aboutsummaryrefslogtreecommitdiffstats
path: root/lib/snmp
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2019-07-22 19:38:40 +0200
committerMicael Karlberg <[email protected]>2019-07-23 11:50:35 +0200
commit1f581d6cd85759a83ab641e1a382e4ae55bae8cc (patch)
tree62cc412396e1ce1bfdec9482e24cdcc46a0d314a /lib/snmp
parentfa1684afd7a2fca598e6d5d366df3fc18a8953a1 (diff)
downloadotp-1f581d6cd85759a83ab641e1a382e4ae55bae8cc.tar.gz
otp-1f581d6cd85759a83ab641e1a382e4ae55bae8cc.tar.bz2
otp-1f581d6cd85759a83ab641e1a382e4ae55bae8cc.zip
[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.
Diffstat (limited to 'lib/snmp')
-rw-r--r--lib/snmp/test/snmp_manager_test.erl33
1 files changed, 29 insertions, 4 deletions
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) -> [];