diff options
Diffstat (limited to 'lib/kernel/test')
-rw-r--r-- | lib/kernel/test/init_SUITE.erl | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/lib/kernel/test/init_SUITE.erl b/lib/kernel/test/init_SUITE.erl index 06bfe97bc4..2db0f7dcb8 100644 --- a/lib/kernel/test/init_SUITE.erl +++ b/lib/kernel/test/init_SUITE.erl @@ -24,6 +24,7 @@ init_per_group/2,end_per_group/2]). -export([get_arguments/1, get_argument/1, boot_var/1, restart/1, + many_restarts/1, get_plain_arguments/1, reboot/1, stop/1, get_status/1, script_id/1]). -export([boot1/1, boot2/1]). @@ -43,6 +44,7 @@ suite() -> [{ct_hooks,[ts_install_cth]}]. all() -> [get_arguments, get_argument, boot_var, + many_restarts, get_plain_arguments, restart, get_status, script_id, {group, boot}]. @@ -317,6 +319,73 @@ is_real_system(KernelVsn, StdlibVsn) -> %% Therefore the slave process must be killed %% before restart. %% ------------------------------------------------ +many_restarts(doc) -> []; +many_restarts(suite) -> + case ?t:os_type() of + {Fam, _} when Fam == unix; Fam == win32 -> + {req, [distribution, {local_slave_nodes, 1}, {time, 5}]}; + _ -> + {skip, "Only run on unix and win32"} + end; + +many_restarts(Config) when is_list(Config) -> + ?line Dog = ?t:timetrap(?t:seconds(480)), + ?line {ok, Node} = loose_node:start(init_test, "", ?DEFAULT_TIMEOUT_SEC), + ?line loop_restart(30,Node,rpc:call(Node,erlang,whereis,[error_logger])), + ?line loose_node:stop(Node), + ?line ?t:timetrap_cancel(Dog), + ok. + +loop_restart(0,_,_) -> + ok; +loop_restart(N,Node,EHPid) -> + ?line erlang:monitor_node(Node, true), + ?line ok = rpc:call(Node, init, restart, []), + ?line receive + {nodedown, Node} -> + ok + after 10000 -> + loose_node:stop(Node), + ?t:fail(not_stopping) + end, + ?line ok = wait_for(30, Node, EHPid), + ?line loop_restart(N-1,Node,rpc:call(Node,erlang,whereis,[error_logger])). + +wait_for(0,Node,_) -> + loose_node:stop(Node), + error; +wait_for(N,Node,EHPid) -> + ?line case rpc:call(Node, erlang, whereis, [error_logger]) of + Pid when is_pid(Pid), Pid =/= EHPid -> + %% ?line erlang:display(ok), + ?line ok; + _X -> + %% ?line erlang:display(_X), + %% ?line Procs = rpc:call(Node, erlang, processes, []), + %% ?line erlang:display(Procs), + %% case is_list(Procs) of + %% true -> + %% ?line [(catch erlang:display( + %% rpc:call(Node, + %% erlang, + %% process_info, + %% [Y,registered_name]))) + %% || Y <- Procs]; + %% _ -> + %% ok + %% end, + receive + after 100 -> + ok + end, + ?line wait_for(N-1,Node,EHPid) + end. + +%% ------------------------------------------------ +%% Slave executes erlang:halt() on master nodedown. +%% Therefore the slave process must be killed +%% before restart. +%% ------------------------------------------------ restart(doc) -> []; restart(suite) -> case ?t:os_type() of |