summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Radestock <matthias@rabbitmq.com>2012-08-11 09:58:09 +0100
committerMatthias Radestock <matthias@rabbitmq.com>2012-08-11 09:58:09 +0100
commitaf5fd4f44bed3d08afcceaeaa30afc720ea9fee1 (patch)
tree32d10f51abb335557ed7a20e7da7d2f47fd90c13
parent10cda2191282649534493f8dc8b80da65bdbf436 (diff)
downloadrabbitmq-server-bug25094.tar.gz
re-assess coverage suspension in testsbug25094
I took out all the coverage suspensions and then gradually added them back in until the tests passed. The end result is - reduced scope of coverage suspension in some cases - new instances of coverage suspension due to the changes in this bug - some useful helper functions for coverage suspension
-rw-r--r--src/rabbit_tests.erl58
1 files changed, 37 insertions, 21 deletions
diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl
index bb60bd12..e78b979f 100644
--- a/src/rabbit_tests.erl
+++ b/src/rabbit_tests.erl
@@ -74,12 +74,10 @@ maybe_run_cluster_dependent_tests() ->
run_cluster_dependent_tests(SecondaryNode) ->
SecondaryNodeS = atom_to_list(SecondaryNode),
- cover:stop(SecondaryNode),
ok = control_action(stop_app, []),
- ok = control_action(reset, []),
+ ok = safe_reset(),
ok = control_action(cluster, [SecondaryNodeS]),
ok = control_action(start_app, []),
- cover:start(SecondaryNode),
ok = control_action(start_app, SecondaryNode, [], []),
io:format("Running cluster dependent tests with node ~p~n", [SecondaryNode]),
@@ -940,7 +938,7 @@ test_cluster_management2(SecondaryNode) ->
ok = assert_ram_node(),
%% join cluster as a ram node
- ok = control_action(reset, []),
+ ok = safe_reset(),
ok = control_action(force_cluster, [SecondaryNodeS, "invalid1@invalid"]),
ok = control_action(start_app, []),
ok = control_action(stop_app, []),
@@ -997,29 +995,30 @@ test_cluster_management2(SecondaryNode) ->
ok = assert_disc_node(),
%% turn a disk node into a ram node
- ok = control_action(reset, []),
+ %%
+ %% can't use safe_reset here since for some reason nodes()==[] and
+ %% yet w/o stopping coverage things break
+ with_suspended_cover(
+ [SecondaryNode], fun () -> ok = control_action(reset, []) end),
ok = control_action(cluster, [SecondaryNodeS]),
ok = control_action(start_app, []),
ok = control_action(stop_app, []),
ok = assert_ram_node(),
%% NB: this will log an inconsistent_database error, which is harmless
- %% Turning cover on / off is OK even if we're not in general using cover,
- %% it just turns the engine on / off, doesn't actually log anything.
- cover:stop([SecondaryNode]),
- true = disconnect_node(SecondaryNode),
- pong = net_adm:ping(SecondaryNode),
- cover:start([SecondaryNode]),
+ with_suspended_cover(
+ [SecondaryNode], fun () ->
+ true = disconnect_node(SecondaryNode),
+ pong = net_adm:ping(SecondaryNode)
+ end),
%% leaving a cluster as a ram node
- ok = control_action(reset, []),
+ ok = safe_reset(),
%% ...and as a disk node
ok = control_action(cluster, [SecondaryNodeS, NodeS]),
ok = control_action(start_app, []),
ok = control_action(stop_app, []),
- cover:stop(SecondaryNode),
- ok = control_action(reset, []),
- cover:start(SecondaryNode),
+ ok = safe_reset(),
%% attempt to leave cluster when no other node is alive
ok = control_action(cluster, [SecondaryNodeS, NodeS]),
@@ -1034,22 +1033,39 @@ test_cluster_management2(SecondaryNode) ->
control_action(cluster, [SecondaryNodeS]),
%% leave system clustered, with the secondary node as a ram node
- ok = control_action(force_reset, []),
+ with_suspended_cover(
+ [SecondaryNode], fun () -> ok = control_action(force_reset, []) end),
ok = control_action(start_app, []),
%% Yes, this is rather ugly. But since we're a clustered Mnesia
%% node and we're telling another clustered node to reset itself,
%% we will get disconnected half way through causing a
%% badrpc. This never happens in real life since rabbitmqctl is
- %% not a clustered Mnesia node.
- cover:stop(SecondaryNode),
- {badrpc, nodedown} = control_action(force_reset, SecondaryNode, [], []),
- pong = net_adm:ping(SecondaryNode),
- cover:start(SecondaryNode),
+ %% not a clustered Mnesia node and is a hidden node.
+ with_suspended_cover(
+ [SecondaryNode],
+ fun () ->
+ {badrpc, nodedown} =
+ control_action(force_reset, SecondaryNode, [], []),
+ pong = net_adm:ping(SecondaryNode)
+ end),
ok = control_action(cluster, SecondaryNode, [NodeS], []),
ok = control_action(start_app, SecondaryNode, [], []),
passed.
+%% 'cover' does not cope at all well with nodes disconnecting, which
+%% happens as part of reset. So we turn it off temporarily. That is ok
+%% even if we're not in general using cover, it just turns the engine
+%% on / off and doesn't log anything.
+safe_reset() -> with_suspended_cover(
+ nodes(), fun () -> control_action(reset, []) end).
+
+with_suspended_cover(Nodes, Fun) ->
+ cover:stop(Nodes),
+ Res = Fun(),
+ cover:start(Nodes),
+ Res.
+
test_user_management() ->
%% lots if stuff that should fail