backing_queue_SUITE:: Move `get_queue_sup_pid()` from rabbitmq-ct-helpers

This is the only place this function is used and this removes a
dependency cycle: rabbit_ct_broker_helpers can't depend on the broker:
the broker already depends on it as a test dependency.

[#159298729]
This commit is contained in:
Jean-Sébastien Pédron 2019-01-24 14:04:42 +01:00
parent d0fd11fff9
commit 3ec8ffffe7
No known key found for this signature in database
GPG Key ID: 39E99761A5FD94CC
1 changed files with 17 additions and 1 deletions

View File

@ -723,7 +723,7 @@ bq_queue_recover1(Config) ->
true, false, [], none, <<"acting-user">>),
publish_and_confirm(Q, <<>>, Count),
SupPid = rabbit_ct_broker_helpers:get_queue_sup_pid(Q),
SupPid = get_queue_sup_pid(Q),
true = is_pid(SupPid),
exit(SupPid, kill),
exit(QPid, kill),
@ -751,6 +751,22 @@ bq_queue_recover1(Config) ->
end),
passed.
%% Return the PID of the given queue's supervisor.
get_queue_sup_pid(#amqqueue { pid = QPid, name = QName }) ->
VHost = QName#resource.virtual_host,
{ok, AmqSup} = rabbit_amqqueue_sup_sup:find_for_vhost(VHost, node(QPid)),
Sups = supervisor:which_children(AmqSup),
get_queue_sup_pid(Sups, QPid).
get_queue_sup_pid([{_, SupPid, _, _} | Rest], QueuePid) ->
WorkerPids = [Pid || {_, Pid, _, _} <- supervisor:which_children(SupPid)],
case lists:member(QueuePid, WorkerPids) of
true -> SupPid;
false -> get_queue_sup_pid(Rest, QueuePid)
end;
get_queue_sup_pid([], _QueuePid) ->
undefined.
variable_queue_dynamic_duration_change(Config) ->
passed = rabbit_ct_broker_helpers:rpc(Config, 0,
?MODULE, variable_queue_dynamic_duration_change1, [Config]).