Skip to content

Commit 6a02122

Browse files
Merge pull request #11532 from rabbitmq/mergify/bp/v3.13.x/pr-11528
Follow-up to #11457 (backport #11528)
2 parents b1af26b + eeca81e commit 6a02122

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

deps/rabbit/src/rabbit_amqqueue.erl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,8 @@ check_queue_type(Val, _Args) when is_binary(Val) ->
11211121
true -> ok;
11221122
false -> {error, rabbit_misc:format("unsupported queue type '~ts'", [Val])}
11231123
end;
1124+
check_queue_type(Val, Args) when is_atom(Val) ->
1125+
check_queue_type(rabbit_data_coercion:to_binary(Val), Args);
11241126
check_queue_type(_Val, _Args) ->
11251127
{error, invalid_queue_type}.
11261128

deps/rabbit/src/rabbit_queue_type.erl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ discover(<<"classic">>) ->
246246
rabbit_classic_queue;
247247
discover(<<"stream">>) ->
248248
rabbit_stream_queue;
249+
discover(Other) when is_atom(Other) ->
250+
discover(rabbit_data_coercion:to_binary(Other));
249251
discover(Other) when is_binary(Other) ->
250252
T = rabbit_registry:binary_to_type(Other),
251253
{ok, Mod} = rabbit_registry:lookup_module(queue, T),

deps/rabbit/src/rabbit_vhost.erl

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ do_add(Name, Metadata, ActingUser) ->
171171
case Metadata of
172172
#{default_queue_type := DQT} ->
173173
%% check that the queue type is known
174+
rabbit_log:debug("Default queue type of virtual host '~ts' is ~tp", [Name, DQT]),
174175
try rabbit_queue_type:discover(DQT) of
175176
_ ->
176177
case rabbit_queue_type:feature_flag_name(DQT) of
@@ -182,7 +183,7 @@ do_add(Name, Metadata, ActingUser) ->
182183
end
183184
end
184185
catch _:_ ->
185-
throw({error, invalid_queue_type})
186+
throw({error, invalid_queue_type, DQT})
186187
end;
187188
_ ->
188189
ok
@@ -315,20 +316,16 @@ put_vhost(Name, Description, Tags0, Trace, Username) ->
315316
boolean(),
316317
rabbit_types:username()) ->
317318
'ok' | {'error', any()} | {'EXIT', any()}.
318-
put_vhost(Name, Description, Tags0, DefaultQueueType0, Trace, Username) ->
319+
put_vhost(Name, Description, Tags0, DefaultQueueType, Trace, Username) ->
319320
Tags = case Tags0 of
320321
undefined -> <<"">>;
321322
null -> <<"">>;
322323
"undefined" -> <<"">>;
323324
"null" -> <<"">>;
324325
Other -> Other
325326
end,
326-
DefaultQueueType = case DefaultQueueType0 of
327-
<<"undefined">> -> undefined;
328-
_ -> DefaultQueueType0
329-
end,
330327
ParsedTags = parse_tags(Tags),
331-
rabbit_log:debug("Parsed tags ~tp to ~tp", [Tags, ParsedTags]),
328+
rabbit_log:debug("Parsed virtual host tags ~tp to ~tp", [Tags, ParsedTags]),
332329
Result = case exists(Name) of
333330
true ->
334331
update(Name, Description, ParsedTags, DefaultQueueType, Username);

deps/rabbit/test/definition_import_SUITE.erl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,9 @@ import_case11(Config) -> import_file_case(Config, "case11").
211211
import_case12(Config) -> import_invalid_file_case(Config, "failing_case12").
212212

213213
import_case13(Config) ->
214-
import_file_case(Config, "case13"),
215214
VHost = <<"/">>,
215+
delete_vhost(Config, VHost),
216+
import_file_case(Config, "case13"),
216217
QueueName = <<"definitions.import.case13.qq.1">>,
217218
QueueIsImported =
218219
fun () ->
@@ -231,8 +232,9 @@ import_case13(Config) ->
231232
amqqueue:get_arguments(Q)).
232233

233234
import_case13a(Config) ->
234-
import_file_case(Config, "case13"),
235235
VHost = <<"/">>,
236+
delete_vhost(Config, VHost),
237+
import_file_case(Config, "case13"),
236238
QueueName = <<"definitions.import.case13.qq.1">>,
237239
QueueIsImported =
238240
fun () ->
@@ -254,8 +256,9 @@ import_case14(Config) -> import_file_case(Config, "case14").
254256
import_case15(Config) -> import_file_case(Config, "case15").
255257
%% contains a virtual host with tags
256258
import_case16(Config) ->
257-
import_file_case(Config, "case16"),
258259
VHost = <<"tagged">>,
260+
delete_vhost(Config, VHost),
261+
import_file_case(Config, "case16"),
259262
VHostIsImported =
260263
fun () ->
261264
case vhost_lookup(Config, VHost) of
@@ -516,3 +519,6 @@ vhost_lookup(Config, VHost) ->
516519

517520
user_lookup(Config, User) ->
518521
rabbit_ct_broker_helpers:rpc(Config, 0, rabbit_auth_backend_internal, lookup_user, [User]).
522+
523+
delete_vhost(Config, VHost) ->
524+
rabbit_ct_broker_helpers:rpc(Config, 0, rabbit_vhost, delete, [VHost, <<"CT tests">>]).

0 commit comments

Comments
 (0)