@@ -24,7 +24,8 @@ groups() ->
2424 [
2525 {non_parallel_tests , [], [
2626 tracing_test ,
27- tracing_validation_test
27+ tracing_validation_test ,
28+ trace_file_content_type_test
2829 ]}
2930 ].
3031
@@ -128,6 +129,35 @@ tracing_validation_test(Config) ->
128129 http_delete (Config , Path , ? NO_CONTENT ),
129130 ok .
130131
132+ trace_file_content_type_test (Config ) ->
133+ case filelib :is_dir (? LOG_DIR ) of
134+ true -> {ok , Files } = file :list_dir (? LOG_DIR ),
135+ [ok = file :delete (? LOG_DIR ++ F ) || F <- Files ];
136+ _ -> ok
137+ end ,
138+
139+ Args = #{format => <<" text" >>,
140+ pattern => <<" #" >>},
141+ http_put (Config , " /traces/%2f/test-charset" , Args , ? CREATED ),
142+
143+ Ch = rabbit_ct_client_helpers :open_channel (Config ),
144+ amqp_channel :cast (Ch , # 'basic.publish' { exchange = <<" amq.topic" >>,
145+ routing_key = <<" key" >> },
146+ # amqp_msg {props = # 'P_basic' {},
147+ payload = <<" Test message" >>}),
148+ rabbit_ct_client_helpers :close_channel (Ch ),
149+
150+ timer :sleep (100 ),
151+
152+ http_delete (Config , " /traces/%2f/test-charset" , ? NO_CONTENT ),
153+ {ok , {{_HTTP , 200 , _ }, Headers , _Body }} =
154+ req (Config , get , " /trace-files/test-charset.log" , [auth_header (" guest" , " guest" )]),
155+ ContentType = proplists :get_value (" content-type" , Headers ),
156+ ? assertEqual (match , re :run (ContentType , " text/plain" , [{capture , none }])),
157+ ? assertEqual (match , re :run (ContentType , " charset=utf-8" , [{capture , none }])),
158+ http_delete (Config , " /trace-files/test-charset.log" , ? NO_CONTENT ),
159+ ok .
160+
131161% %---------------------------------------------------------------------------
132162% % TODO: Below is copied from rabbit_mgmt_test_http,
133163% % should be moved to use rabbit_mgmt_test_util once rabbitmq_management
0 commit comments