Skip to content

Commit c7e2261

Browse files
committed
test: Fix flakiness when waiting for tables
1 parent fef1d76 commit c7e2261

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

src/mria_app.erl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
-export([start/2, stop/1]).
2222

23+
-export([ready/0]).
24+
2325
%% Classy hooks
2426
-export([ on_run_level/2
2527
, on_node_init/0
@@ -37,6 +39,8 @@
3739
-include_lib("snabbkaffe/include/trace.hrl").
3840
-include("mria.hrl").
3941

42+
-define(optvar_ready, mria_app_ready).
43+
4044
%%================================================================================
4145
%% Application callbacks
4246
%%================================================================================
@@ -58,6 +62,14 @@ stop(_) ->
5862
mria_config:erase_all_config(),
5963
ok.
6064

65+
%%================================================================================
66+
%% Misc API
67+
%%================================================================================
68+
69+
-spec ready() -> boolean().
70+
ready() ->
71+
optvar:is_set(?optvar_ready).
72+
6173
%%================================================================================
6274
%% Classy hooks
6375
%%================================================================================
@@ -70,8 +82,10 @@ on_node_init() ->
7082

7183
on_run_level(stopped, single) ->
7284
{ok, _Apps} = application:ensure_all_started(mria),
85+
optvar:set(?optvar_ready, true),
7386
ok;
7487
on_run_level(single, stopped) ->
88+
optvar:unset(?optvar_ready),
7589
mria:stop();
7690
on_run_level(_, _) ->
7791
ok.

test/mria_join_fixture.erl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ init_per_node(Site, _Node, JoinTo, Acc) ->
1313
case is_peer(JoinTo, Site) of
1414
false ->
1515
?assertEqual(ok, familiar:call(Site, classy, join_node, [JoinTo, join])),
16-
?retry(100, 10, ?assertEqual(true, is_peer(JoinTo, Site)));
16+
?retry(100, 1000, ?assert(is_peer(JoinTo, Site))),
17+
?retry(100, 1000, ?assert(familiar:call(Site, mria_app, ready, [])));
1718
true ->
1819
ok
1920
end,

0 commit comments

Comments
 (0)