From 22494c65f5da5b06816c637141c40b14e829cb11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Fri, 28 Feb 2014 15:28:10 +0100 Subject: Attempt to provide more information if a test case fails --- lib/tools/test/cover_SUITE.erl | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'lib/tools') diff --git a/lib/tools/test/cover_SUITE.erl b/lib/tools/test/cover_SUITE.erl index ec61c57cec..0b98f52e6e 100644 --- a/lib/tools/test/cover_SUITE.erl +++ b/lib/tools/test/cover_SUITE.erl @@ -520,9 +520,9 @@ reconnect(Config) -> rpc:cast(N1,f,call_f2_when_isolated,[]), %% Disconnect and check that node is removed from main cover node - net_kernel:disconnect(N1), + true = net_kernel:disconnect(N1), timer:sleep(500), % allow some to detect disconnect and for f:f2() call - [] = cover:which_nodes(), + cover_which_nodes([]), %% Do some add one module (b) and remove one module (a) code:purge(a), @@ -530,7 +530,7 @@ reconnect(Config) -> {ok,b} = cover:compile(b), cover_compiled = code:which(b), - [] = cover:which_nodes(), + cover_which_nodes([]), check_f_calls(1,0), % only the first call - before the flush %% Reconnect the node and check that b and f are cover compiled but not a @@ -573,7 +573,7 @@ die_and_reconnect(Config) -> %% Kill the node rpc:call(N1,erlang,halt,[]), - [] = cover:which_nodes(), + cover_which_nodes([]), check_f_calls(1,0), % only the first call - before the flush @@ -614,7 +614,7 @@ dont_reconnect_after_stop(Config) -> %% Stop cover on the node, then terminate the node cover:stop(N1), rpc:call(N1,erlang,halt,[]), - [] = cover:which_nodes(), + cover_which_nodes([]), check_f_calls(1,0), @@ -622,7 +622,7 @@ dont_reconnect_after_stop(Config) -> {ok,N1} = ?t:start_node(NodeName,peer, [{args," -pa " ++ DataDir},{start_cover,false}]), timer:sleep(300), - [] = cover:which_nodes(), + cover_which_nodes([]), Beam = rpc:call(N1,code,which,[f]), false = (Beam==cover_compiled), @@ -667,7 +667,7 @@ stop_node_after_disconnect(Config) -> {ok,N1} = ?t:start_node(NodeName,peer, [{args," -pa " ++ DataDir},{start_cover,false}]), timer:sleep(300), - [] = cover:which_nodes(), + cover_which_nodes([]), Beam = rpc:call(N1,code,which,[f]), false = (Beam==cover_compiled), @@ -1575,3 +1575,21 @@ is_unloaded(What) -> check_f_calls(F1,F2) -> {ok,[{{f,f1,0},F1},{{f,f2,0},F2}|_]} = cover:analyse(f,calls,function). + +cover_which_nodes(Expected) -> + case cover:which_nodes() of + Expected -> + ok; + Other -> + {Time,ok} = timer:tc(fun Retry() -> + case cover:which_nodes() of + Expected -> ok; + _ -> + ?t:sleep(100), + Retry() + end + end), + io:format("~p ms before cover:which_nodes() returned ~p", + [Time,Expected]), + Expected = Other + end. -- cgit v1.2.3 From 651d8b9ab88b4bad73d37f3696b8d3cf0970a80d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Tue, 4 Mar 2014 12:20:57 +0100 Subject: cover_SUITE:reconnect/1: Let the other side initiate the disconnect The reconnect/1 test starts another node and takes down the connection to it for a while. However, it has been in observed in our daily builds that sometimes a "spontaneous" re-connection occurs. I think that it because of the call to rpc:cast/3 which internally will set the group leader for the remote process to a process on the test_server node. It seems that sometimes the group_leader/2 call will re-establish the connection. Unfortunately, I have not been able to force this to happen by inserting delays in the rpc module, so it it still just an hypothesis. However, letting the other node do the disconnection does seem to fix the problem and intuitively that should be safer way to do it because the group_leader/2 call and the disconnection will be executed sequentially on the same node instead of concurrently from two different nodes. --- lib/tools/test/cover_SUITE.erl | 6 ++---- lib/tools/test/cover_SUITE_data/f.erl | 7 ++++++- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'lib/tools') diff --git a/lib/tools/test/cover_SUITE.erl b/lib/tools/test/cover_SUITE.erl index 0b98f52e6e..80807b1d38 100644 --- a/lib/tools/test/cover_SUITE.erl +++ b/lib/tools/test/cover_SUITE.erl @@ -516,11 +516,9 @@ reconnect(Config) -> cover:flush(N1), rpc:call(N1,f,f1,[]), - %% This will cause a call to f:f2() when nodes()==[] on N1 + %% This will cause first casue the N1 node to initiate a + %% disconnect and then call f:f2() when nodes() =:= [] on N1. rpc:cast(N1,f,call_f2_when_isolated,[]), - - %% Disconnect and check that node is removed from main cover node - true = net_kernel:disconnect(N1), timer:sleep(500), % allow some to detect disconnect and for f:f2() call cover_which_nodes([]), diff --git a/lib/tools/test/cover_SUITE_data/f.erl b/lib/tools/test/cover_SUITE_data/f.erl index ce2963014a..a29a67b388 100644 --- a/lib/tools/test/cover_SUITE_data/f.erl +++ b/lib/tools/test/cover_SUITE_data/f.erl @@ -10,10 +10,15 @@ f2() -> f2_line2. call_f2_when_isolated() -> + [Other] = nodes(), + net_kernel:disconnect(Other), + do_call_f2_when_isolated(). + +do_call_f2_when_isolated() -> case nodes() of [] -> f2(); _ -> timer:sleep(100), - call_f2_when_isolated() + do_call_f2_when_isolated() end. -- cgit v1.2.3