1717
1818all () ->
1919 [
20- queue_created ,
21- authentication ,
22- audit_queue ,
23- audit_exchange ,
24- audit_exchange_internal_parameter ,
25- audit_binding ,
26- audit_vhost ,
27- audit_vhost_deletion ,
28- audit_channel ,
29- audit_connection ,
30- audit_direct_connection ,
31- audit_consumer ,
32- audit_parameter ,
33- audit_policy ,
34- audit_vhost_limit ,
35- audit_user ,
36- audit_user_password ,
37- audit_user_tags ,
38- audit_permission ,
39- audit_topic_permission ,
40- resource_alarm ,
41- unregister
20+ {group , amqp },
21+ {group , amqpl }
22+ ].
23+
24+ groups () ->
25+ [
26+ {amqp , [shuffle ],
27+ [
28+ amqp_connection
29+ ]},
30+ {amqpl , [],
31+ [
32+ queue_created ,
33+ authentication ,
34+ audit_queue ,
35+ audit_exchange ,
36+ audit_exchange_internal_parameter ,
37+ audit_binding ,
38+ audit_vhost ,
39+ audit_vhost_deletion ,
40+ audit_channel ,
41+ audit_connection ,
42+ audit_direct_connection ,
43+ audit_consumer ,
44+ audit_parameter ,
45+ audit_policy ,
46+ audit_vhost_limit ,
47+ audit_user ,
48+ audit_user_password ,
49+ audit_user_tags ,
50+ audit_permission ,
51+ audit_topic_permission ,
52+ resource_alarm ,
53+ unregister
54+ ]}
4255 ].
4356
4457% % -------------------------------------------------------------------
@@ -60,6 +73,9 @@ end_per_suite(Config) ->
6073 rabbit_ct_client_helpers :teardown_steps () ++
6174 rabbit_ct_broker_helpers :teardown_steps ()).
6275
76+ init_per_group (amqp , Config ) ->
77+ {ok , _ } = application :ensure_all_started (rabbitmq_amqp_client ),
78+ Config ;
6379init_per_group (_ , Config ) ->
6480 Config .
6581
@@ -453,6 +469,35 @@ unregister(Config) ->
453469 lookup , [X ])),
454470 ok .
455471
472+ % % Test that the event exchange works when publising and consuming via AMQP 1.0.
473+ amqp_connection (Config ) ->
474+ QName = atom_to_binary (? FUNCTION_NAME ),
475+ Address = rabbitmq_amqp_address :queue (QName ),
476+ {Connection1 , Session , LinkPair } = amqp_init (Config ),
477+ {ok , _ } = rabbitmq_amqp_client :declare_queue (LinkPair , QName ,#{}),
478+ ok = rabbitmq_amqp_client :bind_queue (
479+ LinkPair , QName , <<" amq.rabbitmq.event" >>, <<" connection.*" >>, #{}),
480+ {ok , Receiver } = amqp10_client :attach_receiver_link (
481+ Session , <<" receiver" >>, Address , settled ),
482+
483+ OpnConf0 = amqp_connection_config (Config ),
484+ OpnConf = maps :update (container_id , <<" 2nd container" >>, OpnConf0 ),
485+ {ok , Connection2 } = amqp10_client :open_connection (OpnConf ),
486+ receive {amqp10_event , {connection , Connection2 , opened }} -> ok
487+ after 5000 -> ct :fail ({missing_event , ? LINE })
488+ end ,
489+ {ok , Msg } = amqp10_client :get_msg (Receiver ),
490+ ? assertMatch (#{<<" x-routing-key" >> := <<" connection.created" >>},
491+ amqp10_msg :message_annotations (Msg )),
492+ ? assertMatch (#{<<" container_id" >> := <<" 2nd container" >>},
493+ amqp10_msg :application_properties (Msg )),
494+ ok = amqp10_client :close_connection (Connection2 ),
495+
496+ {ok , _ } = rabbitmq_amqp_client :delete_queue (LinkPair , QName ),
497+ ok = rabbitmq_amqp_client :detach_management_link_pair_sync (LinkPair ),
498+ ok = amqp10_client :end_session (Session ),
499+ ok = amqp10_client :close_connection (Connection1 ).
500+
456501% % -------------------------------------------------------------------
457502% % Helpers
458503% % -------------------------------------------------------------------
@@ -494,3 +539,18 @@ receive_event(Event) ->
494539 60000 ->
495540 throw ({receive_event_timeout , Event })
496541 end .
542+
543+ amqp_init (Config ) ->
544+ OpnConf = amqp_connection_config (Config ),
545+ {ok , Connection } = amqp10_client :open_connection (OpnConf ),
546+ {ok , Session } = amqp10_client :begin_session_sync (Connection ),
547+ {ok , LinkPair } = rabbitmq_amqp_client :attach_management_link_pair_sync (Session , <<" my link pair" >>),
548+ {Connection , Session , LinkPair }.
549+
550+ amqp_connection_config (Config ) ->
551+ Host = proplists :get_value (rmq_hostname , Config ),
552+ Port = rabbit_ct_broker_helpers :get_node_config (Config , 0 , tcp_port_amqp ),
553+ #{address => Host ,
554+ port => Port ,
555+ container_id => <<" my container" >>,
556+ sasl => {plain , <<" guest" >>, <<" guest" >>}}.
0 commit comments