Skip to content

Commit 8eb4f27

Browse files
committed
cluster_SUITE: Expect a noproc exception when starting an invalid store
[Why] The store's supervisor might have already abandonned to restart the Ra server at the time we ask to trigger an election. This would raise a `noproc` exception.
1 parent 2de0b60 commit 8eb4f27

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

test/cluster_SUITE.erl

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -475,24 +475,35 @@ fail_to_start_with_bad_ra_server_config(Config) ->
475475
StoreId = RaSystem,
476476

477477
ct:pal("Start database"),
478-
?assertExit(
479-
{{{bad_action_from_state_function,
480-
{{timeout, tick}, not_a_timeout, tick_timeout}},
481-
_},
482-
_},
483-
khepri:start(RaSystem, #{cluster_name => StoreId,
484-
tick_timeout => not_a_timeout})),
478+
Ret1 = (catch khepri:start(RaSystem, #{cluster_name => StoreId,
479+
tick_timeout => not_a_timeout})),
480+
ct:pal("Return value of khepri:start/2: ~p", [Ret1]),
481+
?assert(
482+
case Ret1 of
483+
{'EXIT',
484+
{{{bad_action_from_state_function,
485+
{{timeout, tick}, not_a_timeout, tick_timeout}},
486+
_},
487+
_}} ->
488+
true;
489+
{'EXIT',
490+
{noproc, _}} ->
491+
true;
492+
_ ->
493+
ct:pal("Unexpected return value:~n~p", [Ret1]),
494+
false
495+
end),
485496

486497
ThisMember = khepri_cluster:this_member(StoreId),
487498
ok = khepri_cluster:wait_for_ra_server_exit(ThisMember),
488499

489500
%% The process is restarted by its supervisor. Depending on the timing, we
490501
%% may get a `noproc' or an exception.
491502
ct:pal("Database unusable after failing to start it"),
492-
Ret = (catch khepri:get(StoreId, [foo])),
493-
ct:pal("Return value of khepri:get/2: ~p", [Ret]),
503+
Ret2 = (catch khepri:get(StoreId, [foo])),
504+
ct:pal("Return value of khepri:get/2: ~p", [Ret2]),
494505
?assert(
495-
case Ret of
506+
case Ret2 of
496507
{'EXIT',
497508
{{{bad_action_from_state_function,
498509
{{timeout, tick}, not_a_timeout, tick_timeout}},
@@ -507,7 +518,7 @@ fail_to_start_with_bad_ra_server_config(Config) ->
507518
{error, noproc} ->
508519
true;
509520
_ ->
510-
ct:pal("Unexpected return value:~n~p", [Ret]),
521+
ct:pal("Unexpected return value:~n~p", [Ret2]),
511522
false
512523
end),
513524

0 commit comments

Comments
 (0)