@@ -33,7 +33,8 @@ all() ->
33
33
34
34
groups () ->
35
35
[{single_node , [],
36
- [test_stream ,
36
+ [filtering_ff , % % must stay at the top, feature flag disabled for this one
37
+ test_stream ,
37
38
test_stream_tls ,
38
39
test_publish_v2 ,
39
40
test_gc_consumers ,
@@ -72,6 +73,22 @@ init_per_group(Group, Config)
72
73
{rabbitmq_ct_tls_verify , verify_none },
73
74
{rabbitmq_stream , verify_none }
74
75
]),
76
+ % % filtering feature flag disabled for the first test,
77
+ % % then enabled in the end_per_testcase function
78
+ ExtraSetupSteps =
79
+ case Group of
80
+ single_node ->
81
+ [fun (StepConfig ) ->
82
+ rabbit_ct_helpers :merge_app_env (StepConfig ,
83
+ {rabbit ,
84
+ [{forced_feature_flags_on_init ,
85
+ [stream_queue ,
86
+ stream_sac_coordinator_unblock_group ,
87
+ stream_single_active_consumer ]}]})
88
+ end ];
89
+ _ ->
90
+ []
91
+ end ,
75
92
rabbit_ct_helpers :run_setup_steps (
76
93
Config1 ,
77
94
[fun (StepConfig ) ->
@@ -86,6 +103,7 @@ init_per_group(Group, Config)
86
103
[{connection_negotiation_step_timeout ,
87
104
500 }]})
88
105
end ]
106
+ ++ ExtraSetupSteps
89
107
++ rabbit_ct_broker_helpers :setup_steps ());
90
108
init_per_group (cluster = Group , Config ) ->
91
109
Config1 = rabbit_ct_helpers :set_config (
@@ -123,6 +141,13 @@ init_per_testcase(close_connection_on_consumer_update_timeout = TestCase, Config
123
141
init_per_testcase (TestCase , Config ) ->
124
142
rabbit_ct_helpers :testcase_started (Config , TestCase ).
125
143
144
+ end_per_testcase (filtering_ff = TestCase , Config ) ->
145
+ _ = rabbit_ct_broker_helpers :rpc (Config ,
146
+ 0 ,
147
+ rabbit_feature_flags ,
148
+ enable ,
149
+ [stream_filtering ]),
150
+ rabbit_ct_helpers :testcase_finished (Config , TestCase );
126
151
end_per_testcase (close_connection_on_consumer_update_timeout = TestCase , Config ) ->
127
152
ok = rabbit_ct_broker_helpers :rpc (Config ,
128
153
0 ,
@@ -133,6 +158,32 @@ end_per_testcase(close_connection_on_consumer_update_timeout = TestCase, Config)
133
158
end_per_testcase (TestCase , Config ) ->
134
159
rabbit_ct_helpers :testcase_finished (Config , TestCase ).
135
160
161
+ filtering_ff (Config ) ->
162
+ Stream = atom_to_binary (? FUNCTION_NAME , utf8 ),
163
+ Transport = gen_tcp ,
164
+ Port = get_stream_port (Config ),
165
+ Opts = [{active , false }, {mode , binary }],
166
+ {ok , S } = Transport :connect (" localhost" , Port , Opts ),
167
+ C0 = rabbit_stream_core :init (0 ),
168
+ C1 = test_peer_properties (Transport , S , C0 ),
169
+ C2 = test_authenticate (Transport , S , C1 ),
170
+ C3 = test_create_stream (Transport , S , Stream , C2 ),
171
+ PublisherId = 42 ,
172
+ C4 = test_declare_publisher (Transport , S , PublisherId , Stream , C3 ),
173
+ Body = <<" hello" >>,
174
+ C5 = test_publish_confirm (Transport , S , publish_v2 , PublisherId , Body ,
175
+ publish_error , C4 ),
176
+ SubscriptionId = 42 ,
177
+ C6 = test_subscribe (Transport , S , SubscriptionId , Stream ,
178
+ #{<<" filter.0" >> => <<" foo" >>},
179
+ ? RESPONSE_CODE_PRECONDITION_FAILED ,
180
+ C5 ),
181
+
182
+ C7 = test_delete_stream (Transport , S , Stream , C6 ),
183
+ _C8 = test_close (Transport , S , C7 ),
184
+ closed = wait_for_socket_close (Transport , S , 10 ),
185
+ ok .
186
+
136
187
test_global_counters (Config ) ->
137
188
Stream = atom_to_binary (? FUNCTION_NAME , utf8 ),
138
189
test_server (gen_tcp , Stream , Config ),
@@ -188,11 +239,14 @@ test_publish_v2(Config) ->
188
239
PublisherId = 42 ,
189
240
C4 = test_declare_publisher (Transport , S , PublisherId , Stream , C3 ),
190
241
Body = <<" hello" >>,
191
- C5 = test_publish_confirm (Transport , S , publish_v2 , PublisherId , Body , C4 ),
192
- C6 = test_publish_confirm (Transport , S , publish_v2 , PublisherId , Body , C5 ),
242
+ C5 = test_publish_confirm (Transport , S , publish_v2 , PublisherId , Body ,
243
+ publish_confirm , C4 ),
244
+ C6 = test_publish_confirm (Transport , S , publish_v2 , PublisherId , Body ,
245
+ publish_confirm , C5 ),
193
246
SubscriptionId = 42 ,
194
247
C7 = test_subscribe (Transport , S , SubscriptionId , Stream ,
195
248
#{<<" filter.0" >> => <<" foo" >>},
249
+ ? RESPONSE_CODE_OK ,
196
250
C6 ),
197
251
C8 = test_deliver (Transport , S , SubscriptionId , 0 , Body , C7 ),
198
252
C8b = test_deliver (Transport , S , SubscriptionId , 1 , Body , C8 ),
@@ -419,6 +473,7 @@ close_connection_on_consumer_update_timeout(Config) ->
419
473
C4 = test_subscribe (Transport , S , SubId , Stream ,
420
474
#{<<" single-active-consumer" >> => <<" true" >>,
421
475
<<" name" >> => <<" foo" >>},
476
+ ? RESPONSE_CODE_OK ,
422
477
C3 ),
423
478
{Cmd , _C5 } = receive_commands (Transport , S , C4 ),
424
479
? assertMatch ({request , _ , {consumer_update , SubId , true }}, Cmd ),
@@ -681,18 +736,21 @@ test_declare_publisher(Transport, S, PublisherId, Stream, C0) ->
681
736
C .
682
737
683
738
test_publish_confirm (Transport , S , PublisherId , Body , C0 ) ->
684
- test_publish_confirm (Transport , S , publish , PublisherId , Body , C0 ).
739
+ test_publish_confirm (Transport , S , publish , PublisherId , Body ,
740
+ publish_confirm , C0 ).
685
741
686
- test_publish_confirm (Transport , S , publish = PublishCmd , PublisherId , Body , C0 ) ->
742
+ test_publish_confirm (Transport , S , publish = PublishCmd , PublisherId , Body ,
743
+ ExpectedConfirmCommand ,C0 ) ->
687
744
BodySize = byte_size (Body ),
688
745
Messages = [<<1 :64 , 0 :1 , BodySize :31 , Body :BodySize /binary >>],
689
746
PublishFrame =
690
747
rabbit_stream_core :frame ({PublishCmd , PublisherId , 1 , Messages }),
691
748
ok = Transport :send (S , PublishFrame ),
692
749
{Cmd , C } = receive_commands (Transport , S , C0 ),
693
- ? assertMatch ({publish_confirm , PublisherId , [1 ]}, Cmd ),
750
+ ? assertMatch ({ExpectedConfirmCommand , PublisherId , [1 ]}, Cmd ),
694
751
C ;
695
- test_publish_confirm (Transport , S , publish_v2 = PublishCmd , PublisherId , Body , C0 ) ->
752
+ test_publish_confirm (Transport , S , publish_v2 = PublishCmd , PublisherId , Body ,
753
+ ExpectedConfirmCommand , C0 ) ->
696
754
BodySize = byte_size (Body ),
697
755
FilterValue = <<" foo" >>,
698
756
FilterValueSize = byte_size (FilterValue ),
@@ -702,7 +760,12 @@ test_publish_confirm(Transport, S, publish_v2 = PublishCmd, PublisherId, Body, C
702
760
rabbit_stream_core :frame ({PublishCmd , PublisherId , 1 , Messages }),
703
761
ok = Transport :send (S , PublishFrame ),
704
762
{Cmd , C } = receive_commands (Transport , S , C0 ),
705
- ? assertMatch ({publish_confirm , PublisherId , [1 ]}, Cmd ),
763
+ case ExpectedConfirmCommand of
764
+ publish_confirm ->
765
+ ? assertMatch ({ExpectedConfirmCommand , PublisherId , [1 ]}, Cmd );
766
+ publish_error ->
767
+ ? assertMatch ({ExpectedConfirmCommand , PublisherId , _ , [1 ]}, Cmd )
768
+ end ,
706
769
C .
707
770
708
771
test_subscribe (Transport , S , SubscriptionId , Stream , C0 ) ->
@@ -711,21 +774,23 @@ test_subscribe(Transport, S, SubscriptionId, Stream, C0) ->
711
774
SubscriptionId ,
712
775
Stream ,
713
776
#{<<" random" >> => <<" thing" >>},
777
+ ? RESPONSE_CODE_OK ,
714
778
C0 ).
715
779
716
780
test_subscribe (Transport ,
717
781
S ,
718
782
SubscriptionId ,
719
783
Stream ,
720
784
SubscriptionProperties ,
785
+ ExpectedResponseCode ,
721
786
C0 ) ->
722
787
SubCmd =
723
788
{request , 1 ,
724
789
{subscribe , SubscriptionId , Stream , 0 , 10 , SubscriptionProperties }},
725
790
SubscribeFrame = rabbit_stream_core :frame (SubCmd ),
726
791
ok = Transport :send (S , SubscribeFrame ),
727
792
{Cmd , C } = receive_commands (Transport , S , C0 ),
728
- ? assertMatch ({response , 1 , {subscribe , ? RESPONSE_CODE_OK }}, Cmd ),
793
+ ? assertMatch ({response , 1 , {subscribe , ExpectedResponseCode }}, Cmd ),
729
794
C .
730
795
731
796
test_unsubscribe (Transport , Socket , SubscriptionId , C0 ) ->
0 commit comments