Skip to content

Commit 0c38622

Browse files
Shovel HTTP API: more tests for dynamic shovels
1 parent 982c11c commit 0c38622

File tree

1 file changed

+90
-4
lines changed

1 file changed

+90
-4
lines changed

deps/rabbitmq_shovel_management/test/http_SUITE.erl

Lines changed: 90 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ groups() ->
2929
{dynamic_shovels, [], [
3030
start_and_list_a_dynamic_amqp10_shovel,
3131
start_and_get_a_dynamic_amqp10_shovel,
32+
start_and_get_a_dynamic_amqp091_shovel_with_publish_properties,
33+
start_and_get_a_dynamic_amqp091_shovel_with_missing_publish_properties,
34+
start_and_get_a_dynamic_amqp091_shovel_with_empty_publish_properties,
3235
create_and_delete_a_dynamic_shovel_that_successfully_connects,
3336
create_and_delete_a_dynamic_shovel_that_fails_to_connect
3437
]},
@@ -127,7 +130,7 @@ start_inets(Config) ->
127130

128131
start_and_list_a_dynamic_amqp10_shovel(Config) ->
129132
remove_all_dynamic_shovels(Config, <<"/">>),
130-
Name = <<"dynamic-amqp10-await-startup-1">>,
133+
Name = rabbit_data_coercion:to_binary(?FUNCTION_NAME),
131134
ID = {<<"/">>, Name},
132135
await_shovel_removed(Config, ID),
133136

@@ -144,15 +147,15 @@ start_and_list_a_dynamic_amqp10_shovel(Config) ->
144147

145148
start_and_get_a_dynamic_amqp10_shovel(Config) ->
146149
remove_all_dynamic_shovels(Config, <<"/">>),
147-
Name = <<"dynamic-amqp10-get-shovel-1">>,
150+
Name = rabbit_data_coercion:to_binary(?FUNCTION_NAME),
148151
ID = {<<"/">>, Name},
149152
await_shovel_removed(Config, ID),
150153

151154
declare_shovel(Config, Name),
152155
await_shovel_startup(Config, ID),
153156
Sh = get_shovel(Config, Name),
154157
?assertEqual(Name, maps:get(name, Sh)),
155-
delete_shovel(Config, <<"dynamic-amqp10-await-startup-1">>),
158+
delete_shovel(Config, Name),
156159

157160
ok.
158161

@@ -167,6 +170,48 @@ start_and_get_a_dynamic_amqp10_shovel(Config) ->
167170
vhost := <<"v">>,
168171
type := <<"dynamic">>}).
169172

173+
start_and_get_a_dynamic_amqp091_shovel_with_publish_properties(Config) ->
174+
remove_all_dynamic_shovels(Config, <<"/">>),
175+
Name = rabbit_data_coercion:to_binary(?FUNCTION_NAME),
176+
ID = {<<"/">>, Name},
177+
await_shovel_removed(Config, ID),
178+
179+
declare_amqp091_shovel_with_publish_properties(Config, Name),
180+
await_shovel_startup(Config, ID),
181+
Sh = get_shovel(Config, Name),
182+
?assertEqual(Name, maps:get(name, Sh)),
183+
delete_shovel(Config, Name),
184+
185+
ok.
186+
187+
start_and_get_a_dynamic_amqp091_shovel_with_missing_publish_properties(Config) ->
188+
remove_all_dynamic_shovels(Config, <<"/">>),
189+
Name = rabbit_data_coercion:to_binary(?FUNCTION_NAME),
190+
ID = {<<"/">>, Name},
191+
await_shovel_removed(Config, ID),
192+
193+
declare_amqp091_shovel(Config, Name),
194+
await_shovel_startup(Config, ID),
195+
Sh = get_shovel(Config, Name),
196+
?assertEqual(Name, maps:get(name, Sh)),
197+
delete_shovel(Config, Name),
198+
199+
ok.
200+
201+
start_and_get_a_dynamic_amqp091_shovel_with_empty_publish_properties(Config) ->
202+
remove_all_dynamic_shovels(Config, <<"/">>),
203+
Name = rabbit_data_coercion:to_binary(?FUNCTION_NAME),
204+
ID = {<<"/">>, Name},
205+
await_shovel_removed(Config, ID),
206+
207+
declare_amqp091_shovel_with_publish_properties(Config, Name, #{}),
208+
await_shovel_startup(Config, ID),
209+
Sh = get_shovel(Config, Name),
210+
?assertEqual(Name, maps:get(name, Sh)),
211+
delete_shovel(Config, Name),
212+
213+
ok.
214+
170215
start_static_shovels(Config) ->
171216
http_put(Config, "/users/admin",
172217
#{password => <<"admin">>, tags => <<"administrator">>}, ?CREATED),
@@ -366,7 +411,48 @@ declare_shovel(Config, Name) ->
366411
'dest-address' => <<"test2">>,
367412
'dest-properties' => #{},
368413
'dest-application-properties' => #{},
369-
'dest-message-annotations' => #{}}
414+
'dest-message-annotations' => #{}
415+
}
416+
}, ?CREATED).
417+
418+
declare_amqp091_shovel(Config, Name) ->
419+
Port = integer_to_binary(
420+
rabbit_ct_broker_helpers:get_node_config(Config, 0, tcp_port_amqp)),
421+
http_put(Config, io_lib:format("/parameters/shovel/%2f/~ts", [Name]),
422+
#{
423+
value => #{
424+
<<"src-protocol">> => <<"amqp091">>,
425+
<<"src-uri">> => <<"amqp://localhost:", Port/binary>>,
426+
<<"src-queue">> => <<"amqp091.src.test">>,
427+
<<"src-delete-after">> => <<"never">>,
428+
<<"dest-protocol">> => <<"amqp091">>,
429+
<<"dest-uri">> => <<"amqp://localhost:", Port/binary>>,
430+
<<"dest-queue">> => <<"amqp091.dest.test">>
431+
}
432+
}, ?CREATED).
433+
434+
declare_amqp091_shovel_with_publish_properties(Config, Name) ->
435+
Props = #{
436+
<<"delivery_mode">> => 2,
437+
<<"app_id">> => <<"shovel_management:http_SUITE">>
438+
},
439+
declare_amqp091_shovel_with_publish_properties(Config, Name, Props).
440+
441+
declare_amqp091_shovel_with_publish_properties(Config, Name, Props) ->
442+
Port = integer_to_binary(
443+
rabbit_ct_broker_helpers:get_node_config(Config, 0, tcp_port_amqp)),
444+
http_put(Config, io_lib:format("/parameters/shovel/%2f/~ts", [Name]),
445+
#{
446+
value => #{
447+
<<"src-protocol">> => <<"amqp091">>,
448+
<<"src-uri">> => <<"amqp://localhost:", Port/binary>>,
449+
<<"src-queue">> => <<"amqp091.src.test">>,
450+
<<"src-delete-after">> => <<"never">>,
451+
<<"dest-protocol">> => <<"amqp091">>,
452+
<<"dest-uri">> => <<"amqp://localhost:", Port/binary>>,
453+
<<"dest-queue">> => <<"amqp091.dest.test">>,
454+
<<"dest-publish-properties">> => Props
455+
}
370456
}, ?CREATED).
371457

372458
await_shovel_startup(Config, Name) ->

0 commit comments

Comments
 (0)