Skip to content

Commit c92801f

Browse files
Merge pull request #7749 from rabbitmq/mergify/bp/v3.11.x/pr-7748
QQ: add test for message ttl using a policy. (backport #7747) (backport #7748)
2 parents 8182cfd + 91829f4 commit c92801f

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

deps/rabbit/test/quorum_queue_SUITE.erl

+36
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ all_tests() ->
148148
peek,
149149
peek_with_wrong_queue_type,
150150
message_ttl,
151+
message_ttl_policy,
151152
per_message_ttl,
152153
per_message_ttl_mixed_expiry,
153154
per_message_ttl_expiration_too_high,
@@ -2614,6 +2615,41 @@ message_ttl(Config) ->
26142615
wait_for_messages(Config, [[QQ, <<"0">>, <<"0">>, <<"0">>]]),
26152616
ok.
26162617

2618+
message_ttl_policy(Config) ->
2619+
[Server | _] = rabbit_ct_broker_helpers:get_node_configs(Config, nodename),
2620+
2621+
Ch = rabbit_ct_client_helpers:open_channel(Config, Server),
2622+
QQ = ?config(queue_name, Config),
2623+
?assertEqual({'queue.declare_ok', QQ, 0, 0},
2624+
declare(Ch, QQ, [{<<"x-queue-type">>, longstr, <<"quorum">>}])),
2625+
2626+
ok = rabbit_ct_broker_helpers:set_policy(Config, 0, <<"msg-ttl">>,
2627+
QQ, <<"queues">>,
2628+
[{<<"message-ttl">>, 1000}]),
2629+
VHost = <<"%2F">>,
2630+
RaName = binary_to_atom(<<VHost/binary, "_", QQ/binary>>, utf8),
2631+
2632+
QueryFun = fun rabbit_fifo:overview/1,
2633+
{ok, {_, Overview}, _} = rpc:call(Server, ra, local_query, [RaName, QueryFun]),
2634+
?assertMatch(#{config := #{msg_ttl := 1000}}, Overview),
2635+
%% wait for policy?
2636+
Msg1 = <<"msg1">>,
2637+
Msg2 = <<"msg11">>,
2638+
2639+
publish(Ch, QQ, Msg1),
2640+
publish(Ch, QQ, Msg2),
2641+
wait_for_messages(Config, [[QQ, <<"2">>, <<"2">>, <<"0">>]]),
2642+
wait_for_messages(Config, [[QQ, <<"0">>, <<"0">>, <<"0">>]]),
2643+
ok = rabbit_ct_broker_helpers:set_policy(Config, 0, <<"msg-ttl">>,
2644+
QQ, <<"queues">>,
2645+
[{<<"message-ttl">>, 3000}]),
2646+
{ok, {_, Overview2}, _} = rpc:call(Server, ra, local_query, [RaName, QueryFun]),
2647+
?assertMatch(#{config := #{msg_ttl := 3000}}, Overview2),
2648+
publish(Ch, QQ, Msg1),
2649+
wait_for_messages(Config, [[QQ, <<"1">>, <<"1">>, <<"0">>]]),
2650+
wait_for_messages(Config, [[QQ, <<"0">>, <<"0">>, <<"0">>]]),
2651+
ok.
2652+
26172653
per_message_ttl(Config) ->
26182654
[Server | _] = rabbit_ct_broker_helpers:get_node_configs(Config, nodename),
26192655

0 commit comments

Comments
 (0)