Skip to content

Commit b60775e

Browse files
author
Daniil Fedotov
committed
Start rabbit application as temporary in tests.
Some tests output can break when `rabbit` application failure stops the node. Make it possible to configure restart type.
1 parent 2545c1b commit b60775e

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/rabbit.erl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
is_running/1, environment/0, rotate_logs/1, force_event_refresh/1,
2424
start_fhc/0]).
2525
-export([start/2, stop/1]).
26-
-export([start_apps/1, stop_apps/1]).
26+
-export([start_apps/1, start_apps/2, stop_apps/1]).
2727
-export([log_location/1, config_files/0, decrypt_config/2]). %% for testing and mgmt-agent
2828

2929
%%---------------------------------------------------------------------------
@@ -217,6 +217,7 @@
217217
%%----------------------------------------------------------------------------
218218

219219
-type file_suffix() :: binary().
220+
-type restart_type() :: 'permanent' | 'transient' | 'temporary'.
220221
%% this really should be an abstract type
221222
-type log_location() :: 'tty' | 'undefined' | file:filename().
222223
-type param() :: atom().
@@ -253,6 +254,7 @@
253254
-spec boot_delegate() -> 'ok'.
254255
-spec recover() -> 'ok'.
255256
-spec start_apps([app_name()]) -> 'ok'.
257+
-spec start_apps([app_name()], [{app_name(), restart_type()}]) -> 'ok'.
256258
-spec stop_apps([app_name()]) -> 'ok'.
257259

258260
%%----------------------------------------------------------------------------
@@ -474,6 +476,9 @@ stop_and_halt() ->
474476
ok.
475477

476478
start_apps(Apps) ->
479+
start_apps(Apps, []).
480+
481+
start_apps(Apps, RestartTypes) ->
477482
app_utils:load_applications(Apps),
478483

479484
ConfigEntryDecoder = case application:get_env(rabbit, config_entry_decoder) of
@@ -513,7 +518,8 @@ start_apps(Apps) ->
513518
true -> ok %% will run during start of rabbit app
514519
end,
515520
ok = app_utils:start_applications(OrderedApps,
516-
handle_app_error(could_not_start)).
521+
handle_app_error(could_not_start),
522+
RestartTypes).
517523

518524
%% This function retrieves the correct IoDevice for requesting
519525
%% input. The problem with using the default IoDevice is that

test/unit_SUITE.erl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,11 @@ do_decrypt_start_app(Config, Passphrase) ->
332332
%%
333333
%% We expect a failure *after* the decrypting has been done.
334334
try
335-
rabbit:start_apps([rabbit_shovel_test])
335+
rabbit:start_apps([rabbit_shovel_test], [{rabbit, temporary}])
336336
catch _:_ ->
337337
ok
338-
end,
338+
end
339+
,
339340
%% Check if the values have been decrypted.
340341
{ok, Shovels} = application:get_env(rabbit_shovel_test, shovels),
341342
{_, FirstShovel} = lists:keyfind(my_first_shovel, 1, Shovels),
@@ -359,7 +360,7 @@ decrypt_start_app_undefined(Config) ->
359360
%%
360361
%% We expect a failure during decryption because the passphrase is missing.
361362
try
362-
rabbit:start_apps([rabbit_shovel_test])
363+
rabbit:start_apps([rabbit_shovel_test], [{rabbit, temporary}])
363364
catch
364365
exit:{bad_configuration, config_entry_decoder} -> ok;
365366
_:_ -> exit(unexpected_exception)
@@ -379,7 +380,7 @@ decrypt_start_app_wrong_passphrase(Config) ->
379380
%%
380381
%% We expect a failure during decryption because the passphrase is wrong.
381382
try
382-
rabbit:start_apps([rabbit_shovel_test])
383+
rabbit:start_apps([rabbit_shovel_test], [{rabbit, temporary}])
383384
catch
384385
exit:{decryption_error,_,_} -> ok;
385386
_:_ -> exit(unexpected_exception)

0 commit comments

Comments
 (0)