diff options
| author | Simon MacMullen <simon@rabbitmq.com> | 2011-08-17 16:01:14 +0100 |
|---|---|---|
| committer | Simon MacMullen <simon@rabbitmq.com> | 2011-08-17 16:01:14 +0100 |
| commit | 9ad33199a63a94a9eb274eeda193adce541ae868 (patch) | |
| tree | 84bc7a949aa134f6a1ec48631a04eee07c535b3a /src | |
| parent | c05d03cdea1d476d6f9b4d86a3655eaf40373764 (diff) | |
| download | rabbitmq-server-git-9ad33199a63a94a9eb274eeda193adce541ae868.tar.gz | |
More testing of which_children
Diffstat (limited to 'src')
| -rw-r--r-- | src/mirrored_supervisor_tests.erl | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/mirrored_supervisor_tests.erl b/src/mirrored_supervisor_tests.erl index bcec95c2f6..9c93718f16 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() -> |
