@@ -148,6 +148,7 @@ all_tests() ->
148
148
peek ,
149
149
peek_with_wrong_queue_type ,
150
150
message_ttl ,
151
+ message_ttl_policy ,
151
152
per_message_ttl ,
152
153
per_message_ttl_mixed_expiry ,
153
154
per_message_ttl_expiration_too_high ,
@@ -2614,6 +2615,41 @@ message_ttl(Config) ->
2614
2615
wait_for_messages (Config , [[QQ , <<" 0" >>, <<" 0" >>, <<" 0" >>]]),
2615
2616
ok .
2616
2617
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
+
2617
2653
per_message_ttl (Config ) ->
2618
2654
[Server | _ ] = rabbit_ct_broker_helpers :get_node_configs (Config , nodename ),
2619
2655
0 commit comments