summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon MacMullen <simon@rabbitmq.com>2011-07-01 16:58:24 +0100
committerSimon MacMullen <simon@rabbitmq.com>2011-07-01 16:58:24 +0100
commitca14bae2d3f66b38058cf42c4101fc3c00c571fc (patch)
tree61a0ec168c6bedd3f9ca36d8d5d1e89cb7315504 /src
parentc40fe2d2e8e391430c9f3dae400afe8fe2ebad77 (diff)
downloadrabbitmq-server-git-ca14bae2d3f66b38058cf42c4101fc3c00c571fc.tar.gz
Improve reliability, test deleting and restarting children.
Diffstat (limited to 'src')
-rw-r--r--src/mirrored_supervisor_tests.erl18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/mirrored_supervisor_tests.erl b/src/mirrored_supervisor_tests.erl
index 22a3bd52eb..d86b3d448b 100644
--- a/src/mirrored_supervisor_tests.erl
+++ b/src/mirrored_supervisor_tests.erl
@@ -32,6 +32,7 @@ all_tests() ->
passed = test_migrate(),
passed = test_migrate_twice(),
passed = test_already_there(),
+ passed = test_delete_restart(),
passed.
test_migrate() ->
@@ -62,6 +63,19 @@ test_already_there() ->
{ok, Pid} = mirrored_supervisor:start_child(b, S)
end, [a, b]).
+test_delete_restart() ->
+ with_sups(fun([_, _]) ->
+ S = childspec(worker),
+ {ok, Pid1} = mirrored_supervisor:start_child(a, S),
+ mirrored_supervisor:terminate_child(a, worker),
+ mirrored_supervisor:delete_child(a, worker),
+ {ok, Pid2} = mirrored_supervisor:start_child(b, S),
+ false = (Pid1 =:= Pid2),
+ mirrored_supervisor:restart_child(a, worker),
+ Pid3 = pid_of(worker),
+ false = (Pid2 =:= Pid3)
+ end, [a, b]).
+
%% ---------------------------------------------------------------------------
@@ -104,7 +118,9 @@ call(Id, Msg, MaxDelay, Decr) ->
call(Id, Msg, MaxDelay - Decr, Decr)
end.
-kill(Pid) -> exit(Pid, kill).
+kill(Pid) ->
+ exit(Pid, kill),
+ timer:sleep(100).
%% ---------------------------------------------------------------------------
%% Dumb gen_server we can supervise