summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2011-08-17 16:01:14 +0100
committerSimon MacMullen <simon@rabbitmq.com>2011-08-17 16:01:14 +0100
commit527b948203ebe2806b5c5519b374257f6a9db310 (patch)
tree84bc7a949aa134f6a1ec48631a04eee07c535b3a
parent728713403b8ed90ae136e63f02581dd22b770702 (diff)
downloadrabbitmq-server-527b948203ebe2806b5c5519b374257f6a9db310.tar.gz
More testing of which_children
-rw-r--r--src/mirrored_supervisor_tests.erl23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/mirrored_supervisor_tests.erl b/src/mirrored_supervisor_tests.erl
index bcec95c2..9c93718f 100644
--- a/src/mirrored_supervisor_tests.erl
+++ b/src/mirrored_supervisor_tests.erl
@@ -99,11 +99,24 @@ test_delete_restart() ->
end, [a, b]).
test_which_children() ->
- with_sups(fun([A, B]) ->
- ?MS:start_child(A, childspec(worker)),
- ?MS:start_child(B, childspec(worker2)),
- 2 = length(?MS:which_children(A))
- end, [a, b]).
+ with_sups(
+ fun([A, B] = Both) ->
+ ?MS:start_child(A, childspec(worker)),
+ assert_wc(Both, fun ([C]) -> true = is_pid(wc_pid(C)) end),
+ ok = ?MS:terminate_child(a, worker),
+ assert_wc(Both, fun ([C]) -> undefined = wc_pid(C) end),
+ {ok, _} = ?MS:restart_child(a, worker),
+ assert_wc(Both, fun ([C]) -> true = is_pid(wc_pid(C)) end),
+ ?MS:start_child(B, childspec(worker2)),
+ assert_wc(Both, fun (C) -> 2 = length(C) end)
+ end, [a, b]).
+
+assert_wc(Sups, Fun) ->
+ [Fun(?MS:which_children(Sup)) || Sup <- Sups].
+
+wc_pid(Child) ->
+ {worker, Pid, worker, [mirrored_supervisor_tests]} = Child,
+ Pid.
%% Not all the members of the group should actually do the failover
test_large_group() ->