File 0375-snmp-agent-test-Request-response-timeout.patch of Package erlang
From e4080b74808e054687d054b108cf1c94129d22cd Mon Sep 17 00:00:00 2001
From: Micael Karlberg <bmk@erlang.org>
Date: Mon, 11 Apr 2022 18:57:40 +0200
Subject: [PATCH 1/2] [snmp|agent|test] Request response timeout
Make the (request) response timeout adapt to the host
using the snmp_factor.
Also if a timeout occurs; display the content of the
message queue.
---
lib/snmp/test/snmp_agent_test_lib.erl | 16 ++++++++++++++++
lib/snmp/test/snmp_test_mgr.erl | 5 +++--
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/lib/snmp/test/snmp_agent_test_lib.erl b/lib/snmp/test/snmp_agent_test_lib.erl
index 41e656e7dc..3877123b37 100644
--- a/lib/snmp/test/snmp_agent_test_lib.erl
+++ b/lib/snmp/test/snmp_agent_test_lib.erl
@@ -299,6 +299,8 @@ init_case(Config) when is_list(Config) ->
put(masterip, tuple_to_list(MasterIP)),
put(sip, tuple_to_list(SIP)),
put(ipfamily, IpFamily),
+
+ put(receive_response_timeout, receive_response_timeout(Config)),
MibDir = ?config(mib_dir, Config),
put(mib_dir, MibDir),
@@ -319,6 +321,20 @@ init_case(Config) when is_list(Config) ->
{SaNode, MgrNode, MibDir}.
+receive_response_timeout(Config) ->
+ case lists:keysearch(snmp_factor, 1, Config) of
+ {value, {snmp_factor, F}} when (F < 4) ->
+ ?SECS(5);
+ {value, {snmp_factor, F}} when (F < 6) ->
+ ?SECS(10);
+ {value, {snmp_factor, F}} when (F < 8) ->
+ ?SECS(15);
+ {value, {snmp_factor, _}} ->
+ ?SECS(20);
+ _ ->
+ ?SECS(10)
+ end.
+
%%%--------------------------------------------------
%%% Used to test the standard mib with our
%%% configuration.
diff --git a/lib/snmp/test/snmp_test_mgr.erl b/lib/snmp/test/snmp_test_mgr.erl
index d9caa15cdb..054e7ea108 100644
--- a/lib/snmp/test/snmp_test_mgr.erl
+++ b/lib/snmp/test/snmp_test_mgr.erl
@@ -147,7 +147,7 @@ receive_response() ->
receive_response(get_timeout()).
receive_response(Timeout) ->
- d("await response within ~w ms",[Timeout]),
+ d("await response within ~w ms", [Timeout]),
receive
{snmp_pdu, PDU} when is_record(PDU, pdu) ->
d("[await response] received PDU: "
@@ -158,7 +158,8 @@ receive_response(Timeout) ->
"~n ~p", [Reason]),
ERROR
after Timeout ->
- ?EPRINT("[await response] unexpected timeout"),
+ ?EPRINT("[await response] unexpected timeout: "
+ "~n ~p", [process_info(self(), messages)]),
{error, timeout}
end.
--
2.34.1