@@ -24,6 +24,7 @@ all() ->
24
24
{group , per_object_endpoint_metrics },
25
25
{group , commercial },
26
26
{group , detailed_metrics },
27
+ {group , special_chars },
27
28
{group , authentication }
28
29
].
29
30
@@ -62,6 +63,7 @@ groups() ->
62
63
exchange_bindings_metric ,
63
64
exchange_names_metric
64
65
]},
66
+ {special_chars , [], [core_metrics_special_chars ]},
65
67
{authentication , [], [basic_auth ]}
66
68
].
67
69
@@ -206,6 +208,39 @@ init_per_group(commercial, Config0) ->
206
208
Config1 = rabbit_ct_helpers :merge_app_env (Config0 , ProductConfig ),
207
209
init_per_group (commercial , Config1 , []);
208
210
211
+ init_per_group (special_chars , Config0 ) ->
212
+ StatsEnv = {rabbit , [{collect_statistics , fine }, {collect_statistics_interval , 100 }]},
213
+ Config1 = init_per_group (special_chars , rabbit_ct_helpers :merge_app_env (Config0 , StatsEnv ), []),
214
+
215
+ VHost = <<" vhost\"\n\\ " >>,
216
+ rabbit_ct_broker_helpers :add_vhost (Config1 , 0 , VHost , <<" guest" >>),
217
+ rabbit_ct_broker_helpers :set_full_permissions (Config1 , VHost ),
218
+ VHostConn = rabbit_ct_client_helpers :open_unmanaged_connection (Config1 , 0 , VHost ),
219
+ {ok , VHostCh } = amqp_connection :open_channel (VHostConn ),
220
+
221
+ % % new line characters (\r and \n) are removed from queue and
222
+ % % exchange names during creation (unlike for vhosts)
223
+ QName = <<" queue\"\\ " >>,
224
+ # 'queue.declare_ok' {} = amqp_channel :call (VHostCh ,
225
+ # 'queue.declare' {queue = QName ,
226
+ durable = true
227
+ }),
228
+ Exchange = <<" exchange\"\\ " >>,
229
+ # 'exchange.declare_ok' {} = amqp_channel :call (VHostCh , # 'exchange.declare' {exchange = Exchange }),
230
+ # 'queue.bind_ok' {} = amqp_channel :call (VHostCh , # 'queue.bind' {queue = QName , exchange = Exchange , routing_key = QName }),
231
+
232
+ amqp_channel :call (VHostCh ,
233
+ # 'basic.publish' {exchange = Exchange , routing_key = QName },
234
+ # amqp_msg {payload = <<" msg" >>}),
235
+
236
+ Config2 = [{vhost_name , VHost },
237
+ {queue_name , QName },
238
+ {exchange_name , Exchange },
239
+ {connection , VHostConn },
240
+ {channel , VHostCh }
241
+ |Config1 ],
242
+ init_per_group (special_chars , Config2 , []);
243
+
209
244
init_per_group (authentication , Config ) ->
210
245
Config1 = rabbit_ct_helpers :merge_app_env (
211
246
Config , {rabbitmq_prometheus , [{authentication , [{enabled , true }]}]}),
@@ -249,6 +284,11 @@ end_per_group(detailed_metrics, Config) ->
249
284
amqp_channel :close (VHost2Ch ),
250
285
amqp_connection :close (? config (vhost2_conn , Config )),
251
286
287
+ % % Delete queues?
288
+ end_per_group_ (Config );
289
+ end_per_group (special_chars , Config ) ->
290
+ amqp_channel :close (? config (channel , Config )),
291
+ amqp_connection :close (? config (connection , Config )),
252
292
% % Delete queues?
253
293
end_per_group_ (Config );
254
294
end_per_group (authentication , Config ) ->
@@ -560,6 +600,32 @@ exchange_names_metric(Config) ->
560
600
}, Names ),
561
601
ok .
562
602
603
+ core_metrics_special_chars (Config ) ->
604
+ {_ , Body1 } = http_get_with_pal (Config , " /metrics/detailed?family=queue_coarse_metrics" , [], 200 ),
605
+ ? assertMatch (#{rabbitmq_detailed_queue_messages :=
606
+ #{#{vhost => " vhost\\\"\\ n\\\\ " ,
607
+ queue => " queue\\\"\\\\ " } := [I ]}}
608
+ when I == 0 ; I == 1 ,
609
+ parse_response (Body1 )),
610
+
611
+ {_ , Body2 } = http_get_with_pal (Config , " /metrics/detailed?family=channel_exchange_metrics" , [], 200 ),
612
+ #{rabbitmq_detailed_channel_messages_published_total := LabelValue2 } = parse_response (Body2 ),
613
+ ? assertMatch ([{#{channel := _ ,
614
+ vhost := " vhost\\\"\\ n\\\\ " ,
615
+ exchange := " exchange\\\"\\\\ " }, [I ]}]
616
+ when I == 0 ; I == 1 ,
617
+ maps :to_list (LabelValue2 )),
618
+
619
+ {_ , Body3 } = http_get_with_pal (Config , " /metrics/detailed?family=channel_queue_exchange_metrics" , [], 200 ),
620
+ #{rabbitmq_detailed_queue_messages_published_total := LabelValue3 } = parse_response (Body3 ),
621
+ ? assertMatch ([{#{channel := _ ,
622
+ queue_vhost := " vhost\\\"\\ n\\\\ " ,
623
+ queue := " queue\\\"\\\\ " ,
624
+ exchange_vhost := " vhost\\\"\\ n\\\\ " ,
625
+ exchange := " exchange\\\"\\\\ " }, [I ]}]
626
+ when I == 0 ; I == 1 ,
627
+ maps :to_list (LabelValue3 )),
628
+ ok .
563
629
564
630
basic_auth (Config ) ->
565
631
http_get (Config , [{" accept-encoding" , " deflate" }], 401 ),
0 commit comments