rabbit_ct_broker_helpers: Stop node if start-background-broker failed

If the `start-background-broker` recipe fails, it is possible that the
node was started but the follow-up wait/status failed.

To not let a, unused node around, we try to stop it in case of a failure
and ignore the result of that stop recipe.

This situation happened in CI where Elixir seems to crash (one of the
two CLI commands we run after starting the node):

    Logger - error: {removed_failing_handler,'Elixir.Logger'}
    Logger - error: {removed_failing_handler,'Elixir.Logger'}
    Logger - error: {removed_failing_handler,'Elixir.Logger'}
    escript: exception error: undefined function 'Elixir.Exception':blame/3
      in function  'Elixir.Kernel.CLI':format_error/3 (lib/kernel/cli.ex, line 82)
      in call from 'Elixir.Kernel.CLI':print_error/3 (lib/kernel/cli.ex, line 173)
      in call from 'Elixir.Kernel.CLI':exec_fun/2 (lib/kernel/cli.ex, line 150)
      in call from 'Elixir.Kernel.CLI':run/1 (lib/kernel/cli.ex, line 47)
      in call from escript:run/2 (escript.erl, line 758)
      in call from escript:start/1 (escript.erl, line 277)
      in call from init:start_em/1
    .../rabbit_common/mk/rabbitmq-run.mk:323: recipe for target 'start-background-broker' failed

In this case, rabbit_ct_broker_helpers tried again to start the node and
it worked. But it affected an unrelated testcase later because it tried
to use a TCP port already used by that left-over node.
This commit is contained in:
Jean-Sébastien Pédron 2020-03-25 11:14:56 +01:00
parent f1d31c9620
commit b3caf2daff
1 changed files with 8 additions and 3 deletions

View File

@ -680,7 +680,7 @@ do_start_rabbitmq_node(Config, NodeConfig, I) ->
false ->
ExtraArgs3
end,
Cmd = ["start-background-broker",
MakeVars = [
{"RABBITMQ_NODENAME=~s", [Nodename]},
{"RABBITMQ_NODENAME_FOR_PATHS=~s", [InitialNodename]},
{"RABBITMQ_DIST_PORT=~b", [DistPort]},
@ -692,9 +692,14 @@ do_start_rabbitmq_node(Config, NodeConfig, I) ->
{"TEST_TMPDIR=~s", [PrivDir]},
"NOBUILD=1"
| ExtraArgs],
Cmd = ["start-background-broker" | MakeVars],
case rabbit_ct_helpers:make(Config, SrcDir, Cmd) of
{ok, _} -> query_node(Config, NodeConfig);
_ -> {skip, "Failed to initialize RabbitMQ"}
{ok, _} ->
query_node(Config, NodeConfig);
_ ->
AbortCmd = ["stop-node" | MakeVars],
_ = rabbit_ct_helpers:make(Config, SrcDir, AbortCmd),
{skip, "Failed to initialize RabbitMQ"}
end.
query_node(Config, NodeConfig) ->