Skip to content

Commit

Permalink
db_info: Test that is_store_running/1 and get_store_ids/0 handle …
Browse files Browse the repository at this point in the history
…crashed Ra servers

[Why]
These functions didn't use to handle a Ra server that has stopped behing
the back of Khepri correctly. This is fixed by the two previous commits.
  • Loading branch information
dumbbell committed Jul 22, 2024
1 parent 64be616 commit f165e51
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/db_info.erl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,32 @@ get_store_ids_with_running_store_test_() ->
[?FUNCTION_NAME],
khepri:get_store_ids())]}.

get_store_ids_after_killing_ra_server_test_() ->
{setup,
fun() -> test_ra_server_helpers:setup(?FUNCTION_NAME) end,
fun(Priv) -> test_ra_server_helpers:cleanup(Priv) end,
[?_assertEqual(
[?FUNCTION_NAME],
khepri:get_store_ids()),
?_assertEqual(
true,
khepri_cluster:is_store_running(?FUNCTION_NAME)),

?_test(terminate_ra_server(?FUNCTION_NAME)),

?_assertEqual(
[],
khepri:get_store_ids()),
?_assertEqual(
false,
khepri_cluster:is_store_running(?FUNCTION_NAME))]}.

terminate_ra_server(ClusterName) ->
RaSystem = ClusterName,
Member = {ClusterName, node()},
ra:stop_server(RaSystem, Member),
khepri_cluster:wait_for_ra_server_exit(Member).

is_store_running_with_no_running_stores_test_() ->
[?_assertEqual(
false,
Expand Down

0 comments on commit f165e51

Please sign in to comment.