1717all () ->
1818 [
1919 inject_dqt_undefined_binary ,
20- inject_dqt_preserves_existing_metadata
20+ inject_dqt_null ,
21+ inject_dqt_nil ,
22+ inject_dqt_preserves_existing_metadata ,
23+ new_metadata_sanitizes_undefined_binary ,
24+ new_metadata_sanitizes_null ,
25+ new_metadata_sanitizes_nil ,
26+ vhost_import_with_undefined_dqt ,
27+ vhost_import_with_null_dqt ,
28+ vhost_import_with_nil_dqt ,
29+ update_metadata_sanitizes_undefined_binary ,
30+ update_metadata_sanitizes_null ,
31+ update_metadata_sanitizes_nil
2132 ].
2233
2334% % -------------------------------------------------------------------
@@ -31,20 +42,6 @@ init_per_suite(Config) ->
3142end_per_suite (Config ) ->
3243 rabbit_ct_helpers :run_teardown_steps (Config ).
3344
34- init_per_group (Group , Config ) ->
35- Config1 = rabbit_ct_helpers :set_config (Config , [
36- {rmq_nodename_suffix , Group },
37- {rmq_nodes_count , 1 }
38- ]),
39- rabbit_ct_helpers :run_steps (Config1 ,
40- rabbit_ct_broker_helpers :setup_steps () ++
41- rabbit_ct_client_helpers :setup_steps ()).
42-
43- end_per_group (_Group , Config ) ->
44- rabbit_ct_helpers :run_steps (Config ,
45- rabbit_ct_client_helpers :teardown_steps () ++
46- rabbit_ct_broker_helpers :teardown_steps ()).
47-
4845init_per_testcase (Testcase , Config ) ->
4946 Config1 = rabbit_ct_helpers :set_config (Config , [
5047 {rmq_nodename_suffix , Testcase },
@@ -65,8 +62,6 @@ end_per_testcase(Testcase, Config) ->
6562% % Test Cases
6663% % -------------------------------------------------------------------
6764
68- % % When default_queue_type is the binary <<"undefined">> (exported from an older versions),
69- % % inject the default. See rabbitmq/rabbitmq-server#10469
7065inject_dqt_undefined_binary (Config ) ->
7166 Expected = rpc (Config , 0 , rabbit_queue_type , default_alias , []),
7267 Input = #{default_queue_type => <<" undefined" >>, name => <<" /" >>},
@@ -75,7 +70,22 @@ inject_dqt_undefined_binary(Config) ->
7570 rpc (Config , 0 , rabbit_queue_type , inject_dqt , [Input ]),
7671 ok .
7772
78- % % Existing metadata keys should be preserved when injecting DQT
73+ inject_dqt_null (Config ) ->
74+ Expected = rpc (Config , 0 , rabbit_queue_type , default_alias , []),
75+ Input = #{default_queue_type => null , name => <<" /" >>},
76+ #{default_queue_type := Expected ,
77+ metadata := #{default_queue_type := Expected }} =
78+ rpc (Config , 0 , rabbit_queue_type , inject_dqt , [Input ]),
79+ ok .
80+
81+ inject_dqt_nil (Config ) ->
82+ Expected = rpc (Config , 0 , rabbit_queue_type , default_alias , []),
83+ Input = #{default_queue_type => nil , name => <<" /" >>},
84+ #{default_queue_type := Expected ,
85+ metadata := #{default_queue_type := Expected }} =
86+ rpc (Config , 0 , rabbit_queue_type , inject_dqt , [Input ]),
87+ ok .
88+
7989inject_dqt_preserves_existing_metadata (Config ) ->
8090 Expected = rpc (Config , 0 , rabbit_queue_type , default_alias , []),
8191 Input = #{
@@ -91,3 +101,122 @@ inject_dqt_preserves_existing_metadata(Config) ->
91101 tags := [replicate ]}} =
92102 rpc (Config , 0 , rabbit_queue_type , inject_dqt , [Input ]),
93103 ok .
104+
105+ new_metadata_sanitizes_undefined_binary (Config ) ->
106+ Expected = rpc (Config , 0 , rabbit_queue_type , default_alias , []),
107+ #{default_queue_type := Expected } =
108+ rpc (Config , 0 , vhost , new_metadata , [<<" description" >>, [], <<" undefined" >>]),
109+ #{default_queue_type := Expected } =
110+ rpc (Config , 0 , vhost , new_metadata , [<<" description" >>, [], undefined ]),
111+ #{default_queue_type := <<" quorum" >>} =
112+ rpc (Config , 0 , vhost , new_metadata , [<<" description" >>, [], <<" quorum" >>]),
113+ ok .
114+
115+ new_metadata_sanitizes_null (Config ) ->
116+ Expected = rpc (Config , 0 , rabbit_queue_type , default_alias , []),
117+ #{default_queue_type := Expected } =
118+ rpc (Config , 0 , vhost , new_metadata , [<<" description" >>, [], null ]),
119+ ok .
120+
121+ new_metadata_sanitizes_nil (Config ) ->
122+ Expected = rpc (Config , 0 , rabbit_queue_type , default_alias , []),
123+ #{default_queue_type := Expected } =
124+ rpc (Config , 0 , vhost , new_metadata , [<<" description" >>, [], nil ]),
125+ ok .
126+
127+ vhost_import_with_undefined_dqt (Config ) ->
128+ VHost = <<" import-undefined-dqt-test" >>,
129+ Expected = rpc (Config , 0 , rabbit_queue_type , default_alias , []),
130+ try
131+ ok = rpc (Config , 0 , rabbit_vhost , put_vhost ,
132+ [VHost , <<" test description" >>, [], <<" undefined" >>, false , <<" test-user" >>]),
133+ V = rpc (Config , 0 , rabbit_vhost , lookup , [VHost ]),
134+ Metadata = rpc (Config , 0 , vhost , get_metadata , [V ]),
135+ #{default_queue_type := StoredDQT } = Metadata ,
136+ Expected = StoredDQT
137+ after
138+ rpc (Config , 0 , rabbit_vhost , delete , [VHost , <<" test-user" >>])
139+ end ,
140+ ok .
141+
142+ vhost_import_with_null_dqt (Config ) ->
143+ VHost = <<" import-null-dqt-test" >>,
144+ Expected = rpc (Config , 0 , rabbit_queue_type , default_alias , []),
145+ try
146+ ok = rpc (Config , 0 , rabbit_vhost , put_vhost ,
147+ [VHost , <<" test description" >>, [], null , false , <<" test-user" >>]),
148+ V = rpc (Config , 0 , rabbit_vhost , lookup , [VHost ]),
149+ Metadata = rpc (Config , 0 , vhost , get_metadata , [V ]),
150+ #{default_queue_type := StoredDQT } = Metadata ,
151+ Expected = StoredDQT
152+ after
153+ rpc (Config , 0 , rabbit_vhost , delete , [VHost , <<" test-user" >>])
154+ end ,
155+ ok .
156+
157+ vhost_import_with_nil_dqt (Config ) ->
158+ VHost = <<" import-nil-dqt-test" >>,
159+ Expected = rpc (Config , 0 , rabbit_queue_type , default_alias , []),
160+ try
161+ ok = rpc (Config , 0 , rabbit_vhost , put_vhost ,
162+ [VHost , <<" test description" >>, [], nil , false , <<" test-user" >>]),
163+ V = rpc (Config , 0 , rabbit_vhost , lookup , [VHost ]),
164+ Metadata = rpc (Config , 0 , vhost , get_metadata , [V ]),
165+ #{default_queue_type := StoredDQT } = Metadata ,
166+ Expected = StoredDQT
167+ after
168+ rpc (Config , 0 , rabbit_vhost , delete , [VHost , <<" test-user" >>])
169+ end ,
170+ ok .
171+
172+ update_metadata_sanitizes_undefined_binary (Config ) ->
173+ VHost = <<" update-metadata-undefined-dqt-test" >>,
174+ try
175+ ok = rpc (Config , 0 , rabbit_vhost , put_vhost ,
176+ [VHost , <<" test" >>, [], <<" classic" >>, false , <<" test-user" >>]),
177+ V1 = rpc (Config , 0 , rabbit_vhost , lookup , [VHost ]),
178+ #{default_queue_type := <<" classic" >>} = rpc (Config , 0 , vhost , get_metadata , [V1 ]),
179+ % % update_metadata should not overwrite with <<"undefined">>
180+ ok = rpc (Config , 0 , rabbit_vhost , update_metadata ,
181+ [VHost , #{default_queue_type => <<" undefined" >>}, <<" test-user" >>]),
182+ V2 = rpc (Config , 0 , rabbit_vhost , lookup , [VHost ]),
183+ #{default_queue_type := StoredDQT } = rpc (Config , 0 , vhost , get_metadata , [V2 ]),
184+ <<" classic" >> = StoredDQT
185+ after
186+ rpc (Config , 0 , rabbit_vhost , delete , [VHost , <<" test-user" >>])
187+ end ,
188+ ok .
189+
190+ update_metadata_sanitizes_null (Config ) ->
191+ VHost = <<" update-metadata-null-dqt-test" >>,
192+ try
193+ ok = rpc (Config , 0 , rabbit_vhost , put_vhost ,
194+ [VHost , <<" test" >>, [], <<" classic" >>, false , <<" test-user" >>]),
195+ V1 = rpc (Config , 0 , rabbit_vhost , lookup , [VHost ]),
196+ #{default_queue_type := <<" classic" >>} = rpc (Config , 0 , vhost , get_metadata , [V1 ]),
197+ ok = rpc (Config , 0 , rabbit_vhost , update_metadata ,
198+ [VHost , #{default_queue_type => null }, <<" test-user" >>]),
199+ V2 = rpc (Config , 0 , rabbit_vhost , lookup , [VHost ]),
200+ #{default_queue_type := StoredDQT } = rpc (Config , 0 , vhost , get_metadata , [V2 ]),
201+ <<" classic" >> = StoredDQT
202+ after
203+ rpc (Config , 0 , rabbit_vhost , delete , [VHost , <<" test-user" >>])
204+ end ,
205+ ok .
206+
207+ update_metadata_sanitizes_nil (Config ) ->
208+ VHost = <<" update-metadata-nil-dqt-test" >>,
209+ try
210+ ok = rpc (Config , 0 , rabbit_vhost , put_vhost ,
211+ [VHost , <<" test" >>, [], <<" classic" >>, false , <<" test-user" >>]),
212+ V1 = rpc (Config , 0 , rabbit_vhost , lookup , [VHost ]),
213+ #{default_queue_type := <<" classic" >>} = rpc (Config , 0 , vhost , get_metadata , [V1 ]),
214+ ok = rpc (Config , 0 , rabbit_vhost , update_metadata ,
215+ [VHost , #{default_queue_type => nil }, <<" test-user" >>]),
216+ V2 = rpc (Config , 0 , rabbit_vhost , lookup , [VHost ]),
217+ #{default_queue_type := StoredDQT } = rpc (Config , 0 , vhost , get_metadata , [V2 ]),
218+ <<" classic" >> = StoredDQT
219+ after
220+ rpc (Config , 0 , rabbit_vhost , delete , [VHost , <<" test-user" >>])
221+ end ,
222+ ok .
0 commit comments