55% % Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved.
66% %
77
8- -module (amqp_system_SUITE ).
8+ -module (amqp_dotnet_SUITE ).
99
1010-include_lib (" common_test/include/ct.hrl" ).
11+ -include_lib (" eunit/include/eunit.hrl" ).
1112-include_lib (" rabbit_common/include/rabbit_framing.hrl" ).
1213
1314-compile (nowarn_export_all ).
1415-compile (export_all ).
1516
1617all () ->
1718 [
18- {group , dotnet },
19- {group , java }
19+ {group , cluster_size_1 }
2020 ].
2121
2222groups () ->
23- [
24- {dotnet , [], [
25- roundtrip ,
26- roundtrip_to_amqp_091 ,
27- default_outcome ,
28- no_routes_is_released ,
29- outcomes ,
30- fragmentation ,
31- message_annotations ,
32- footer ,
33- data_types ,
34- % % TODO at_most_once,
35- reject ,
36- redelivery ,
37- released ,
38- routing ,
39- invalid_routes ,
40- auth_failure ,
41- access_failure_not_allowed ,
42- access_failure_send ,
43- streams
44- ]},
45- {java , [], [
46- roundtrip
47- ]}
48- ].
23+ [{cluster_size_1 , [],
24+ [
25+ roundtrip ,
26+ roundtrip_to_amqp_091 ,
27+ default_outcome ,
28+ no_routes_is_released ,
29+ outcomes ,
30+ fragmentation ,
31+ message_annotations ,
32+ footer ,
33+ data_types ,
34+ reject ,
35+ redelivery ,
36+ released ,
37+ routing ,
38+ invalid_routes ,
39+ auth_failure ,
40+ access_failure_not_allowed ,
41+ access_failure_send ,
42+ streams
43+ ]
44+ }].
4945
5046% % -------------------------------------------------------------------
5147% % Testsuite setup/teardown.
@@ -63,26 +59,20 @@ init_per_suite(Config) ->
6359end_per_suite (Config ) ->
6460 Config .
6561
66- init_per_group (Group , Config ) ->
62+ init_per_group (cluster_size_1 , Config ) ->
6763 Suffix = rabbit_ct_helpers :testcase_absname (Config , " " , " -" ),
68- Config1 = rabbit_ct_helpers :set_config (Config , [
69- {rmq_nodename_suffix , Suffix },
70- {amqp_client_library , Group }
71- ]),
72- GroupSetupStep = case Group of
73- dotnet -> fun build_dotnet_test_project /1 ;
74- java -> fun build_maven_test_project /1
75- end ,
64+ Config1 = rabbit_ct_helpers :set_config (Config , {rmq_nodename_suffix , Suffix }),
7665 Config2 = rabbit_ct_helpers :run_setup_steps (
7766 Config1 ,
78- [GroupSetupStep ] ++
67+ [fun build_dotnet_test_project / 1 ] ++
7968 rabbit_ct_broker_helpers :setup_steps () ++
8069 rabbit_ct_client_helpers :setup_steps ()),
8170 ok = rabbit_ct_broker_helpers :enable_feature_flag (Config2 , 'rabbitmq_4.0.0' ),
8271 Config2 .
8372
8473end_per_group (_ , Config ) ->
85- rabbit_ct_helpers :run_teardown_steps (Config ,
74+ rabbit_ct_helpers :run_teardown_steps (
75+ Config ,
8676 rabbit_ct_client_helpers :teardown_steps () ++
8777 rabbit_ct_broker_helpers :teardown_steps ()).
8878
@@ -93,28 +83,14 @@ end_per_testcase(Testcase, Config) ->
9383 rabbit_ct_helpers :testcase_finished (Config , Testcase ).
9484
9585build_dotnet_test_project (Config ) ->
96- TestProjectDir = filename :join (
97- [? config (data_dir , Config ), " fsharp-tests" ]),
98- Ret = rabbit_ct_helpers :exec ([" dotnet" , " restore" ],
99- [{cd , TestProjectDir }]),
100- case Ret of
86+ TestProjectDir = filename :join ([? config (data_dir , Config ), " fsharp-tests" ]),
87+ case rabbit_ct_helpers :exec ([" dotnet" , " restore" ],
88+ [{cd , TestProjectDir }]) of
10189 {ok , _ } ->
10290 rabbit_ct_helpers :set_config (
10391 Config , {dotnet_test_project_dir , TestProjectDir });
104- _ ->
105- ct :fail ({" 'dotnet restore' failed" , Ret })
106- end .
107-
108- build_maven_test_project (Config ) ->
109- TestProjectDir = filename :join ([? config (data_dir , Config ), " java-tests" ]),
110- Ret = rabbit_ct_helpers :exec ([TestProjectDir ++ " /mvnw" , " test-compile" ],
111- [{cd , TestProjectDir }]),
112- case Ret of
113- {ok , _ } ->
114- rabbit_ct_helpers :set_config (Config ,
115- {maven_test_project_dir , TestProjectDir });
116- _ ->
117- ct :fail ({" 'mvnw test-compile' failed" , Ret })
92+ Other ->
93+ ct :fail ({" 'dotnet restore' failed" , Other })
11894 end .
11995
12096% % -------------------------------------------------------------------
@@ -123,58 +99,53 @@ build_maven_test_project(Config) ->
12399
124100roundtrip (Config ) ->
125101 declare_queue (Config , ? FUNCTION_NAME , " quorum" ),
126- run (Config , [{dotnet , " roundtrip" },
127- {java , " RoundTripTest" }]).
128-
129- streams (Config ) ->
130- declare_queue (Config , ? FUNCTION_NAME , " stream" ),
131- run (Config , [{dotnet , " streams" }]).
102+ run (? FUNCTION_NAME , Config ).
132103
133104roundtrip_to_amqp_091 (Config ) ->
134105 declare_queue (Config , ? FUNCTION_NAME , " classic" ),
135- run (Config , [{ dotnet , " roundtrip_to_amqp_091 " }] ).
106+ run (? FUNCTION_NAME , Config ).
136107
137108default_outcome (Config ) ->
138109 declare_queue (Config , ? FUNCTION_NAME , " classic" ),
139- run (Config , [{ dotnet , " default_outcome " }] ).
110+ run (? FUNCTION_NAME , Config ).
140111
141112no_routes_is_released (Config ) ->
142113 Ch = rabbit_ct_client_helpers :open_channel (Config ),
143114 amqp_channel :call (Ch , # 'exchange.declare' {exchange = <<" no_routes_is_released" >>,
144115 durable = true }),
145- run (Config , [{ dotnet , " no_routes_is_released " }] ).
116+ run (? FUNCTION_NAME , Config ).
146117
147118outcomes (Config ) ->
148119 declare_queue (Config , ? FUNCTION_NAME , " classic" ),
149- run (Config , [{ dotnet , " outcomes " }] ).
120+ run (? FUNCTION_NAME , Config ).
150121
151122fragmentation (Config ) ->
152123 declare_queue (Config , ? FUNCTION_NAME , " classic" ),
153- run (Config , [{ dotnet , " fragmentation " }] ).
124+ run (? FUNCTION_NAME , Config ).
154125
155126message_annotations (Config ) ->
156127 declare_queue (Config , ? FUNCTION_NAME , " classic" ),
157- run (Config , [{ dotnet , " message_annotations " }] ).
128+ run (? FUNCTION_NAME , Config ).
158129
159130footer (Config ) ->
160131 declare_queue (Config , ? FUNCTION_NAME , " classic" ),
161- run (Config , [{ dotnet , " footer " }] ).
132+ run (? FUNCTION_NAME , Config ).
162133
163134data_types (Config ) ->
164135 declare_queue (Config , ? FUNCTION_NAME , " classic" ),
165- run (Config , [{ dotnet , " data_types " }] ).
136+ run (? FUNCTION_NAME , Config ).
166137
167138reject (Config ) ->
168139 declare_queue (Config , ? FUNCTION_NAME , " classic" ),
169- run (Config , [{ dotnet , " reject " }] ).
140+ run (? FUNCTION_NAME , Config ).
170141
171142redelivery (Config ) ->
172143 declare_queue (Config , ? FUNCTION_NAME , " quorum" ),
173- run (Config , [{ dotnet , " redelivery " }] ).
144+ run (? FUNCTION_NAME , Config ).
174145
175146released (Config ) ->
176147 declare_queue (Config , ? FUNCTION_NAME , " quorum" ),
177- run (Config , [{ dotnet , " released " }] ).
148+ run (? FUNCTION_NAME , Config ).
178149
179150routing (Config ) ->
180151 Ch = rabbit_ct_client_helpers :open_channel (Config ),
@@ -203,23 +174,18 @@ routing(Config) ->
203174 exchange = <<" amq.direct" >>,
204175 routing_key = <<" direct_q" >>
205176 }),
206-
207- run (Config , [
208- {dotnet , " routing" }
209- ]).
177+ run (? FUNCTION_NAME , Config ).
210178
211179invalid_routes (Config ) ->
212- run (Config , [
213- {dotnet , " invalid_routes" }
214- ]).
180+ run (? FUNCTION_NAME , Config ).
215181
216182auth_failure (Config ) ->
217- run (Config , [ { dotnet , " auth_failure " } ] ).
183+ run (? FUNCTION_NAME , Config ).
218184
219185access_failure_not_allowed (Config ) ->
220186 User = atom_to_binary (? FUNCTION_NAME ),
221187 ok = rabbit_ct_broker_helpers :add_user (Config , User , <<" boo" >>),
222- run (Config , [ { dotnet , " access_failure_not_allowed " } ] ),
188+ run (? FUNCTION_NAME , Config ),
223189 ok = rabbit_ct_broker_helpers :delete_user (Config , User ).
224190
225191access_failure_send (Config ) ->
@@ -230,45 +196,35 @@ access_failure_send(Config) ->
230196 <<" ^banana.*" >>, % % write
231197 <<" ^banana.*" >> % % read
232198 ),
233- run (Config , [ { dotnet , " access_failure_send " } ] ),
199+ run (? FUNCTION_NAME , Config ),
234200 ok = rabbit_ct_broker_helpers :delete_user (Config , User ).
235201
236- run (Config , Flavors ) ->
237- ClientLibrary = ? config (amqp_client_library , Config ),
238- Fun = case ClientLibrary of
239- dotnet -> fun run_dotnet_test /2 ;
240- java -> fun run_java_test /2
241- end ,
242- {ClientLibrary , TestName } = proplists :lookup (ClientLibrary , Flavors ),
243- Fun (Config , TestName ).
202+ streams (Config ) ->
203+ declare_queue (Config , ? FUNCTION_NAME , " stream" ),
204+ run (? FUNCTION_NAME , Config ).
244205
245- run_dotnet_test (Config , Method ) ->
246- TestProjectDir = ? config (dotnet_test_project_dir , Config ),
247- Uri = rabbit_ct_broker_helpers :node_uri (Config , 0 , [{use_ipaddr , true }]),
248- Ret = rabbit_ct_helpers :exec ([" dotnet" , " run" , " --" , Method , Uri ],
249- [
250- {cd , TestProjectDir }
251- ]),
252- ct :pal (" ~s : result ~p " , [? FUNCTION_NAME , Ret ]),
253- {ok , _ } = Ret .
254-
255- run_java_test (Config , Class ) ->
256- TestProjectDir = ? config (maven_test_project_dir , Config ),
257- Ret = rabbit_ct_helpers :exec ([
258- TestProjectDir ++ " /mvnw" ,
259- " test" ,
260- {" -Dtest=~ts " , [Class ]},
261- {" -Drmq_broker_uri=~ts " , [rabbit_ct_broker_helpers :node_uri (Config , 0 )]}
262- ],
263- [{cd , TestProjectDir }]),
264- {ok , _ } = Ret .
206+ % % -------------------------------------------------------------------
207+ % % Helpers
208+ % % -------------------------------------------------------------------
265209
266210declare_queue (Config , Name , Type ) ->
267211 Ch = rabbit_ct_client_helpers :open_channel (Config ),
268212 # 'queue.declare_ok' {} =
269- amqp_channel :call (Ch , # 'queue.declare' {queue = atom_to_binary (Name , utf8 ),
270- durable = true ,
271- arguments = [{<<" x-queue-type" >>,
272- longstr , Type }]}),
213+ amqp_channel :call (Ch , # 'queue.declare' {queue = atom_to_binary (Name , utf8 ),
214+ durable = true ,
215+ arguments = [{<<" x-queue-type" >>,
216+ longstr , Type }]}),
273217 rabbit_ct_client_helpers :close_channel (Ch ),
274218 ok .
219+
220+ run (TestNameAtom , Config ) ->
221+ TestName = atom_to_list (TestNameAtom ),
222+ TestProjectDir = ? config (dotnet_test_project_dir , Config ),
223+ Uri = rabbit_ct_broker_helpers :node_uri (Config , 0 , [{use_ipaddr , true }]),
224+ case rabbit_ct_helpers :exec ([" dotnet" , " run" , " --" , TestName , Uri ],
225+ [{cd , TestProjectDir }]) of
226+ {ok , _Stdout_ } ->
227+ ok ;
228+ {error , _ExitCode , _Stdout } ->
229+ ct :fail (TestName )
230+ end .
0 commit comments