Browse Source

Increase timeout for gproc_dist:sync()
In rare instances (esp. on Travis), gproc_dist:sync() can take longer
than 5 seconds. This is possibly related to the 5-second 'TAU' in
the gen_leader implementation. Allow for 10 seconds at least, and make
sure the EUnit test case will wait at least that long.

Ulf Wiger 7 years ago
parent
commit
65398be497
2 changed files with 9 additions and 2 deletions
  1. 8 1
      src/gproc_dist.erl
  2. 1 1
      test/gproc_dist_tests.erl

+ 8 - 1
src/gproc_dist.erl

@@ -265,7 +265,8 @@ reset_counter(_) ->
 %% @end
 %% @end
 %%
 %%
 sync() ->
 sync() ->
-    leader_call(sync).
+    %% Increase timeout since gen_leader can take some time ...
+    leader_call(sync, 10000).
 
 
 %% @spec get_leader() -> node()
 %% @spec get_leader() -> node()
 %% @doc Returns the node of the current gproc leader.
 %% @doc Returns the node of the current gproc leader.
@@ -910,6 +911,12 @@ leader_call(Req) ->
         Reply  -> Reply
         Reply  -> Reply
     end.
     end.
 
 
+leader_call(Req, Timeout) ->
+    case gen_leader:leader_call(?MODULE, Req, Timeout) of
+        badarg -> ?THROW_GPROC_ERROR(badarg);
+        Reply  -> Reply
+    end.
+
 leader_cast(Msg) ->
 leader_cast(Msg) ->
     gen_leader:leader_cast(?MODULE, Msg).
     gen_leader:leader_cast(?MODULE, Msg).
 
 

+ 1 - 1
test/gproc_dist_tests.erl

@@ -49,7 +49,7 @@ dist_test_() ->
                 tests(Ns, [?f(t_fail_node(Ns))])
                 tests(Ns, [?f(t_fail_node(Ns))])
         end,
         end,
         fun(Ns) ->
         fun(Ns) ->
-                tests(Ns, [{timeout, 10, ?f(t_master_dies(Ns))}])
+                tests(Ns, [{timeout, 15, ?f(t_master_dies(Ns))}])
         end
         end
        ]}
        ]}
      ]}.
      ]}.