From 1f581d6cd85759a83ab641e1a382e4ae55bae8cc Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Mon, 22 Jul 2019 19:38:40 +0200 Subject: [snmp|manager|test] Notify started (test case) adjustments We have seen one case when it takes unreasonably long time to start the manager, which causes the test case (notify_started01) to fail. We try to monitor the start, and if it takes to long a time, we instead skip. --- lib/snmp/test/snmp_manager_test.erl | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'lib/snmp/test') diff --git a/lib/snmp/test/snmp_manager_test.erl b/lib/snmp/test/snmp_manager_test.erl index 7cd3eae0c7..2546ee7edd 100644 --- a/lib/snmp/test/snmp_manager_test.erl +++ b/lib/snmp/test/snmp_manager_test.erl @@ -1023,10 +1023,10 @@ notify_started02(Config) when is_list(Config) -> write_manager_conf(ConfDir), - Opts = [{server, [{verbosity, log}]}, - {net_if, [{verbosity, silence}]}, + Opts = [{server, [{verbosity, log}]}, + {net_if, [{verbosity, silence}]}, {note_store, [{verbosity, silence}]}, - {config, [{verbosity, log}, {dir, ConfDir}, {db_dir, DbDir}]}], + {config, [{verbosity, debug}, {dir, ConfDir}, {db_dir, DbDir}]}], p("start snmpm client process"), NumIterations = 5, @@ -1056,8 +1056,14 @@ notify_started02(Config) when is_list(Config) -> p("await snmpm client process exit (max ~p+10000 msec)", [ApproxStartTime]), receive + %% We take this opportunity to check if we got a skip from + %% the ctrl process. + {'EXIT', Pid2, {skip, SkipReason1}} -> + ?SKIP(SkipReason1); {'EXIT', Pid1, normal} -> ok; + {'EXIT', Pid1, {suite_failed, Reason1}} -> + ?FAIL({client, Reason1}); {'EXIT', Pid1, Reason1} -> ?FAIL({client, Reason1}) after ApproxStartTime + 10000 -> @@ -1070,6 +1076,9 @@ notify_started02(Config) when is_list(Config) -> receive {'EXIT', Pid2, normal} -> ok; + {'EXIT', Pid2, {skip, SkipReason2}} -> + %% In case of a race + ?SKIP(SkipReason2); {'EXIT', Pid2, Reason2} -> ?FAIL({ctrl, Reason2}) after 5000 -> @@ -1159,6 +1168,12 @@ ns02_ctrl(Opts, N) -> p("starting"), ns02_ctrl_loop(Opts, N). + +%% We have seen that some times it takes unreasonably long time to +%% start the manager (it got "stuck" in snmpm_config). But since +%% we did not have enough verbosity, we do not know how far it got. +%% So, we try to monitor each start attempt. We allow 5 sec (just +%% to give slow boxes a chance). ns02_ctrl_loop(_Opts, 0) -> p("done"), exit(normal); @@ -1166,13 +1181,23 @@ ns02_ctrl_loop(Opts, N) -> p("entry when N: ~p", [N]), ?SLEEP(2000), p("start manager"), - snmpm:start(Opts), + %% snmpm:start(Opts), + {Pid, MRef} = erlang:spawn_monitor(fun() -> exit(snmpm:start(Opts)) end), + receive + {'DOWN', MRef, process, Pid, ok} -> + ok + after 5000 -> + p("start manager (~p) timeout - kill"), + exit(Pid, kill), + exit({skip, timeout}) + end, ?SLEEP(2000), p("stop manager"), snmpm:stop(), ns02_ctrl_loop(Opts, N-1). + %%====================================================================== info(suite) -> []; -- cgit v1.2.3 From bf89fa2a64d5df1a1701e12bbc13d1825a12df2a Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Tue, 23 Jul 2019 16:21:12 +0200 Subject: [snmp|manager|test] Fixed notify test case The (second) notify test case had a faulty "condition" test (which skipped the case in all cases except when it was supposed to be skipped :) Also, the test start and stop of the manager during the test case has been adjusted. We try to keep track of how long time each start and stop takes. And also, if they takes to long, we skip the case. --- lib/snmp/test/snmp_manager_test.erl | 44 +++++++++++++++++++++++-------------- lib/snmp/test/snmp_test_lib.erl | 5 ++++- 2 files changed, 32 insertions(+), 17 deletions(-) (limited to 'lib/snmp/test') diff --git a/lib/snmp/test/snmp_manager_test.erl b/lib/snmp/test/snmp_manager_test.erl index 2546ee7edd..d49ab53c9f 100644 --- a/lib/snmp/test/snmp_manager_test.erl +++ b/lib/snmp/test/snmp_manager_test.erl @@ -990,25 +990,23 @@ notify_started02(Config) when is_list(Config) -> %% %% The point of this is to catch machines running - %% SLES9 (2.6.5) + %% SLES9 (2.6.5). LinuxVersionVerify = fun() -> case os:cmd("uname -m") of "i686" ++ _ -> -%% io:format("found an i686 machine, " -%% "now check version~n", []), case os:version() of {2, 6, Rev} when Rev >= 16 -> - true; + false; {2, Min, _} when Min > 6 -> - true; + false; {Maj, _, _} when Maj > 2 -> - true; + false; _ -> - false + true end; _ -> - true + false end end, Skippable = [{unix, [{linux, LinuxVersionVerify}]}], @@ -1103,7 +1101,7 @@ ns02_client_await_approx_runtime(Pid) -> "~n ~p", [Pid, Reason]), {error, Reason} - after 15000 -> + after 30000 -> %% Either something is *really* wrong or this machine %% is dog slow. Either way, this is a skip-reason... {skip, approx_runtime_timeout} @@ -1181,19 +1179,33 @@ ns02_ctrl_loop(Opts, N) -> p("entry when N: ~p", [N]), ?SLEEP(2000), p("start manager"), - %% snmpm:start(Opts), - {Pid, MRef} = erlang:spawn_monitor(fun() -> exit(snmpm:start(Opts)) end), + TS1 = erlang:system_time(millisecond), + {StarterPid, StarterMRef} = + erlang:spawn_monitor(fun() -> exit(snmpm:start(Opts)) end), receive - {'DOWN', MRef, process, Pid, ok} -> + {'DOWN', StarterMRef, process, StarterPid, ok} -> + TS2 = erlang:system_time(millisecond), + p("manager started: ~w ms", [TS2-TS1]), ok after 5000 -> - p("start manager (~p) timeout - kill"), - exit(Pid, kill), - exit({skip, timeout}) + p("manager (~p) start timeout - kill", [StarterPid]), + exit(StarterPid, kill), + exit({skip, start_timeout}) end, ?SLEEP(2000), p("stop manager"), - snmpm:stop(), + ?SLEEP(100), % Give the verbosity to take effect... + TS3 = erlang:system_time(millisecond), + case snmpm:stop(5000) of + ok -> + TS4 = erlang:system_time(millisecond), + p("manager stopped: ~p ms", [TS4-TS3]), + ok; + {error, timeout} -> + p("manager stop timeout - kill (cleanup) and skip"), + exit(whereis(snmpm_supervisor), kill), + exit({skip, stop_timeout}) + end, ns02_ctrl_loop(Opts, N-1). diff --git a/lib/snmp/test/snmp_test_lib.erl b/lib/snmp/test/snmp_test_lib.erl index 35bc535a80..a05040e281 100644 --- a/lib/snmp/test/snmp_test_lib.erl +++ b/lib/snmp/test/snmp_test_lib.erl @@ -202,11 +202,14 @@ non_pc_tc_maybe_skip(Config, Condition, File, Line) %% test-server... ok; _ -> - case Condition() of + try Condition() of true -> skip(non_pc_testcase, File, Line); false -> ok + catch + C:E:S -> + skip({condition, C, E, S}, File, Line) end end end. -- cgit v1.2.3