Merge pull request #4524 from rabbitmq/speed-up-reimport-definitions
Speed up reimport queue definitions
This commit is contained in:
commit
6710b34ad9
|
|
@ -683,12 +683,17 @@ add_queue_int(_Queue, R = #resource{kind = queue,
|
|||
rabbit_log:warning("Skipping import of a queue whose name begins with 'amq.', "
|
||||
"name: ~s, acting user: ~s", [Name, ActingUser]);
|
||||
add_queue_int(Queue, Name, ActingUser) ->
|
||||
rabbit_amqqueue:declare(Name,
|
||||
maps:get(durable, Queue, undefined),
|
||||
maps:get(auto_delete, Queue, undefined),
|
||||
args(maps:get(arguments, Queue, undefined)),
|
||||
none,
|
||||
ActingUser).
|
||||
case rabbit_amqqueue:lookup(Name) of
|
||||
{ok, _} ->
|
||||
ok;
|
||||
{error, not_found} ->
|
||||
rabbit_amqqueue:declare(Name,
|
||||
maps:get(durable, Queue, undefined),
|
||||
maps:get(auto_delete, Queue, undefined),
|
||||
args(maps:get(arguments, Queue, undefined)),
|
||||
none,
|
||||
ActingUser)
|
||||
end.
|
||||
|
||||
add_exchange(Exchange, ActingUser) ->
|
||||
add_exchange_int(Exchange, r(exchange, Exchange), ActingUser).
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ groups() ->
|
|||
import_case11,
|
||||
import_case12,
|
||||
import_case13,
|
||||
import_case13a,
|
||||
import_case14,
|
||||
import_case15,
|
||||
import_case16,
|
||||
|
|
@ -230,6 +231,31 @@ import_case13(Config) ->
|
|||
Skip
|
||||
end.
|
||||
|
||||
import_case13a(Config) ->
|
||||
case rabbit_ct_broker_helpers:enable_feature_flag(Config, quorum_queue) of
|
||||
ok ->
|
||||
import_file_case(Config, "case13"),
|
||||
VHost = <<"/">>,
|
||||
QueueName = <<"definitions.import.case13.qq.1">>,
|
||||
QueueIsImported =
|
||||
fun () ->
|
||||
case queue_lookup(Config, VHost, QueueName) of
|
||||
{ok, _} -> true;
|
||||
_ -> false
|
||||
end
|
||||
end,
|
||||
rabbit_ct_helpers:await_condition(QueueIsImported, 20000),
|
||||
{ok, Q} = queue_lookup(Config, VHost, QueueName),
|
||||
|
||||
%% We expect that importing an existing queue (i.e. same vhost and name)
|
||||
%% but with different arguments and different properties is a no-op.
|
||||
import_file_case(Config, "case13a"),
|
||||
timer:sleep(1000),
|
||||
?assertMatch({ok, Q}, queue_lookup(Config, VHost, QueueName));
|
||||
Skip ->
|
||||
Skip
|
||||
end.
|
||||
|
||||
import_case14(Config) -> import_file_case(Config, "case14").
|
||||
%% contains a user with tags as a list
|
||||
import_case15(Config) -> import_file_case(Config, "case15").
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
"bindings": [],
|
||||
"exchanges": [],
|
||||
"global_parameters": [
|
||||
{
|
||||
"name": "cluster_name",
|
||||
"value": "rabbit@localhost"
|
||||
}
|
||||
],
|
||||
"parameters": [],
|
||||
"permissions": [
|
||||
{
|
||||
"configure": ".*",
|
||||
"read": ".*",
|
||||
"user": "guest",
|
||||
"vhost": "/",
|
||||
"write": ".*"
|
||||
}
|
||||
],
|
||||
"policies": [],
|
||||
"queues": [
|
||||
{
|
||||
"arguments": {
|
||||
"x-max-length": 7,
|
||||
"x-queue-type": "stream"
|
||||
},
|
||||
"auto_delete": true,
|
||||
"durable": false,
|
||||
"name": "definitions.import.case13.qq.1",
|
||||
"type": "stream",
|
||||
"vhost": "/"
|
||||
}
|
||||
],
|
||||
"rabbit_version": "3.8.6.gad0c0bd",
|
||||
"rabbitmq_version": "3.8.6.gad0c0bd",
|
||||
"topic_permissions": [],
|
||||
"users": [
|
||||
{
|
||||
"hashing_algorithm": "rabbit_password_hashing_sha256",
|
||||
"name": "guest",
|
||||
"password_hash": "e8lL5PHYcbv3Pd53EUoTOMnVDmsLDgVJXqSQMT+mrO4LVIdW",
|
||||
"tags": "administrator"
|
||||
}
|
||||
],
|
||||
"vhosts": [
|
||||
{
|
||||
"limits": [],
|
||||
"metadata": {
|
||||
"description": "Default virtual host",
|
||||
"tags": []
|
||||
},
|
||||
"name": "/"
|
||||
}
|
||||
]
|
||||
}
|
||||
Loading…
Reference in New Issue