diff options
Diffstat (limited to 'lib/kernel/test/application_SUITE.erl')
-rw-r--r-- | lib/kernel/test/application_SUITE.erl | 542 |
1 files changed, 238 insertions, 304 deletions
diff --git a/lib/kernel/test/application_SUITE.erl b/lib/kernel/test/application_SUITE.erl index 0ff512bb6e..a0a7632d1b 100644 --- a/lib/kernel/test/application_SUITE.erl +++ b/lib/kernel/test/application_SUITE.erl @@ -40,14 +40,14 @@ shutdown_func/1, do_shutdown/1, shutdown_timeout/1, shutdown_deadlock/1]). -define(TESTCASE, testcase_name). --define(testcase, ?config(?TESTCASE, Config)). +-define(testcase, proplists:get_value(?TESTCASE, Config)). -export([init_per_testcase/2, end_per_testcase/2, start_type/0, start_phase/0, conf_change/0]). -% Default timetrap timeout (set in init_per_testcase). --define(default_timeout, ?t:minutes(2)). -suite() -> [{ct_hooks,[ts_install_cth]}]. +suite() -> + [{ct_hooks,[ts_install_cth]}, + {timetrap,{minutes,2}}]. all() -> [failover, failover_comp, permissions, load, @@ -81,21 +81,15 @@ end_per_group(_GroupName, Config) -> init_per_testcase(otp_2973=Case, Config) -> - code:add_path(?config(data_dir,Config)), - Dog = test_server:timetrap(?default_timeout), - [{?TESTCASE, Case}, {watchdog, Dog}|Config]; + code:add_path(proplists:get_value(data_dir,Config)), + [{?TESTCASE, Case}|Config]; init_per_testcase(Case, Config) -> - Dog = test_server:timetrap(?default_timeout), - [{?TESTCASE, Case}, {watchdog, Dog}|Config]. + [{?TESTCASE, Case}|Config]. end_per_testcase(otp_2973, Config) -> - code:del_path(?config(data_dir,Config)), - Dog=?config(watchdog, Config), - test_server:timetrap_cancel(Dog), + code:del_path(proplists:get_value(data_dir,Config)), ok; -end_per_testcase(_Case, Config) -> - Dog=?config(watchdog, Config), - test_server:timetrap_cancel(Dog), +end_per_testcase(_Case, _Config) -> ok. -define(UNTIL(Seq), loop_until_true(fun() -> Seq end)). @@ -120,10 +114,8 @@ loop_until_true(Fun) -> %% Should be started in a CC view with: %% erl -sname XXX -rsh ctrsh where XX not in [cp1, cp2, cp3] %%----------------------------------------------------------------- -failover(suite) -> []; -failover(doc) -> - ["Tests failover and takeover for distributed applications. Tests", - "start, load etc implicitly."]; +%% Tests failover and takeover for distributed applications. Tests +%% start, load etc implicitly. failover(Conf) when is_list(Conf) -> %% start a help process to check the start type StPid = spawn_link(?MODULE, start_type, []), @@ -133,14 +125,14 @@ failover(Conf) when is_list(Conf) -> NoSyncTime = config_fun_fast(config_fo(NodeNames)), WithSyncTime = config_fun(config_fo(NodeNames)), - % Test [cp1, cp2, cp3] + %% Test [cp1, cp2, cp3] {ok, Cp1} = start_node_config(Ncp1, NoSyncTime, Conf), {ok, Cp2} = start_node_config(Ncp2, NoSyncTime, Conf), {ok, Cp3} = start_node_config(Ncp3, WithSyncTime, Conf), Cps = [Cp1, Cp2, Cp3], wait_for_ready_net(), - % Start app1 and make sure cp1 starts it + %% Start app1 and make sure cp1 starts it {[ok,ok,ok],[]} = rpc:multicall(Cps, application, load, [app1()]), ?UNTIL(is_loaded(app1, Cps)), @@ -150,12 +142,12 @@ failover(Conf) when is_list(Conf) -> false = is_started(app1, Cp2), ok = get_start_type(#st{normal = 3}), - % Stop cp1 and make sure cp2 starts app1 + %% Stop cp1 and make sure cp2 starts app1 stop_node_nice(Cp1), ?UNTIL(is_started(app1, Cp2)), ok = get_start_type(#st{normal = 3}), - % Restart cp1 and make sure it restarts app1 + %% Restart cp1 and make sure it restarts app1 {ok, Cp1_2} = start_node_config(Ncp1, NoSyncTime, Conf), global:sync(), ok = rpc:call(Cp1_2, application, load, [app1()]), @@ -164,8 +156,8 @@ failover(Conf) when is_list(Conf) -> ?UNTIL(not is_started(app1, Cp2)), ok = get_start_type(#st{takeover = 3}), - % Test [{cp1, cp2}, cp3] - % Start app_sp and make sure cp2 starts it (cp1 has more apps started) + %% Test [{cp1, cp2}, cp3] + %% Start app_sp and make sure cp2 starts it (cp1 has more apps started) {[ok,ok,ok],[]} = rpc:multicall([Cp1_2, Cp2, Cp3], application, load, [app_sp()]), {[ok,ok,ok],[]} = @@ -175,17 +167,17 @@ failover(Conf) when is_list(Conf) -> false = is_started(app_sp, Cp3), ok = get_start_type(#st{normal = 3}), - % Stop cp2 and make sure cp1 starts app_sp + %% Stop cp2 and make sure cp1 starts app_sp stop_node_nice(Cp2), ?UNTIL(is_started(app_sp, Cp1_2)), ok = get_start_type(#st{failover = 3}), - % Stop cp1 and make sure cp3 starts app_sp + %% Stop cp1 and make sure cp3 starts app_sp stop_node_nice(Cp1_2), ?UNTIL(is_started(app_sp, Cp3)), ok = get_start_type(#st{normal = 3, failover = 3}), - % Restart cp2 and make sure it restarts app_sp + %% Restart cp2 and make sure it restarts app_sp {ok, Cp2_2} = start_node_config(Ncp2, NoSyncTime, Conf), global:sync(), ok = rpc:call(Cp2_2, application, load, [app_sp()]), @@ -194,16 +186,16 @@ failover(Conf) when is_list(Conf) -> ?UNTIL(not is_started(app_sp, Cp3)), ok = get_start_type(#st{takeover = 3}), - % Restart cp1 and make sure it doesn't restart app_sp + %% Restart cp1 and make sure it doesn't restart app_sp {ok, Cp1_3} = start_node_config(Ncp1, NoSyncTime, Conf), global:sync(), ok = rpc:call(Cp1_3, application, load, [app_sp()]), ok = rpc:call(Cp1_3, application, start, [app_sp, permanent]), - test_server:sleep(500), + ct:sleep(500), false = is_started(app_sp, Cp1_3), true = is_started(app_sp, Cp2_2), - % Force takeover to cp1 + %% Force takeover to cp1 ok = rpc:call(Cp1_3, application, takeover, [app_sp, permanent]), ?UNTIL(is_started(app_sp, Cp1_3)), ?UNTIL(not is_started(app_sp, Cp2_2)), @@ -225,11 +217,9 @@ failover(Conf) when is_list(Conf) -> %% Should be started in a CC view with: %% erl -sname XXX -rsh ctrsh where XX not in [cp1, cp2, cp3] %%----------------------------------------------------------------- -failover_comp(suite) -> []; -failover_comp(doc) -> - ["Tests failover and takeover for distributed applications. Tests", - "start, load etc implicitly. The applications do not use start_phases," - "i.e the failover should be trasfered to normal start type."]; +%% Tests failover and takeover for distributed applications. Tests +%% start, load etc implicitly. The applications do not use start_phases +%% i.e. the failover should be transfered to normal start type. failover_comp(Conf) when is_list(Conf) -> %% start a help process to check the start type StPid = spawn_link(?MODULE, start_type, []), @@ -239,14 +229,14 @@ failover_comp(Conf) when is_list(Conf) -> NoSyncTime = config_fun_fast(config(NodeNames)), WithSyncTime = config_fun(config(NodeNames)), - % Test [cp1, cp2, cp3] + %% Test [cp1, cp2, cp3] {ok, Cp1} = start_node_config(Ncp1, NoSyncTime, Conf), {ok, Cp2} = start_node_config(Ncp2, NoSyncTime, Conf), {ok, Cp3} = start_node_config(Ncp3, WithSyncTime, Conf), Cps = [Cp1, Cp2, Cp3], wait_for_ready_net(), - % Start app1 and make sure cp1 starts it + %% Start app1 and make sure cp1 starts it {[ok,ok,ok],[]} = rpc:multicall(Cps, application, load, [app1()]), ?UNTIL(is_loaded(app1, Cps)), @@ -256,12 +246,12 @@ failover_comp(Conf) when is_list(Conf) -> false = is_started(app1, Cp2), ok = get_start_type(#st{normal = 3}), - % Stop cp1 and make sure cp2 starts app1 + %% Stop cp1 and make sure cp2 starts app1 stop_node_nice(Cp1), ?UNTIL(is_started(app1, Cp2)), ok = get_start_type(#st{normal = 3}), - % Restart cp1 and make sure it restarts app1 + %% Restart cp1 and make sure it restarts app1 {ok, Cp1_2} = start_node_config(Ncp1, NoSyncTime, Conf), global:sync(), ok = rpc:call(Cp1_2, application, load, [app1()]), @@ -271,8 +261,8 @@ failover_comp(Conf) when is_list(Conf) -> ?UNTIL(not is_started(app1, Cp2)), ok = get_start_type(#st{takeover = 3}), - % Test [{cp1, cp2}, cp3] - % Start app3 and make sure cp2 starts it (cp1 has more apps started) + %% Test [{cp1, cp2}, cp3] + %% Start app3 and make sure cp2 starts it (cp1 has more apps started) {[ok,ok,ok],[]} = rpc:multicall([Cp1_2, Cp2, Cp3], application, load, [app3()]), ?UNTIL(is_loaded(app3, [Cp1_2, Cp2, Cp3])), @@ -283,17 +273,17 @@ failover_comp(Conf) when is_list(Conf) -> false = is_started(app3, Cp3), ok = get_start_type(#st{normal = 3}), - % Stop cp2 and make sure cp1 starts app3 + %% Stop cp2 and make sure cp1 starts app3 stop_node_nice(Cp2), ?UNTIL(is_started(app3, Cp1_2)), ok = get_start_type(#st{normal = 3}), - % Stop cp1 and make sure cp3 starts app3 + %% Stop cp1 and make sure cp3 starts app3 stop_node_nice(Cp1_2), ?UNTIL(is_started(app3, Cp3)), ok = get_start_type(#st{normal = 6}), - % Restart cp2 and make sure it restarts app3 + %% Restart cp2 and make sure it restarts app3 {ok, Cp2_2} = start_node_config(Ncp2, NoSyncTime, Conf), global:sync(), ok = rpc:call(Cp2_2, application, load, [app3()]), @@ -303,17 +293,17 @@ failover_comp(Conf) when is_list(Conf) -> ?UNTIL(not is_started(app3, Cp3)), ok = get_start_type(#st{takeover = 3}), - % Restart cp1 and make sure it doesn't restart app3 + %% Restart cp1 and make sure it doesn't restart app3 {ok, Cp1_3} = start_node_config(Ncp1, NoSyncTime, Conf), global:sync(), ok = rpc:call(Cp1_3, application, load, [app3()]), true = is_loaded(app3, Cp1_3), ok = rpc:call(Cp1_3, application, start, [app3, permanent]), - test_server:sleep(5000), + ct:sleep(5000), false = is_started(app3, Cp1_3), true = is_started(app3, Cp2_2), - % Force takeover to cp1 + %% Force takeover to cp1 ok = rpc:call(Cp1_3, application, takeover, [app3, permanent]), ?UNTIL(is_started(app3, Cp1_3)), ?UNTIL(not is_started(app3, Cp2_2)), @@ -335,23 +325,21 @@ failover_comp(Conf) when is_list(Conf) -> %% Should be started in a CC view with: %% erl -sname XXX -rsh ctrsh where XX not in [cp1, cp2, cp3] %%----------------------------------------------------------------- -permissions(suite) -> []; -permissions(doc) -> - ["Tests permissions for distributed applications."]; +%% Tests permissions for distributed applications. permissions(Conf) when is_list(Conf) -> NodeNames = [Ncp1, Ncp2, Ncp3] = node_names([cp1, cp2, cp3], Conf), NoSyncTime = config_fun_fast(config2(NodeNames)), WithSyncTime = config_fun(config2(NodeNames)), - % Test [cp1, cp2, cp3] + %% Test [cp1, cp2, cp3] {ok, Cp1} = start_node_config(Ncp1, NoSyncTime, Conf), {ok, Cp2} = start_node_config(Ncp2, NoSyncTime, Conf), {ok, Cp3} = start_node_config(Ncp3, WithSyncTime, Conf), Cps = [Cp1, Cp2, Cp3], wait_for_ready_net(), - % Start app1 and make sure cp1 starts it + %% Start app1 and make sure cp1 starts it {[ok,ok,ok],[]} = rpc:multicall(Cps, application, load, [app1()]), ?UNTIL(is_loaded(app1, Cps)), @@ -360,50 +348,50 @@ permissions(Conf) when is_list(Conf) -> ?UNTIL(is_started(app1, Cp1)), false = is_started(app1, Cp2), - % Unpermit app1 on cp1, make sure cp2 starts it + %% Unpermit app1 on cp1, make sure cp2 starts it ok = rpc:call(Cp1, application, permit, [app1, false]), false = is_started(app1, Cp1), true = is_started(app1, Cp2), - % Unpermit app1 on cp2, make sure cp3 starts it + %% Unpermit app1 on cp2, make sure cp3 starts it ok = rpc:call(Cp2, application, permit, [app1, false]), false = is_started(app1, Cp1), false = is_started(app1, Cp2), true = is_started(app1, Cp3), - % Permit cp2 again + %% Permit cp2 again ok = rpc:call(Cp2, application, permit, [app1, true]), false = is_started(app1, Cp1), false = is_started(app1, Cp3), true = is_started(app1, Cp2), - % Start app3, make sure noone starts it + %% Start app3, make sure noone starts it {[ok,ok,ok],[]} = rpc:multicall(Cps, application, load, [app3()]), ?UNTIL(is_loaded(app3, Cps)), {[ok,ok,ok],[]} = rpc:multicall(Cps, application, start, [app3, permanent]), - test_server:sleep(1000), + ct:sleep(1000), false = is_started(app3, Cp1), false = is_started(app3, Cp2), false = is_started(app3, Cp3), - % Permit app3 on Cp3 + %% Permit app3 on Cp3 ok = rpc:call(Cp3, application, permit, [app3, true]), true = is_started(app3, Cp3), - % Permit app3 on Cp2, make sure it starts it + %% Permit app3 on Cp2, make sure it starts it ok = rpc:call(Cp2, application, permit, [app3, true]), true = is_started(app3, Cp2), false = is_started(app3, Cp3), - % Permit app3 on Cp1, make sure it doesn't start it + %% Permit app3 on Cp1, make sure it doesn't start it ok = rpc:call(Cp1, application, permit, [app3, true]), false = is_started(app3, Cp1), true = is_started(app3, Cp2), false = is_started(app3, Cp3), - % Stop Cp2, make sure Cp1 starts app3 + %% Stop Cp2, make sure Cp1 starts app3 stop_node_nice(Cp2), ?UNTIL(is_started(app3, Cp1)), @@ -415,15 +403,13 @@ permissions(Conf) when is_list(Conf) -> %% Should be started in a CC view with: %% erl -sname XXX -rsh ctrsh where XX not in [cp1, cp2, cp3] %%----------------------------------------------------------------- -load(suite) -> []; -load(doc) -> - ["Tests loading of distributed applications."]; +%% Tests loading of distributed applications. load(Conf) when is_list(Conf) -> NodeNames = [Ncp1, Ncp2, Ncp3] = node_names([cp1, cp2, cp3], Conf), NoSyncTime = config_fun_fast(config3(NodeNames)), WithSyncTime = config_fun(config3(NodeNames)), - % Test [cp1, cp2, cp3] + %% Test [cp1, cp2, cp3] {ok, Cp1} = start_node_config(Ncp1, NoSyncTime, Conf), {ok, Cp2} = start_node_config(Ncp2, NoSyncTime, Conf), {ok, Cp3} = start_node_config(Ncp3, WithSyncTime, Conf), @@ -439,7 +425,7 @@ load(Conf) when is_list(Conf) -> false = is_started(app1, Cp2), false = is_started(app1, Cp3), - % Load app1 with different specs and make sure we get an error + %% Load app1 with different specs and make sure we get an error {[{error,_},{error,_}],[]} = rpc:multicall([Cp1, Cp2], application, load, [app1(), d1(NodeNames)]), {error, _} = rpc:call(Cp3, application, load, [app1(), d2(NodeNames)]), @@ -452,15 +438,13 @@ load(Conf) when is_list(Conf) -> %%----------------------------------------------------------------- %% Same test as load/1, only with code path cache enabled. %%----------------------------------------------------------------- -load_use_cache(suite) -> []; -load_use_cache(doc) -> - ["Tests loading of distributed applications. Code path cache enabled."]; +%% Tests loading of distributed applications. Code path cache enabled. load_use_cache(Conf) when is_list(Conf) -> NodeNames = [Ncp1, Ncp2, Ncp3] = node_names([cp1, cp2, cp3], Conf), NoSyncTime = config_fun_fast(config3(NodeNames)), WithSyncTime = config_fun(config3(NodeNames)), - % Test [cp1, cp2, cp3] + %% Test [cp1, cp2, cp3] {ok, Cp1} = start_node_with_cache(Ncp1, NoSyncTime, Conf), {ok, Cp2} = start_node_with_cache(Ncp2, NoSyncTime, Conf), {ok, Cp3} = start_node_with_cache(Ncp3, WithSyncTime, Conf), @@ -475,7 +459,7 @@ load_use_cache(Conf) when is_list(Conf) -> ?UNTIL(is_started(app1, Cp1)), false = is_started(app1, Cp2), - % Load app1 with different specs and make sure we get an error + %% Load app1 with different specs and make sure we get an error {[{error,_},{error,_}],[]} = rpc:multicall([Cp1, Cp2], application, load, [app1(), d1(NodeNames)]), {error, _} = rpc:call(Cp3, application, load, [app1(), d2(NodeNames)]), @@ -489,9 +473,7 @@ load_use_cache(Conf) when is_list(Conf) -> %% Should be started in a CC view with: %% erl -sname XXX -rsh ctrsh where XX not in [cp1, cp2, cp3] %%----------------------------------------------------------------- -start_phases(suite) -> []; -start_phases(doc) -> - ["Tests new start phases and failover."]; +%% Tests new start phases and failover. start_phases(Conf) when is_list(Conf) -> %% start a help process to check the start type SpPid = spawn_link(?MODULE, start_phase, []), @@ -553,17 +535,15 @@ start_phases(Conf) when is_list(Conf) -> ok. -script_start(doc) -> - ["Start distributed applications from within a boot script. Test ", - "same as failover."]; -script_start(suite) -> []; +%% Start distributed applications from within a boot script. Test +%% same as failover. script_start(Conf) when is_list(Conf) -> %% start a help process to check the start type StPid = spawn_link(?MODULE, start_type, []), yes = global:register_name(st_type, StPid), - % Create the .app files and the boot script + %% Create the .app files and the boot script ok = create_app(), {{KernelVer,StdlibVer}, _} = create_script("latest"), case is_real_system(KernelVer, StdlibVer) of @@ -578,7 +558,7 @@ script_start(Conf) when is_list(Conf) -> NoSyncTime = config_fun_fast(config_fo(NodeNames)), WithSyncTime = config_fun(config_fo(NodeNames)), - % Test [cp1, cp2, cp3] + %% Test [cp1, cp2, cp3] {ok, Cp1} = start_node_boot_config(Ncp1, NoSyncTime, Conf, latest), {ok, Cp2} = start_node_boot_config(Ncp2, NoSyncTime, Conf, latest), {ok, Cp3} = start_node_boot_config(Ncp3, WithSyncTime, Conf, latest), @@ -590,16 +570,16 @@ script_start(Conf) when is_list(Conf) -> false = is_started(app1, Cp2), ok = get_start_type(#st{normal = 9}), - % Stop cp1 and make sure cp2 starts app1, app2 normally (no - % start_phases defined) and app_sp as failover (start_phases - % defined) + %% Stop cp1 and make sure cp2 starts app1, app2 normally (no + %% start_phases defined) and app_sp as failover (start_phases + %% defined) stop_node_nice(Cp1), ?UNTIL(is_started(app1, Cp2)), ?UNTIL(is_started(app2, Cp2)), ?UNTIL(is_started(app_sp, Cp2)), ok = get_start_type(#st{normal = 6, failover = 3}), - % Restart cp1, Cp1 takesover app1 and app2 + %% Restart cp1, Cp1 takesover app1 and app2 {ok, Cp1_2} = start_node_boot_config(Ncp1, NoSyncTime, Conf, latest), global:sync(), ?UNTIL(is_started(app1, Cp1_2)), @@ -610,20 +590,20 @@ script_start(Conf) when is_list(Conf) -> ?UNTIL(not is_started(app2, Cp2)), ok = get_start_type(#st{takeover = 6}), - % Stop cp2 and make sure cp1 starts app_sp. + %% Stop cp2 and make sure cp1 starts app_sp. false = is_started(app_sp, Cp1_2), stop_node_nice(Cp2), ?UNTIL(is_started(app_sp, Cp1_2)), ok = get_start_type(#st{failover = 3}), - % Stop cp1 and make sure cp3 starts app1, app2 and app_sp + %% Stop cp1 and make sure cp3 starts app1, app2 and app_sp stop_node_nice(Cp1_2), ?UNTIL(is_started(app_sp, Cp3)), ?UNTIL(is_started(app1, Cp3)), ?UNTIL(is_started(app2, Cp3)), ok = get_start_type(#st{normal = 6, failover = 3}), - % Restart cp2 and make sure it takesover app1, app2 and app_sp + %% Restart cp2 and make sure it takesover app1, app2 and app_sp {ok, Cp2_2} = start_node_boot_config(Ncp2, NoSyncTime, Conf, latest), global:sync(), ?UNTIL(is_started(app_sp, Cp2_2)), @@ -634,7 +614,7 @@ script_start(Conf) when is_list(Conf) -> ?UNTIL(not is_started(app2, Cp3)), ok = get_start_type(#st{takeover = 9}), - % Restart cp1 and make sure it takesover app1, app2 + %% Restart cp1 and make sure it takesover app1, app2 {ok, Cp1_3} = start_node_boot_config(Ncp1, NoSyncTime, Conf, latest), global:sync(), ?UNTIL(is_started(app1, Cp1_3)), @@ -645,7 +625,7 @@ script_start(Conf) when is_list(Conf) -> ?UNTIL(not is_started(app2, Cp2_2)), ok = get_start_type(#st{takeover = 6}), - % Force takeover to cp1 + %% Force takeover to cp1 ok = rpc:call(Cp1_3, application, takeover, [app_sp, permanent]), ?UNTIL(is_started(app_sp, Cp1_3)), ?UNTIL(not is_started(app_sp, Cp2_2)), @@ -668,15 +648,13 @@ script_start(Conf) when is_list(Conf) -> ok. -permit_false_start_local(doc) -> - ["Start local applications with permission false. Set", - "permit true on different nodes."]; -permit_false_start_local(suite) -> []; +%% Start local applications with permission false. Set +%% permit true on different nodes. permit_false_start_local(Conf) when is_list(Conf) -> %% This configuration does not start dist_ac. Config = write_config_file(fun config_perm/1, Conf), - % Test [cp1, cp2, cp3] + %% Test [cp1, cp2, cp3] [Ncp1, Ncp2, Ncp3] = node_names([cp1, cp2, cp3], Conf), {ok, Cp1} = start_node(Ncp1, Config), {ok, Cp2} = start_node(Ncp2, Config), @@ -694,99 +672,99 @@ permit_false_start_local(Conf) when is_list(Conf) -> {[ok,ok,ok],[]} = rpc:multicall([Cp1, Cp2, Cp3], application, load, [app3()]), - test_server:sleep(1000), + ct:sleep(1000), false = is_started(app1, Cp1), false = is_started(app1, Cp2), false = is_started(app1, Cp3), - %Permit a not started application + %% Permit a not started application ok = rpc:call(Cp1, application, permit, [app3, true]), - test_server:sleep(1000), + ct:sleep(1000), false = is_started(app3, Cp1), false = is_started(app3, Cp2), false = is_started(app3, Cp3), - %Permit a not loaded application + %% Permit a not loaded application {error,{not_loaded,app_notloaded}} = rpc:call(Cp1, application, permit, [app_notloaded, true]), - test_server:sleep(1000), + ct:sleep(1000), false = is_started(app_notloaded, Cp1), false = is_started(app_notloaded, Cp2), false = is_started(app_notloaded, Cp3), - %Unpermit a not started application + %% Unpermit a not started application ok = rpc:call(Cp1, application, permit, [app3, false]), - test_server:sleep(1000), + ct:sleep(1000), false = is_started(app3, Cp1), false = is_started(app3, Cp2), false = is_started(app3, Cp3), - %Unpermit a not loaded application + %% Unpermit a not loaded application {error,{not_loaded,app_notloaded}} = rpc:call(Cp1, application, permit, [app_notloaded, false]), - test_server:sleep(1000), + ct:sleep(1000), false = is_started(app_notloaded, Cp1), false = is_started(app_notloaded, Cp2), false = is_started(app_notloaded, Cp3), - % Permit app1 on CP1 and make sure it is started + %% Permit app1 on CP1 and make sure it is started ok = rpc:call(Cp1, application, permit, [app1, true]), ?UNTIL(is_started(app1, Cp1)), false = is_started(app1, Cp2), false = is_started(app1, Cp3), - % Permit it again + %% Permit it again ok = rpc:call(Cp1, application, permit, [app1, true]), - test_server:sleep(1000), + ct:sleep(1000), true = is_started(app1, Cp1), false = is_started(app1, Cp2), false = is_started(app1, Cp3), - % Permit app2 on CP1 and make sure it is started + %% Permit app2 on CP1 and make sure it is started ok = rpc:call(Cp1, application, permit, [app2, true]), ?UNTIL(is_started(app2, Cp1)), false = is_started(app2, Cp2), false = is_started(app2, Cp3), - % Permit app1 on CP2 and make sure it is started + %% Permit app1 on CP2 and make sure it is started ok = rpc:call(Cp2, application, permit, [app1, true]), ?UNTIL(is_started(app1, Cp2)), true = is_started(app1, Cp1), false = is_started(app1, Cp3), - % Unpermit app1 on CP1 and make sure it is stopped + %% Unpermit app1 on CP1 and make sure it is stopped ok = rpc:call(Cp1, application, permit, [app1, false]), ?UNTIL(false =:= is_started(app1, Cp1)), true = is_started(app1, Cp2), false = is_started(app1, Cp3), - % Unpermit it agin + %% Unpermit it agin ok = rpc:call(Cp1, application, permit, [app1, false]), - test_server:sleep(1000), + ct:sleep(1000), false = is_started(app1, Cp1), true = is_started(app1, Cp2), false = is_started(app1, Cp3), - % Permit app1 on CP1 and make sure it is started + %% Permit app1 on CP1 and make sure it is started ok = rpc:call(Cp1, application, permit, [app1, true]), ?UNTIL(is_started(app1, Cp1)), true = is_started(app1, Cp2), false = is_started(app1, Cp3), - % Unpermit app1 on CP1 and make sure it is stopped + %% Unpermit app1 on CP1 and make sure it is stopped ok = rpc:call(Cp1, application, permit, [app1, false]), ?UNTIL(false =:= is_started(app1, Cp1)), true = is_started(app1, Cp2), false = is_started(app1, Cp3), - % Unpermit app1 on CP2 and make sure it is stopped + %% Unpermit app1 on CP2 and make sure it is stopped ok = rpc:call(Cp2, application, permit, [app1, false]), - test_server:sleep(1000), + ct:sleep(1000), ?UNTIL(false =:= is_started(app1, Cp2)), false = is_started(app1, Cp1), false = is_started(app1, Cp3), - % Unpermit app2 on CP1 and make sure it is stopped + %% Unpermit app2 on CP1 and make sure it is stopped ok = rpc:call(Cp1, application, permit, [app2, false]), ?UNTIL(false =:= is_started(app2, Cp2)), false = is_started(app2, Cp1), @@ -798,16 +776,14 @@ permit_false_start_local(Conf) when is_list(Conf) -> ok. -permit_false_start_dist(doc) -> - ["Start distributed applications with permission false. Set", - "permit true on different nodes."]; -permit_false_start_dist(suite) -> []; +%% Start distributed applications with permission false. Set +%% permit true on different nodes. permit_false_start_dist(Conf) when is_list(Conf) -> NodeNames = [Ncp1, Ncp2, Ncp3] = node_names([cp1, cp2, cp3], Conf), NoSyncTime = config_fun_fast(config_perm2(NodeNames)), WithSyncTime = config_fun(config_perm2(NodeNames)), - % Test [cp1, cp2, cp3] + %% Test [cp1, cp2, cp3] {ok, Cp1} = start_node_config(Ncp1, NoSyncTime, Conf), {ok, Cp2} = start_node_config(Ncp2, NoSyncTime, Conf), {ok, Cp3} = start_node_config(Ncp3, WithSyncTime, Conf), @@ -822,36 +798,36 @@ permit_false_start_dist(Conf) when is_list(Conf) -> {[ok,ok,ok],[]} = rpc:multicall(Cps, application, load, [app2()]), - test_server:sleep(1000), + ct:sleep(1000), false = is_started(app1, Cp1), false = is_started(app1, Cp2), false = is_started(app1, Cp3), - %Permit a not started application + %% Permit a not started application ok = rpc:call(Cp1, application, permit, [app2, true]), - test_server:sleep(1000), + ct:sleep(1000), false = is_started(app2, Cp1), false = is_started(app2, Cp2), false = is_started(app2, Cp3), - %Permit a not loaded application + %% Permit a not loaded application {error,{not_loaded,app3}} = rpc:call(Cp1, application, permit, [app3, true]), - test_server:sleep(1000), + ct:sleep(1000), false = is_started(app3, Cp1), false = is_started(app3, Cp2), false = is_started(app3, Cp3), - %Unpermit a not started application + %% Unpermit a not started application ok = rpc:call(Cp1, application, permit, [app2, false]), {[ok,ok,ok],[]} = rpc:multicall([Cp1, Cp2, Cp3], application, start, [app2, permanent]), - test_server:sleep(1000), + ct:sleep(1000), false = is_started(app2, Cp1), false = is_started(app2, Cp2), false = is_started(app2, Cp3), - %Unpermit a not loaded application + %% Unpermit a not loaded application {error,{not_loaded,app3}} = rpc:call(Cp1, application, permit, [app3, false]), {[ok,ok,ok],[]} = @@ -859,42 +835,42 @@ permit_false_start_dist(Conf) when is_list(Conf) -> ?UNTIL(is_loaded(app3, Cps)), {[ok,ok,ok],[]} = rpc:multicall(Cps, application, start, [app3, permanent]), - test_server:sleep(1000), + ct:sleep(1000), false = is_started(app3, Cp1), false = is_started(app3, Cp2), false = is_started(app3, Cp3), - % Permit app1 on CP1 and make sure it is started + %% Permit app1 on CP1 and make sure it is started ok = rpc:call(Cp1, application, permit, [app1, true]), ?UNTIL(is_started(app1, Cp1)), false = is_started(app1, Cp2), false = is_started(app1, Cp3), - % Permit it again + %% Permit it again ok = rpc:call(Cp1, application, permit, [app1, true]), ?UNTIL(is_started(app1, Cp1)), false = is_started(app1, Cp2), false = is_started(app1, Cp3), - % Permit app2 on CP1 and make sure it is started + %% Permit app2 on CP1 and make sure it is started ok = rpc:call(Cp1, application, permit, [app2, true]), ?UNTIL(is_started(app2, Cp1)), false = is_started(app2, Cp2), false = is_started(app2, Cp3), - % Permit app1 on CP2 and make sure it is not started + %% Permit app1 on CP2 and make sure it is not started ok = rpc:call(Cp2, application, permit, [app1, true]), - test_server:sleep(1000), + ct:sleep(1000), true = is_started(app1, Cp1), false = is_started(app1, Cp2), false = is_started(app1, Cp3), - % Crash CP1 and make sure app1, but not app2, is started on CP2 + %% Crash CP1 and make sure app1, but not app2, is started on CP2 stop_node_nice(Cp1), ?UNTIL(is_started(app1, Cp2)), false = is_started(app2, Cp2), - % Restart CP1 again, check nothing is running on it + %% Restart CP1 again, check nothing is running on it {ok, Cp1_2} = start_node_config(Ncp1, NoSyncTime, Conf), global:sync(), ok = rpc:call(Cp1_2, application, load, [app1()]), @@ -909,19 +885,19 @@ permit_false_start_dist(Conf) when is_list(Conf) -> false = is_started(app1, Cp1_2), false = is_started(app2, Cp1_2), - % Permit app3 on CP3 and make sure it is started + %% Permit app3 on CP3 and make sure it is started ok = rpc:call(Cp3, application, permit, [app3, true]), ?UNTIL(is_started(app3, Cp3)), false = is_started(app3, Cp1_2), false = is_started(app3, Cp2), - % Permit app3 on CP1 and make sure it is moved there from CP3 + %% Permit app3 on CP1 and make sure it is moved there from CP3 ok = rpc:call(Cp1_2, application, permit, [app3, true]), ?UNTIL(is_started(app3, Cp1_2)), false = is_started(app3, Cp2), false = is_started(app3, Cp3), - % Unpermit app3 on CP3 and CP1 and make sure it is stopped + %% Unpermit app3 on CP3 and CP1 and make sure it is stopped ok = rpc:call(Cp3, application, permit, [app3, false]), ok = rpc:call(Cp1_2, application, permit, [app3, false]), ?UNTIL(false =:= is_started(app3, Cp1_2)), @@ -933,27 +909,25 @@ permit_false_start_dist(Conf) when is_list(Conf) -> stop_node_nice(Cp3), ok. -nodedown_start(doc) -> - ["app1 distributed as [cp1, cp2]. Call application:start(app1) on", - "cp2, but not on cp1. Kill cp1. Make sure app1 is started on cp2."]; -nodedown_start(suite) -> []; +%% app1 distributed as [cp1, cp2]. Call application:start(app1) on +%% cp2, but not on cp1. Kill cp1. Make sure app1 is started on cp2. nodedown_start(Conf) when is_list(Conf) -> NodeNames = [Ncp1, Ncp2] = node_names([cp1, cp2], Conf), NoSyncTime = config_fun_fast(config4(NodeNames)), WithSyncTime = config_fun(config4(NodeNames)), - % Test [cp1, cp2] + %% Test [cp1, cp2] {ok, Cp1} = start_node_config(Ncp1, NoSyncTime, Conf), {ok, Cp2} = start_node_config(Ncp2, WithSyncTime, Conf), wait_for_ready_net(), - % Start app1 and make sure cp1 starts it + %% Start app1 and make sure cp1 starts it {[ok,ok],[]} = rpc:multicall([Cp1, Cp2], application, load, [app1()]), _ = rpc:cast(Cp2, application, start, [app1, permanent]), - test_server:sleep(1000), + ct:sleep(1000), - % Crash CP1 and make sure app1 is started on CP2 + %% Crash CP1 and make sure app1 is started on CP2 stop_node_nice(Cp1), ?UNTIL(is_started(app1, Cp2)), @@ -961,8 +935,7 @@ nodedown_start(Conf) when is_list(Conf) -> ok. -ensure_started(suite) -> []; -ensure_started(doc) -> ["Test application:ensure_started/1."]; +%% Test application:ensure_started/1. ensure_started(_Conf) -> {ok, Fd} = file:open("app1.app", [write]), @@ -981,8 +954,7 @@ ensure_started(_Conf) -> ok = application:unload(app1), ok. -ensure_all_started(suite) -> []; -ensure_all_started(doc) -> ["Test application:ensure_all_started/1-2."]; +%% Test application:ensure_all_started/1-2. ensure_all_started(_Conf) -> {ok, Fd1} = file:open("app1.app", [write]), @@ -1069,11 +1041,9 @@ ensure_all_started(_Conf) -> %% Ticket: OTP-1586 %% Slogan: recursive load of applications fails %%----------------------------------------------------------------- -otp_1586(suite) -> []; -otp_1586(doc) -> - ["Test recursive load of applications."]; +%% Test recursive load of applications. otp_1586(Conf) when is_list(Conf) -> - Dir = ?config(priv_dir,Conf), + Dir = proplists:get_value(priv_dir,Conf), {ok, Fd} = file:open(filename:join(Dir, "app5.app"), [write]), w_app5(Fd), file:close(Fd), @@ -1090,21 +1060,19 @@ otp_1586(Conf) when is_list(Conf) -> %% Slogan: start of distrib apps fails when the nodes start %% simultaneously %%----------------------------------------------------------------- -otp_2078(suite) -> []; -otp_2078(doc) -> - ["Test start of distrib apps fails when the nodes start simultaneously."]; +%% Test start of distrib apps fails when the nodes start simultaneously. otp_2078(Conf) when is_list(Conf) -> NodeNames = [Ncp1, Ncp2] = node_names([cp1, cp2], Conf), NoSyncTime = config_fun_fast(config4(NodeNames)), WithSyncTime = config_fun(config4(NodeNames)), - % Test [cp1, cp2] + %% Test [cp1, cp2] {ok, Cp1} = start_node_config(Ncp1, NoSyncTime, Conf), {ok, Cp2} = start_node_config(Ncp2, WithSyncTime, Conf), Cps = [Cp1, Cp2], wait_for_ready_net(), - % Start app1 and make sure cp1 starts it + %% Start app1 and make sure cp1 starts it {[ok,ok],[]} = rpc:multicall(Cps, application, load, [app1()]), ?UNTIL(is_loaded(app1, Cps)), @@ -1112,8 +1080,8 @@ otp_2078(Conf) when is_list(Conf) -> ?UNTIL(is_started(app1, Cp1)), false = is_started(app1, Cp2), - % Start app1 on cp2; make sure it works (the bug was that this start - % returned error) + %% Start app1 on cp2; make sure it works (the bug was that this start + %% returned error) ok = rpc:call(Cp2, application, start, [app1, permanent]), true = is_started(app1, Cp1), false = is_started(app1, Cp2), @@ -1122,15 +1090,13 @@ otp_2078(Conf) when is_list(Conf) -> stop_node_nice(Cp2), ok. -otp_2012(suite) -> []; -otp_2012(doc) -> - ["Test change of configuration parameters without changing code."]; +%% Test change of configuration parameters without changing code. otp_2012(Conf) when is_list(Conf) -> %% start a help process to check the config change CcPid = spawn_link(?MODULE, conf_change, []), yes = global:register_name(conf_change, CcPid), - % Write a .app file + %% Write a .app file {ok, Fd} = file:open("app1.app", [write]), w_app1(Fd), file:close(Fd), @@ -1138,7 +1104,7 @@ otp_2012(Conf) when is_list(Conf) -> w_app1(Fd2), file:close(Fd2), - % Start app1 + %% Start app1 ok = application:load(app1()), ok = application:start(app1, permanent), @@ -1149,7 +1115,7 @@ otp_2012(Conf) when is_list(Conf) -> ok = application_controller:config_change(EnvBefore), ok = get_conf_change([{[], [{new1, hi}, {new2, moi}], []}]), - % Start app2 + %% Start app2 ok = application:load(app2()), ok = application:start(app2, permanent), @@ -1173,11 +1139,9 @@ otp_2012(Conf) when is_list(Conf) -> %% Ticket: OTP-2718 %% Slogan: transient app which fails during start is ignored %%----------------------------------------------------------------- -otp_2718(suite) -> []; -otp_2718(doc) -> - ["Test fail of transient app at start."]; +%% Test fail of transient app at start. otp_2718(Conf) when is_list(Conf) -> - {ok, Cp1} = start_node_args(cp1, "-pa " ++ ?config(data_dir,Conf)), + {ok, Cp1} = start_node_args(cp1, "-pa " ++ proplists:get_value(data_dir,Conf)), wait_for_ready_net(), %% normal exit from the application @@ -1185,7 +1149,7 @@ otp_2718(Conf) when is_list(Conf) -> ?UNTIL(is_loaded(trans_normal, Cp1)), {error, {{'EXIT',normal},_}} = rpc:call(Cp1, application, start, [trans_normal, transient]), - test_server:sleep(2000), + ct:sleep(2000), false = is_started(trans_normal, Cp1), %% abnormal exit from the application @@ -1193,7 +1157,7 @@ otp_2718(Conf) when is_list(Conf) -> {error, {bad_return,{{trans_abnormal_sup,start,[normal,[]]}, {'EXIT',abnormal}}}} = rpc:call(Cp1, application, start, [trans_abnormal, transient]), - test_server:sleep(3000), + ct:sleep(3000), {badrpc,nodedown} = which_applications(Cp1), ok. @@ -1201,11 +1165,9 @@ otp_2718(Conf) when is_list(Conf) -> %% Ticket: OTP-2973 %% Slogan: application:start does not test if an appl is already starting... %%----------------------------------------------------------------- -otp_2973(suite) -> []; -otp_2973(doc) -> - ["Test of two processes simultanously starting the same application."]; +%% Test of two processes simultanously starting the same application. otp_2973(Conf) when is_list(Conf) -> - % Write a .app file + %% Write a .app file {ok, Fd} = file:open("app0.app", [write]), w_app(Fd, app0()), file:close(Fd), @@ -1222,14 +1184,14 @@ otp_2973(Conf) when is_list(Conf) -> {Pid2, res, Res2x} -> {Res1x, Res2x} after 2000 -> - test_server:fail(timeout_pid2) + ct:fail(timeout_pid2) end; {Pid2, res, Res2x} -> receive {Pid1, res, Res1x} -> {Res1x, Res2x} after 2000 -> - test_server:fail(timeout_pid1) + ct:fail(timeout_pid1) end end, @@ -1243,11 +1205,11 @@ otp_2973(Conf) when is_list(Conf) -> _ -> Txt = io_lib:format("Illegal results from start: ~p ~p ", [Res1, Res2]), - test_server:fail(lists:flatten(Txt)) + ct:fail(lists:flatten(Txt)) end, - % Write a .app file + %% Write a .app file {ok, Fda} = file:open("app_start_error.app", [write]), w_app_start_error(Fda), file:close(Fda), @@ -1261,14 +1223,14 @@ otp_2973(Conf) when is_list(Conf) -> {Pid2, res, Res2y} -> {Res1y, Res2y} after 2000 -> - test_server:fail(timeout_pid2) + ct:fail(timeout_pid2) end; {Pid2, res, Res2y} -> receive {Pid1, res, Res1y} -> {Res1y, Res2y} after 2000 -> - test_server:fail(timeout_pid1) + ct:fail(timeout_pid1) end end, @@ -1278,7 +1240,7 @@ otp_2973(Conf) when is_list(Conf) -> ok; _ -> Txta = io_lib:format("Illegal results from start ~p ~p ",[Res1a, Res2a]), - test_server:fail(lists:flatten(Txta)) + ct:fail(lists:flatten(Txta)) end, ok. @@ -1289,36 +1251,34 @@ otp_2973(Conf) when is_list(Conf) -> %% Ticket: OTP-3184 %% Slogan: crash the node if permanent appl has illegal env parameter values %%----------------------------------------------------------------- -otp_3184(suite) -> []; -otp_3184(doc) -> - ["When a distributed application is started the permit flag is checked " - "that the permit flag is not changed during the start. " - "Te check must only be made if the application is started on the own node"]; +%% When a distributed application is started the permit flag is checked +%% that the permit flag is not changed during the start. +%% The check must only be made if the application is started on the own node. otp_3184(Conf) when is_list(Conf) -> NodeNames = [Ncp1, Ncp2] = node_names([cp1, cp2], Conf), NoSyncTime = config_fun_fast(config3184(NodeNames)), WithSyncTime = config_fun(config3184(NodeNames)), - % Test [cp1, cp2] + %% Test [cp1, cp2] {ok, Cp1} = start_node_config(Ncp1, NoSyncTime, Conf), {ok, Cp2} = start_node_config(Ncp2, WithSyncTime, Conf), wait_for_ready_net(), - % Start app1 and make sure it is not started + %% Start app1 and make sure it is not started {[ok,ok],[]} = rpc:multicall([Cp1, Cp2], application, load, [app1()]), - test_server:sleep(3000), + ct:sleep(3000), false = is_started(app1, Cp1), false = is_started(app1, Cp2), - % Start app1 on cp1 + %% Start app1 on cp1 ok = rpc:call(Cp1, application, permit, [app1, true]), ok = rpc:call(Cp1, application, start, [app1, permanent]), ok = rpc:call(Cp2, application, start, [app1, permanent]), ?UNTIL(is_started(app1, Cp1)), false = is_started(app1, Cp2), - % Check that the application is marked as running in application_controller + %% Check that the application is marked as running in application_controller X = rpc:call(Cp1, application_controller, info, []), {value, {running, Xrunning}} = lists:keysearch(running, 1, X), {value, Xapp1} = lists:keysearch(app1, 1, Xrunning), @@ -1337,15 +1297,13 @@ otp_3184(Conf) when is_list(Conf) -> %% Ticket: OTP-3002 %% Slogan: crash the node if permanent appl has illegal env parameter values %%----------------------------------------------------------------- -otp_3002(suite) -> []; -otp_3002(doc) -> - ["crash the node if permanent appl has illegal env parameter values."]; +%% crash the node if permanent appl has illegal env parameter values. otp_3002(Conf) when is_list(Conf) -> - % Create the boot script + %% Create the boot script {{KernelVer,StdlibVer}, {LatestDir, LatestName}} = create_script_3002("script_3002"), - ?t:format(0, "LatestDir = ~p~n", [LatestDir]), - ?t:format(0, "LatestName = ~p~n", [LatestName]), + ct:pal(?HI_VERBOSITY, "LatestDir = ~p~n", [LatestDir]), + ct:pal(?HI_VERBOSITY, "LatestName = ~p~n", [LatestName]), case is_real_system(KernelVer, StdlibVer) of true -> @@ -1371,10 +1329,9 @@ otp_3002(Conf) when is_list(Conf) -> %% when it received dist_ac_app_stopped). %%----------------------------------------------------------------- -otp_4066(suite) -> []; -otp_4066(doc) -> ["Check that application stop don't cause dist_ac crash"]; +%% Check that application stop don't cause dist_ac crash. otp_4066(Conf) when is_list(Conf) -> - % Write config files + %% Write config files [Ncp1, Ncp2] = node_names([cp1, cp2], Conf), Host = from($@, atom_to_list(node())), Cp1 = list_to_atom(Ncp1 ++ "@" ++ Host), @@ -1382,12 +1339,12 @@ otp_4066(Conf) when is_list(Conf) -> AllNodes = [Cp1, Cp2], App1Nodes = {app1, AllNodes}, - Dir = ?config(priv_dir,Conf), + Dir = proplists:get_value(priv_dir,Conf), {ok, FdC} = file:open(filename:join(Dir, "otp_4066.config"), [write]), write_config(FdC, config_4066(AllNodes, 5000, [App1Nodes])), file:close(FdC), - % Write the app1.app file + %% Write the app1.app file {ok, FdA12} = file:open(filename:join(Dir, "app1.app"), [write]), w_app1(FdA12), file:close(FdA12), @@ -1402,29 +1359,29 @@ otp_4066(Conf) when is_list(Conf) -> ok = rpc:call(Cp1, application, start, [app1]), wait_until_started(app1, [Cp1]), - test_server:format("--- App1 started at Cp1 ---~n", []), + io:format("--- App1 started at Cp1 ---~n", []), print_dac_state(AllNodes), - % Cp2 previously crashed on this stop + %% Cp2 previously crashed on this stop ok = rpc:call(Cp1, application, stop, [app1]), wait_until_stopped(app1, [Cp1]), - test_server:format("--- App1 stopped at Cp1 ---~n", []), + io:format("--- App1 stopped at Cp1 ---~n", []), print_dac_state(AllNodes), ok = rpc:call(Cp1, application, start, [app1]), wait_until_started(app1, [Cp1]), - test_server:format("--- App1 started at Cp1 ---~n", []), + io:format("--- App1 started at Cp1 ---~n", []), print_dac_state(AllNodes), ok = rpc:call(Cp2, application, load, [app1, App1Nodes]), ok = rpc:call(Cp2, application, start, [app1]), - test_server:format("--- App1 started at Cp2 ---~n", []), + io:format("--- App1 started at Cp2 ---~n", []), print_dac_state(AllNodes), stop_node_nice(Cp1), wait_until_started(app1, [Cp2]), - test_server:format("--- Cp1 crashed; failover to Cp2 ---~n", []), + io:format("--- Cp1 crashed; failover to Cp2 ---~n", []), print_dac_state(Cp2), stop_node_nice(Cp2), @@ -1440,7 +1397,7 @@ write_config(Fd, Config) -> print_dac_state(Node) when is_atom(Node) -> State = gen_server:call({dist_ac, Node}, info), - test_server:format(" * dist_ac state on node ~p:~n ~p~n", + io:format(" * dist_ac state on node ~p:~n ~p~n", [Node, State]); print_dac_state(Nodes) when is_list(Nodes) -> lists:foreach(fun (N) -> print_dac_state(N) end, Nodes). @@ -1450,9 +1407,7 @@ print_dac_state(Nodes) when is_list(Nodes) -> %% Ticket: OTP-4227 %% Slogan: Bad return value from application. %%----------------------------------------------------------------- -otp_4227(suite) -> []; -otp_4227(doc) -> - ["Test start of depending app when required app crashed."]; +%% Test start of depending app when required app crashed. otp_4227(Conf) when is_list(Conf) -> NodeNames = [Ncp1, Ncp2] = node_names([cp1, cp2], Conf), NoSyncTime = config_fun_fast(config_4227(NodeNames)), @@ -1475,11 +1430,11 @@ otp_4227(Conf) when is_list(Conf) -> %% Start app9 and brutally kill it, then try to start app10 ok = rpc:call(Cp1, application, start, [app9]), - test_server:sleep(1000), + ct:sleep(1000), Pid9 = rpc:call(Cp1, erlang, whereis, [ch_sup19]), true = erlang:is_pid(Pid9), true = erlang:exit(Pid9, kill), - test_server:sleep(1000), + ct:sleep(1000), %% This gave {error, no_report} before the patch {error, {not_running, app9}} = @@ -1518,7 +1473,7 @@ otp_5363(Conf) when is_list(Conf) -> %% the code, but only that the correct processes ARE killed. OldPath = code:get_path(), - code:add_patha(?config(data_dir,Conf)), + code:add_patha(proplists:get_value(data_dir,Conf)), try ok = application:load(app_group_leader()), ok = application:start(group_leader), @@ -1532,7 +1487,7 @@ otp_5363(Conf) when is_list(Conf) -> undefined = whereis(nisse); Bad -> io:format("~p\n", [Bad]), - ?t:fail() + ct:fail(failed) end after code:set_path(OldPath) @@ -1543,14 +1498,12 @@ otp_5363(Conf) when is_list(Conf) -> %% Ticket: OTP-5606 %% Slogan: Problems with starting a distributed application %%----------------------------------------------------------------- -otp_5606(suite) -> []; -otp_5606(doc) -> - ["Test of several processes simultanously starting the same " - "distributed application."]; +%% Test of several processes simultanously starting the same +%% distributed application. otp_5606(Conf) when is_list(Conf) -> %% Write a config file - Dir = ?config(priv_dir, Conf), + Dir = proplists:get_value(priv_dir, Conf), {ok, Fd} = file:open(filename:join(Dir, "sys.config"), [write]), NodeNames = [Ncp1, Ncp2] = node_names([cp1, cp2], Conf), (config4(NodeNames))(Fd, 10000), @@ -1586,7 +1539,7 @@ otp_5606(Conf) when is_list(Conf) -> [Res1, Res2, Res3, Res4] -> Txt = io_lib:format("Illegal results from start ~p ~p ~p ~p", [Res1, Res2, Res3, Res4]), - test_server:fail(lists:flatten(Txt)) + ct:fail(lists:flatten(Txt)) end, {error, {already_started, app1}} = @@ -1601,7 +1554,7 @@ otp_5606_loop(ResL) when length(ResL)<4 -> {_Pid, Res} -> otp_5606_loop([Res|ResL]) after 5000 -> - test_server:fail(timeout_waiting_for_res) + ct:fail(timeout_waiting_for_res) end; otp_5606_loop(ResL) -> ResL. @@ -1613,9 +1566,7 @@ loop5606(Pid) -> Pid ! {self(), Res} end. -get_env(suite) -> []; -get_env(doc) -> - ["Tests get_env/* functions"]; +%% Tests get_env/* functions. get_env(Conf) when is_list(Conf) -> {ok, _} = application:get_env(kernel, error_logger), undefined = application:get_env(undefined_app, a), @@ -1627,14 +1578,12 @@ get_env(Conf) when is_list(Conf) -> %% Should be started in a CC view with: %% erl -sname XXX -rsh ctrsh where XX not in [cp1, cp2, cp3] %%----------------------------------------------------------------- -get_key(suite) -> []; -get_key(doc) -> - ["Tests read the .app keys."]; +%% Tests read the .app keys. get_key(Conf) when is_list(Conf) -> NodeNames = [Ncp1, _Ncp2, _Ncp3] = node_names([cp1, cp2, cp3], Conf), WithSyncTime = config_fun(config_inc(NodeNames)), - % Test [cp1, cp2, cp3] + %% Test [cp1, cp2, cp3] {ok, Cp1} = start_node_config(Ncp1, WithSyncTime, Conf), ok = rpc:call(Cp1, application, load, [appinc(), d3(NodeNames)]), @@ -1731,8 +1680,7 @@ get_key(Conf) when is_list(Conf) -> %%% Testing of change of distributed parameter. %%%----------------------------------------------------------------- -distr_changed_tc1(suite) -> []; -distr_changed_tc1(doc) -> ["Test change of distributed parameter."]; +%% Test change of distributed parameter. distr_changed_tc1(Conf) when is_list(Conf) -> {OldKernel, OldEnv, {Cp1, Cp2, Cp3}, {_Ncp1, _Ncp2, _Ncp3}, _Config2} = @@ -1757,7 +1705,7 @@ distr_changed_tc1(Conf) when is_list(Conf) -> rpc:multicall([Cp1, Cp2, Cp3], application_controller, config_change, [OldEnv]), - test_server:sleep(7000), + ct:sleep(7000), DcInfo1 = rpc:call(Cp1, dist_ac, info, []), DcInfo2 = rpc:call(Cp2, dist_ac, info, []), @@ -1778,7 +1726,7 @@ distr_changed_tc1(Conf) when is_list(Conf) -> ok; EWa1 -> X1 = io_lib:format("distribution error: Cp1 ~p ",[EWa1]), - test_server:fail(lists:flatten(X1)) + ct:fail(lists:flatten(X1)) end, case lists:sort(Wa2) of @@ -1786,7 +1734,7 @@ distr_changed_tc1(Conf) when is_list(Conf) -> ok; EWa2 -> X2 = io_lib:format("distribution error: Cp2 ~p ",[EWa2]), - test_server:fail(lists:flatten(X2)) + ct:fail(lists:flatten(X2)) end, case lists:sort(Wa3) of @@ -1794,7 +1742,7 @@ distr_changed_tc1(Conf) when is_list(Conf) -> ok; EWa3 -> X3 = io_lib:format("distribution error: Cp3 ~p ",[EWa3]), - test_server:fail(lists:flatten(X3)) + ct:fail(lists:flatten(X3)) end, DcInfo1n = rpc:call(Cp1, dist_ac, info, []), @@ -1816,9 +1764,7 @@ distr_changed_tc1(Conf) when is_list(Conf) -> ok. -distr_changed_tc2(suite) -> []; -distr_changed_tc2(doc) -> ["Test change of distributed parameter, " - "move appls by crashing a node."]; +%% Test change of distributed parameter, move appls by crashing a node. distr_changed_tc2(Conf) when is_list(Conf) -> {OldKernel, OldEnv, {Cp1, Cp2, Cp3}, {Ncp1, _Ncp2, _Ncp3}, Config2} = @@ -1843,21 +1789,16 @@ distr_changed_tc2(Conf) when is_list(Conf) -> rpc:multicall([Cp1, Cp2, Cp3], application_controller, config_change, [OldEnv]), - test_server:sleep(4000), + ct:sleep(4000), stop_node_nice(Cp1), - test_server:sleep(10000), + ct:sleep(10000), -% _DcInfo1 = rpc:call(Cp1, dist_ac, info, []), _DcInfo2 = rpc:call(Cp2, dist_ac, info, []), _DcInfo3 = rpc:call(Cp3, dist_ac, info, []), -% ?t:format(0,"#### DcInfo1 ~n~p~n",[_DcInfo1]), -% DcWa1 = which_applications(Cp1), DcWa2 = which_applications(Cp2), DcWa3 = which_applications(Cp3), -% Wa1 = lists:foldl(fun({A1, _N1, _V1}, AccIn) -> [A1 | AccIn] end, -% [], DcWa1), Wa2 = lists:foldl(fun({A2, _N2, _V2}, AccIn) -> [A2 | AccIn] end, [], DcWa2), Wa3 = lists:foldl(fun({A3, _N3, _V3}, AccIn) -> [A3 | AccIn] end, @@ -1869,7 +1810,7 @@ distr_changed_tc2(Conf) when is_list(Conf) -> ok; EWa2 -> X2 = io_lib:format("distribution error: Cp2 ~p ",[EWa2]), - test_server:fail(lists:flatten(X2)) + ct:fail(lists:flatten(X2)) end, case lists:sort(Wa3) of @@ -1877,12 +1818,12 @@ distr_changed_tc2(Conf) when is_list(Conf) -> ok; EWa3 -> X3 = io_lib:format("distribution error: Cp3 ~p ",[EWa3]), - test_server:fail(lists:flatten(X3)) + ct:fail(lists:flatten(X3)) end, {ok, Cp1} = start_node_boot(Ncp1, Config2, dc), - test_server:sleep(10000), + ct:sleep(10000), _DcInfo1rs = rpc:call(Cp1, dist_ac, info, []), _DcInfo2rs = rpc:call(Cp2, dist_ac, info, []), @@ -1904,7 +1845,7 @@ distr_changed_tc2(Conf) when is_list(Conf) -> ok; EWa1rs -> X1rs = io_lib:format("distribution error: Cp1 ~p ",[EWa1rs]), - test_server:fail(lists:flatten(X1rs)) + ct:fail(lists:flatten(X1rs)) end, case lists:sort(Wa2rs) of @@ -1912,7 +1853,7 @@ distr_changed_tc2(Conf) when is_list(Conf) -> ok; EWa2rs -> X2rs = io_lib:format("distribution error: Cp2 ~p ",[EWa2rs]), - test_server:fail(lists:flatten(X2rs)) + ct:fail(lists:flatten(X2rs)) end, case lists:sort(Wa3rs) of @@ -1920,7 +1861,7 @@ distr_changed_tc2(Conf) when is_list(Conf) -> ok; EWa3rs -> X3rs = io_lib:format("distribution error: Cp3 ~p ",[EWa3rs]), - test_server:fail(lists:flatten(X3rs)) + ct:fail(lists:flatten(X3rs)) end, @@ -1939,15 +1880,12 @@ distr_changed_tc2(Conf) when is_list(Conf) -> %%%----------------------------------------------------------------- %%% Testing of application configuration change %%%----------------------------------------------------------------- -config_change(suite) -> - []; -config_change(doc) -> - ["Test change of application configuration"]; +%% Test change of application configuration. config_change(Conf) when is_list(Conf) -> %% Change to data_dir {ok, CWD} = file:get_cwd(), - DataDir = ?config(data_dir, Conf), + DataDir = proplists:get_value(data_dir, Conf), ok = file:set_cwd(DataDir), %% Find out application data from boot script @@ -2009,10 +1947,7 @@ get_appls([], Res) -> Res. -persistent_env(suite) -> - []; -persistent_env(doc) -> - ["Test set_env/4 and unset_env/3 with persistent true"]; +%% Test set_env/4 and unset_env/3 with persistent true. persistent_env(Conf) when is_list(Conf) -> ok = application:set_env(appinc, own2, persist, [{persistent, true}]), ok = application:set_env(appinc, key1, persist, [{persistent, true}]), @@ -2056,10 +1991,7 @@ persistent_env(Conf) when is_list(Conf) -> %%%----------------------------------------------------------------- %%% Tests the 'shutdown_func' kernel config parameter %%%----------------------------------------------------------------- -shutdown_func(suite) -> - []; -shutdown_func(doc) -> - ["Tests the 'shutdown_func' kernel config parameter"]; +%% Tests the 'shutdown_func' kernel config parameter. shutdown_func(Config) when is_list(Config) -> {ok,Cp1} = start_node(?MODULE_STRING++"_shutdown_func"), wait_for_ready_net(), @@ -2077,10 +2009,10 @@ shutdown_func(Config) when is_list(Config) -> {'DOWN', Mref, _, Pid, noconnection} -> ok after 10000 -> - test_server:fail(timeout) + ct:fail(timeout) end after 10000 -> - test_server:fail(timeout) + ct:fail(timeout) end. @@ -2098,7 +2030,7 @@ do_shutdown(Reason) -> %%% Tests the 'shutdown_timeout' kernel config parameter %%%----------------------------------------------------------------- shutdown_timeout(Config) when is_list(Config) -> - DataDir = ?config(data_dir,Config), + DataDir = proplists:get_value(data_dir,Config), {ok,Cp1} = start_node(?MODULE_STRING++"_shutdown_timeout"), wait_for_ready_net(), ok = rpc:call(Cp1, application, set_env, [kernel, shutdown_timeout, 1000]), @@ -2121,7 +2053,7 @@ shutdown_timeout(Config) when is_list(Config) -> %%% Provokes a (previous) application shutdown deadlock %%%----------------------------------------------------------------- shutdown_deadlock(Config) when is_list(Config) -> - DataDir = ?config(data_dir,Config), + DataDir = proplists:get_value(data_dir,Config), code:add_path(filename:join([DataDir,deadlock])), %% ok = rpc:call(Cp1, application, start, [sasl]), ok = application:start(deadlock), @@ -2596,7 +2528,7 @@ is_started(Name, Node) -> false -> false end. -% Waits until application Name is started on at least one node. +%% Waits until application Name is started on at least one node. wait_until_started(Name, Nodes) -> case lists:member(true, lists:map(fun (N) -> @@ -2606,11 +2538,11 @@ wait_until_started(Name, Nodes) -> true -> true; false -> - test_server:sleep(500), + ct:sleep(500), wait_until_started(Name, Nodes) end. -% Waits until application Name is stopped on all nodes. +%% Waits until application Name is stopped on all nodes. wait_until_stopped(Name, Nodes) -> case lists:member(true, lists:map(fun (N) -> @@ -2620,7 +2552,7 @@ wait_until_stopped(Name, Nodes) -> false -> true; true -> - test_server:sleep(500), + ct:sleep(500), wait_until_stopped(Name, Nodes) end. @@ -2662,13 +2594,13 @@ start_node_args(Name, Args) -> start_node_boot_3002(Name, Boot) -> Pa = filename:dirname(code:which(?MODULE)), - ?t:format(0, "start_node_boot ~p~n", - [" -pa " ++ Pa ++ " -env ERL_CRASH_DUMP erl_crash_dump." ++ - atom_to_list(Name) ++ " -boot " ++ Boot ++ - " -sasl dummy \"missing "]), + ct:pal(?HI_VERBOSITY, "start_node_boot ~p~n", + [" -pa " ++ Pa ++ " -env ERL_CRASH_DUMP erl_crash_dump." ++ + atom_to_list(Name) ++ " -boot " ++ Boot ++ + " -sasl dummy \"missing "]), test_server:start_node(Name, slave, [{args, " -pa " ++ Pa ++ - " -env ERL_CRASH_DUMP erl_crash_dump." ++ + " -env ERL_CRASH_DUMP erl_crash_dump." ++ atom_to_list(Name) ++ " -boot " ++ Boot ++ " -sasl dummy \"missing "}]). @@ -2678,18 +2610,20 @@ start_node_boot_config(Name, SysConfigFun, Conf, Boot) -> start_node_boot(Name, Config, Boot) -> Pa = filename:dirname(code:which(?MODULE)), - ?t:format(0, "start_node_boot ~p~n",[" -pa " ++ Pa ++ " -config " ++ Config ++ - " -boot " ++ atom_to_list(Boot)]), - test_server:start_node(Name, slave, [{args, " -pa " ++ Pa ++ " -config " ++ Config ++ - " -boot " ++ atom_to_list(Boot)}]). + ct:pal(?HI_VERBOSITY, + "start_node_boot ~p~n",[" -pa " ++ Pa ++ " -config " ++ Config ++ + " -boot " ++ atom_to_list(Boot)]), + test_server:start_node(Name, slave, + [{args, " -pa " ++ Pa ++ " -config " ++ Config ++ + " -boot " ++ atom_to_list(Boot)}]). start_node_config_sf(Name, SysConfigFun, Conf) -> ConfigFile = write_config_file(SysConfigFun, Conf), - DataDir = ?config(data_dir, Conf), % is it used? + DataDir = proplists:get_value(data_dir, Conf), % is it used? start_node(Name, ConfigFile, " -pa " ++ DataDir). write_config_file(SysConfigFun, Conf) -> - Dir = ?config(priv_dir, Conf), + Dir = proplists:get_value(priv_dir, Conf), {ok, Fd} = file:open(filename:join(Dir, "sys.config"), [write]), SysConfigFun(Fd), file:close(Fd), @@ -2713,8 +2647,8 @@ get_start_type(Expected) -> get_start_type(Expected, 30*5, #st{}). get_start_type(_Expected, 0, Ack) -> - test_server:format("====== ~p ======~n", [Ack]), - test_server:fail(not_valid_start_type); + io:format("====== ~p ======~n", [Ack]), + ct:fail(not_valid_start_type); get_start_type(Expected, Times, Ack0) -> #st{normal = N0, local = L0, takeover = T0, failover = F0} = Ack0, global:send(st_type, {st, read, self()}), @@ -2760,13 +2694,13 @@ get_start_phase(Expected) -> Expected -> ok; {sp, T1, I1, So1, Sp1, G1} -> - test_server:format("=============== {sp,T,I,So,Sp,G} ~p ~n",[" "]), - test_server:format("=========== got ~p ~n", + io:format("=============== {sp,T,I,So,Sp,G} ~p ~n",[" "]), + io:format("=========== got ~p ~n", [{sp, T1, I1, So1, Sp1, G1}]), - test_server:format("====== expected ~p ~n", [Expected]), - test_server:fail(not_valid_start_phase) + io:format("====== expected ~p ~n", [Expected]), + ct:fail(not_valid_start_phase) after 5000 -> - test_server:fail(not_valid_start_phase) + ct:fail(not_valid_start_phase) end. start_phase() -> @@ -2797,10 +2731,10 @@ get_conf_change(Expected) -> {cc, Expected} -> ok; {cc, List} -> - test_server:format("====== ~p ======~n",[{cc, List}]), - test_server:fail(not_valid_conf_change) + io:format("====== ~p ======~n",[{cc, List}]), + ct:fail(not_valid_conf_change) after 5000 -> - test_server:fail(not_valid_conf_change_to) + ct:fail(not_valid_conf_change_to) end. conf_change() -> @@ -2896,7 +2830,7 @@ create_script_3002(ScriptName) -> distr_changed_prep(Conf) when is_list(Conf) -> - % Write .app files + %% Write .app files {ok, Fd1} = file:open("app1.app", [write]), w_app1(Fd1), file:close(Fd1), @@ -2917,7 +2851,7 @@ distr_changed_prep(Conf) when is_list(Conf) -> file:close(Fd6), - % Create the .app files and the boot script + %% Create the .app files and the boot script {{KernelVer,StdlibVer}, _} = create_script_dc("dc"), case is_real_system(KernelVer, StdlibVer) of @@ -2933,13 +2867,13 @@ distr_changed_prep(Conf) when is_list(Conf) -> NoSyncTime = config_fun_fast(config_dc(NodeNames)), WithSyncTime = config_fun(config_dc(NodeNames)), - Dir = ?config(priv_dir,Conf), + Dir = proplists:get_value(priv_dir,Conf), {ok, Fd_dc2} = file:open(filename:join(Dir, "sys2.config"), [write]), (config_dc2(NodeNames))(Fd_dc2), file:close(Fd_dc2), Config2 = filename:join(Dir, "sys2"), - % Test [cp1, cp2, cp3] + %% Test [cp1, cp2, cp3] {ok, Cp1} = start_node_boot_config(Ncp1, NoSyncTime, Conf, dc), {ok, Cp2} = start_node_boot_config(Ncp2, NoSyncTime, Conf, dc), {ok, Cp3} = start_node_boot_config(Ncp3, WithSyncTime, Conf, dc), |