From 697fb7f5b02a9c55871e5d0750b08ab230d89fab Mon Sep 17 00:00:00 2001 From: Lois Soto Lopez Date: Tue, 1 Oct 2024 09:07:55 +0200 Subject: [PATCH] Use local function for ensuring qq proc dead --- deps/rabbit/test/quorum_queue_SUITE.erl | 44 ++++++++----------------- 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/deps/rabbit/test/quorum_queue_SUITE.erl b/deps/rabbit/test/quorum_queue_SUITE.erl index e195594ecca4..937e8224d34d 100644 --- a/deps/rabbit/test/quorum_queue_SUITE.erl +++ b/deps/rabbit/test/quorum_queue_SUITE.erl @@ -1247,36 +1247,8 @@ policy_repair(Config) -> ?assert((GottenFails4 =:= 10) or (GottenFails4 =:= 9)), consume_all(Ch, QQ), - % Make the queue process unavailable. - % Kill the process multiple times until its supervisor stops restarting it. - lists:foreach(fun(Srv) -> - KillUntil = fun KillUntil() -> - case - rabbit_ct_broker_helpers:rpc( - Config, - Srv, - erlang, - whereis, - [RaName]) - of - undefined -> - ok; - Pid -> - rabbit_ct_broker_helpers:rpc( - Config, - Srv, - erlang, - exit, - [Pid, kill] - ), - % Give some time for the supervisor to restart the process - timer:sleep(500), - KillUntil() - end - end, - KillUntil() - end, - Servers), + % Ensure the queue process is unavailable + lists:foreach(fun(Srv) -> ensure_qq_proc_dead(Config, Srv, RaName) end, Servers), % Add policy with higher priority, allowing even more messages. ExpectedMaxLength3 = 30, @@ -4380,3 +4352,15 @@ consume_all(Ch, QQ) -> end end, Consume([]). + +ensure_qq_proc_dead(Config, Server, RaName) -> + case rabbit_ct_broker_helpers:rpc(Config, Server, erlang, whereis, [RaName]) of + undefined -> + ok; + Pid -> + rabbit_ct_broker_helpers:rpc(Config, Server, erlang, exit, [Pid, kill]), + %% Give some time for the supervisor to restart the process + timer:sleep(500), + ensure_qq_proc_dead(Config, Server, RaName) + end. +