Skip to content

Commit f669567

Browse files
dcorbachomergify[bot]
authored andcommitted
Shovel: more common testcases
(cherry picked from commit 059813a) # Conflicts: # deps/rabbitmq_shovel/test/shovel_dynamic_SUITE.erl
1 parent 4edd9f7 commit f669567

File tree

4 files changed

+88
-89
lines changed

4 files changed

+88
-89
lines changed

deps/rabbitmq_shovel/test/amqp091_dynamic_SUITE.erl

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ groups() ->
4040
restart,
4141
change_definition,
4242
autodelete,
43-
autodelete_with_rejections,
4443
validation,
4544
security_validation,
4645
get_connection_name,
@@ -517,35 +516,6 @@ autodelete_do(Config, {AckMode, After, ExpSrc, ExpDest}) ->
517516
expect_count(Ch, <<"src">>, <<"hello">>, ExpSrc)
518517
end.
519518

520-
autodelete_with_rejections(Config) ->
521-
Src = <<"src">>,
522-
Dest = <<"dst">>,
523-
Args = [{<<"x-max-length">>, long, 5},
524-
{<<"x-overflow">>, longstr, <<"reject-publish">>}],
525-
with_ch(Config,
526-
fun (Ch) ->
527-
amqp_channel:call(Ch, #'queue.declare'{queue = Dest,
528-
durable = true,
529-
arguments = Args}),
530-
shovel_test_utils:set_param(Config, <<"test">>,
531-
[{<<"src-protocol">>, <<"local">>},
532-
{<<"src-queue">>, Src},
533-
{<<"src-delete-after">>, 10},
534-
{<<"dest-protocol">>, <<"local">>},
535-
{<<"dest-predeclared">>, true},
536-
{<<"dest-queue">>, Dest}
537-
]),
538-
publish_count(Ch, <<>>, Src, <<"hello">>, 10),
539-
await_autodelete(Config, <<"test">>),
540-
Expected = lists:sort([[Src, <<"5">>], [Dest, <<"5">>]]),
541-
eventually(
542-
?_assertMatch(
543-
Expected,
544-
lists:sort(rabbit_ct_broker_helpers:rabbitmqctl_list(
545-
Config, 0,
546-
["list_queues", "name", "messages_ready", "--no-table-headers"]))))
547-
end).
548-
549519
validation(Config) ->
550520
URIs = [{<<"src-uri">>, <<"amqp://">>},
551521
{<<"dest-uri">>, <<"amqp://">>}],

deps/rabbitmq_shovel/test/amqp10_dynamic_SUITE.erl

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ groups() ->
3333
{non_parallel_tests, [], [
3434
simple,
3535
change_definition,
36-
autodelete_with_rejections,
3736
simple_amqp10_dest,
3837
simple_amqp10_src,
3938
amqp091_to_amqp10_with_dead_lettering,
@@ -266,34 +265,6 @@ change_definition(Config) ->
266265
amqp10_expect_empty(Sess, Dest2)
267266
end).
268267

269-
autodelete_with_rejections(Config) ->
270-
Src = ?config(srcq, Config),
271-
Dest = ?config(destq, Config),
272-
with_amqp10_session(
273-
Config,
274-
fun (Sess) ->
275-
amqp10_declare_queue(Sess, Dest, #{<<"x-max-length">> => {uint, 5},
276-
<<"x-overflow">> => {utf8, <<"reject-publish">>}}),
277-
278-
shovel_test_utils:set_param(Config, ?PARAM,
279-
[{<<"src-protocol">>, <<"local">>},
280-
{<<"src-queue">>, Src},
281-
{<<"src-delete-after">>, 10},
282-
{<<"dest-protocol">>, <<"local">>},
283-
{<<"dest-predeclared">>, true},
284-
{<<"dest-queue">>, Dest}
285-
]),
286-
amqp10_publish(Sess, Src, <<"hello">>, 10),
287-
await_autodelete(Config, <<"test">>),
288-
Expected = lists:sort([[Src, <<"5">>], [Dest, <<"5">>]]),
289-
?awaitMatch(
290-
Expected,
291-
lists:sort(rabbit_ct_broker_helpers:rabbitmqctl_list(
292-
Config, 0,
293-
["list_queues", "name", "messages_ready", "--no-table-headers"])),
294-
30_000)
295-
end).
296-
297268
test_amqp10_delete_after_queue_length(Config) ->
298269
Src = ?config(srcq, Config),
299270
Dest = ?config(destq, Config),

deps/rabbitmq_shovel/test/local_dynamic_SUITE.erl

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ groups() ->
5353
local_to_local_delete_after_never,
5454
local_to_local_delete_after_queue_length,
5555
local_to_local_delete_after_queue_length_zero,
56-
local_to_local_delete_after_with_rejections,
5756
local_to_local_no_ack,
5857
local_to_local_quorum_no_ack,
5958
local_to_local_stream_no_ack,
@@ -566,34 +565,6 @@ local_to_local_delete_after_queue_length(Config) ->
566565
amqp10_expect_empty(Sess, Dest)
567566
end).
568567

569-
local_to_local_delete_after_with_rejections(Config) ->
570-
Src = ?config(srcq, Config),
571-
Dest = ?config(destq, Config),
572-
VHost = <<"/">>,
573-
declare_queue(Config, VHost, Dest, [{<<"x-max-length">>, long, 5},
574-
{<<"x-overflow">>, longstr, <<"reject-publish">>}]),
575-
with_amqp10_session(Config,
576-
fun (Sess) ->
577-
shovel_test_utils:set_param(Config, ?PARAM,
578-
[{<<"src-protocol">>, <<"local">>},
579-
{<<"src-queue">>, Src},
580-
{<<"src-delete-after">>, 10},
581-
{<<"dest-protocol">>, <<"local">>},
582-
{<<"dest-predeclared">>, true},
583-
{<<"dest-queue">>, Dest}
584-
]),
585-
amqp10_publish(Sess, Src, <<"tag1">>, 10),
586-
?awaitMatch(not_found, rabbit_ct_broker_helpers:rpc(Config, 0, rabbit_runtime_parameters, lookup, [<<"/">>, <<"shovel">>, ?PARAM]), 30_000),
587-
Expected = lists:sort([[Src, <<"5">>], [Dest, <<"5">>]]),
588-
?awaitMatch(
589-
Expected,
590-
lists:sort(rabbit_ct_broker_helpers:rabbitmqctl_list(
591-
Config, 0,
592-
["list_queues", "name", "messages_ready", "--no-table-headers"])),
593-
30_000)
594-
595-
end).
596-
597568
local_to_local_no_ack(Config) ->
598569
Src = ?config(srcq, Config),
599570
Dest = ?config(destq, Config),

deps/rabbitmq_shovel/test/shovel_dynamic_SUITE.erl

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
-compile(export_all).
1616

17+
-import(rabbit_ct_helpers, [eventually/3]).
1718
-import(shovel_test_utils, [await_autodelete/2,
1819
set_param/3,
1920
set_param_nowait/3,
@@ -69,7 +70,11 @@ tests() ->
6970
autodelete_classic_on_confirm_no_transfer,
7071
autodelete_quorum_on_confirm_no_transfer,
7172
autodelete_classic_on_publish_no_transfer,
72-
autodelete_quorum_on_publish_no_transfer
73+
autodelete_quorum_on_publish_no_transfer,
74+
autodelete_classic_on_confirm_with_rejections,
75+
autodelete_quorum_on_confirm_with_rejections,
76+
autodelete_classic_on_publish_with_rejections,
77+
autodelete_quorum_on_publish_with_rejections
7378
].
7479

7580
%% -------------------------------------------------------------------
@@ -311,7 +316,80 @@ autodelete(Config, Type, AckMode, After, ExpSrc, ExpDest) ->
311316
amqp10_expect_count(Sess, Dest, ExpDest)
312317
end).
313318

319+
<<<<<<< HEAD
314320
>>>>>>> d5f9ff27b (Shovel tests: tests for autodelete common to all protocols)
321+
=======
322+
autodelete_classic_on_confirm_with_rejections(Config) ->
323+
autodelete_with_rejections(Config, <<"classic">>, <<"on-confirm">>, 5, 5).
324+
325+
autodelete_quorum_on_confirm_with_rejections(Config) ->
326+
ExpSrc = fun(ExpDest) -> 100 - ExpDest end,
327+
autodelete_with_quorum_rejections(Config, <<"on-confirm">>, ExpSrc).
328+
329+
autodelete_classic_on_publish_with_rejections(Config) ->
330+
autodelete_with_rejections(Config, <<"classic">>, <<"on-publish">>, 0, 5).
331+
332+
autodelete_quorum_on_publish_with_rejections(Config) ->
333+
ExpSrc = fun(_) -> 0 end,
334+
autodelete_with_quorum_rejections(Config, <<"on-publish">>, ExpSrc).
335+
336+
autodelete_with_rejections(Config, Type, AckMode, ExpSrc, ExpDest) ->
337+
Src = ?config(srcq, Config),
338+
Dest = ?config(destq, Config),
339+
with_amqp10_session(
340+
Config,
341+
fun (Sess) ->
342+
amqp10_declare_queue(Sess, Src, #{<<"x-queue-type">> => {utf8, Type}}),
343+
amqp10_declare_queue(Sess, Dest, #{<<"x-queue-type">> => {utf8, Type},
344+
<<"x-overflow">> => {utf8, <<"reject-publish">>},
345+
<<"x-max-length">> => {ulong, 5}
346+
}),
347+
amqp10_publish(Sess, Src, <<"hello">>, 10),
348+
ExtraArgs = [{<<"ack-mode">>, AckMode},
349+
{<<"src-delete-after">>, 10}],
350+
ShovelArgs = ?config(shovel_args, Config) ++ ExtraArgs,
351+
set_param_nowait(Config, ?PARAM, ShovelArgs),
352+
await_autodelete(Config, ?PARAM),
353+
Expected = lists:sort([[Src, integer_to_binary(ExpSrc)],
354+
[Dest, integer_to_binary(ExpDest)]]),
355+
?awaitMatch(
356+
Expected,
357+
lists:sort(rabbit_ct_broker_helpers:rabbitmqctl_list(
358+
Config, 0,
359+
["list_queues", "name", "messages", "--no-table-headers"])),
360+
45_000),
361+
amqp10_expect_count(Sess, Src, ExpSrc),
362+
amqp10_expect_count(Sess, Dest, ExpDest)
363+
end).
364+
365+
autodelete_with_quorum_rejections(Config, AckMode, ExpSrcFun) ->
366+
Src = ?config(srcq, Config),
367+
Dest = ?config(destq, Config),
368+
Type = <<"quorum">>,
369+
with_amqp10_session(
370+
Config,
371+
fun (Sess) ->
372+
amqp10_declare_queue(Sess, Src, #{<<"x-queue-type">> => {utf8, Type}}),
373+
amqp10_declare_queue(Sess, Dest, #{<<"x-queue-type">> => {utf8, Type},
374+
<<"x-overflow">> => {utf8, <<"reject-publish">>},
375+
<<"x-max-length">> => {ulong, 5}
376+
}),
377+
amqp10_publish(Sess, Src, <<"hello">>, 100),
378+
ExtraArgs = [{<<"ack-mode">>, AckMode},
379+
{<<"src-delete-after">>, 50}],
380+
ShovelArgs = ?config(shovel_args, Config) ++ ExtraArgs,
381+
set_param_nowait(Config, ?PARAM, ShovelArgs),
382+
await_autodelete(Config, ?PARAM),
383+
eventually(
384+
?_assert(
385+
list_queue_messages(Config, Dest) >= 5),
386+
1000, 45),
387+
ExpDest = list_queue_messages(Config, Dest),
388+
amqp10_expect_count(Sess, Src, ExpSrcFun(ExpDest)),
389+
amqp10_expect_count(Sess, Dest, ExpDest)
390+
end).
391+
392+
>>>>>>> 059813a83 (Shovel: more common testcases)
315393
%%----------------------------------------------------------------------------
316394
maybe_skip_local_protocol(Config) ->
317395
[Node] = rabbit_ct_broker_helpers:get_node_configs(Config, nodename),
@@ -322,3 +400,12 @@ maybe_skip_local_protocol(Config) ->
322400
_ ->
323401
{skip, "This group requires rabbitmq_4.0.0 feature flag"}
324402
end.
403+
404+
list_queue_messages(Config, QName) ->
405+
List = rabbit_ct_broker_helpers:rabbitmqctl_list(
406+
Config, 0,
407+
["list_queues", "name", "messages", "--no-table-headers"]),
408+
[[_, Messages]] = lists:filter(fun([Q, _]) ->
409+
Q == QName
410+
end, List),
411+
binary_to_integer(Messages).

0 commit comments

Comments
 (0)