aboutsummaryrefslogtreecommitdiffstats
path: root/lib/snmp/test
diff options
context:
space:
mode:
Diffstat (limited to 'lib/snmp/test')
-rw-r--r--lib/snmp/test/snmp_manager_test.erl60
-rw-r--r--lib/snmp/test/snmp_manager_user.erl21
2 files changed, 69 insertions, 12 deletions
diff --git a/lib/snmp/test/snmp_manager_test.erl b/lib/snmp/test/snmp_manager_test.erl
index 986c324179..d638047701 100644
--- a/lib/snmp/test/snmp_manager_test.erl
+++ b/lib/snmp/test/snmp_manager_test.erl
@@ -80,6 +80,7 @@
simple_sync_set1/1,
simple_sync_set2/1,
+ simple_sync_set3/1,
simple_async_set1/1,
simple_async_set2/1,
@@ -243,7 +244,8 @@ init_per_testcase3(Case, Config) ->
simple_sync_get3,
simple_async_get3,
simple_sync_get_next3,
- simple_async_get_next3
+ simple_async_get_next3,
+ simple_sync_set3
],
Cases =
[
@@ -332,7 +334,8 @@ end_per_testcase2(Case, Config) ->
simple_sync_get3,
simple_async_get3,
simple_sync_get_next3,
- simple_async_get_next3
+ simple_async_get_next3,
+ simple_sync_set3
],
Cases =
[
@@ -441,6 +444,7 @@ groups() ->
[
simple_sync_set1,
simple_sync_set2,
+ simple_sync_set3,
simple_async_set1,
simple_async_set2
]
@@ -2353,7 +2357,17 @@ simple_sync_set2(Config) when is_list(Config) ->
put(tname, sss2),
p("starting with Config: ~p~n", [Config]),
- Node = ?config(manager_node, Config),
+ Set = fun(Node, TargetName, VAVs) ->
+ mgr_user_sync_set(Node, TargetName, VAVs)
+ end,
+ PostVerify = fun() -> ok end,
+
+ do_simple_sync_set2(Config, Set, PostVerify).
+
+do_simple_sync_set2(Config, Set, PostVerify)
+ when is_function(Set, 3) andalso is_function(PostVerify, 0) ->
+
+ Node = ?config(manager_node, Config),
TargetName = ?config(manager_agent_target_name, Config),
p("issue set-request without loading the mib"),
@@ -2363,7 +2377,7 @@ simple_sync_set2(Config) when is_list(Config) ->
{?sysName_instance, s, Val11},
{?sysLocation_instance, s, Val12}
],
- ?line ok = do_simple_set2(Node, TargetName, VAVs1),
+ ?line ok = do_simple_set2(Node, TargetName, VAVs1, Set, PostVerify),
p("issue set-request after first loading the mibs"),
?line ok = mgr_user_load_mib(Node, std_mib()),
@@ -2373,12 +2387,12 @@ simple_sync_set2(Config) when is_list(Config) ->
{[sysName, 0], Val21},
{[sysLocation, 0], Val22}
],
- ?line ok = do_simple_set2(Node, TargetName, VAVs2),
+ ?line ok = do_simple_set2(Node, TargetName, VAVs2, Set, PostVerify),
ok.
-do_simple_set2(Node, TargetName, VAVs) ->
+do_simple_set2(Node, TargetName, VAVs, Set, PostVerify) ->
[SysName, SysLoc] = value_of_vavs(VAVs),
- ?line {ok, Reply, Rem} = mgr_user_sync_set(Node, TargetName, VAVs),
+ ?line {ok, Reply, Rem} = Set(Node, TargetName, VAVs),
?DBG("~n Reply: ~p"
"~n Rem: ~w", [Reply, Rem]),
@@ -2391,7 +2405,7 @@ do_simple_set2(Node, TargetName, VAVs) ->
value = SysName},
#varbind{oid = ?sysLocation_instance,
value = SysLoc}]} ->
- ok;
+ PostVerify();
{noError, 0, Vbs} ->
{error, {unexpected_vbs, Vbs}};
Else ->
@@ -2403,6 +2417,33 @@ do_simple_set2(Node, TargetName, VAVs) ->
%%======================================================================
+simple_sync_set3(doc) ->
+ ["Simple (sync) set-request - Version 3 API (TargetName with send-opts)"];
+simple_sync_set3(suite) -> [];
+simple_sync_set3(Config) when is_list(Config) ->
+ process_flag(trap_exit, true),
+ put(tname, sss3),
+ p("starting with Config: ~p~n", [Config]),
+
+ Self = self(),
+ Msg = simple_sync_set3,
+ Fun = fun() -> Self ! Msg end,
+ Extra = {?SNMPM_EXTRA_INFO_TAG, Fun},
+ SendOpts =
+ [
+ {extra, Extra}
+ ],
+
+ Set = fun(Node, TargetName, VAVs) ->
+ mgr_user_sync_set2(Node, TargetName, VAVs, SendOpts)
+ end,
+ PostVerify = fun() -> receive Msg -> ok end end,
+
+ do_simple_sync_set2(Config, Set, PostVerify).
+
+
+%%======================================================================
+
simple_async_set1(doc) -> ["Simple (async) set-request - "
"Old style (Addr & Port)"];
simple_async_set1(suite) -> [];
@@ -5284,6 +5325,9 @@ mgr_user_sync_set(Node, Addr_or_TargetName, VAV) ->
mgr_user_sync_set(Node, Addr, Port, VAV) ->
rcall(Node, snmp_manager_user, sync_set, [Addr, Port, VAV]).
+mgr_user_sync_set2(Node, TargetName, VAV, SendOpts) ->
+ rcall(Node, snmp_manager_user, sync_set2, [TargetName, VAV, SendOpts]).
+
%% mgr_user_async_set(Node, VAV) ->
%% mgr_user_async_set(Node, ?LOCALHOST(), ?AGENT_PORT, VAV).
mgr_user_async_set(Node, Addr_or_TargetName, VAV) ->
diff --git a/lib/snmp/test/snmp_manager_user.erl b/lib/snmp/test/snmp_manager_user.erl
index cb3f57ad1c..7c4bdbfb0a 100644
--- a/lib/snmp/test/snmp_manager_user.erl
+++ b/lib/snmp/test/snmp_manager_user.erl
@@ -54,7 +54,7 @@
async_get/1, async_get/2, async_get/3, async_get2/3,
sync_get_next/1, sync_get_next/2, sync_get_next/3, sync_get_next2/3,
async_get_next/1, async_get_next/2, async_get_next/3, async_get_next2/3,
- sync_set/1, sync_set/2, sync_set/3,
+ sync_set/1, sync_set/2, sync_set/3, sync_set2/3,
async_set/1, async_set/2, async_set/3,
sync_get_bulk/3, sync_get_bulk/4, sync_get_bulk/5,
async_get_bulk/3, async_get_bulk/4, async_get_bulk/5,
@@ -228,6 +228,9 @@ sync_set(Addr_or_TargetName, VAV) ->
sync_set(Addr, Port, VAV) ->
call({sync_set, Addr, Port, VAV}).
+sync_set2(TargetName, VAV, SendOpts) ->
+ call({sync_set2, TargetName, VAV, SendOpts}).
+
%% --
async_set(VAV) ->
@@ -464,7 +467,7 @@ loop(#state{parent = Parent, id = Id} = S) ->
{{async_get2, TargetName, Oids, SendOpts}, From, Ref}
when is_list(TargetName) ->
- d("loop -> received async_get request with"
+ d("loop -> received async_get2 request with"
"~n TargetName: ~p"
"~n Oids: ~p"
"~n SendOpts: ~p", [TargetName, Oids, SendOpts]),
@@ -507,7 +510,7 @@ loop(#state{parent = Parent, id = Id} = S) ->
{{sync_get_next2, TargetName, Oids, SendOpts}, From, Ref}
when is_list(TargetName) ->
- d("loop -> received sync_get_next request with"
+ d("loop -> received sync_get_next2 request with"
"~n TargetName: ~p"
"~n Oids: ~p"
"~n SendOpts: ~p", [TargetName, Oids, SendOpts]),
@@ -550,7 +553,7 @@ loop(#state{parent = Parent, id = Id} = S) ->
{{async_get_next2, TargetName, Oids, SendOpts}, From, Ref}
when is_list(TargetName) ->
- d("loop -> received async_get_next request with"
+ d("loop -> received async_get_next2 request with"
"~n TargetName: ~p"
"~n Oids: ~p"
"~n SendOpts: ~p", [TargetName, Oids, SendOpts]),
@@ -591,6 +594,16 @@ loop(#state{parent = Parent, id = Id} = S) ->
%% -- (sync) set-request --
%%
+ {{sync_set2, TargetName, VAV, SendOpts}, From, Ref}
+ when is_list(TargetName) ->
+ d("loop -> received sync_set2 request with"
+ "~n TargetName: ~p"
+ "~n VAV: ~p"
+ "~n SendOpts: ~p", [TargetName, VAV, SendOpts]),
+ Res = snmpm:sync_set2(Id, TargetName, VAV, SendOpts),
+ reply(From, Res, Ref),
+ loop(S);
+
{{sync_set, VAV}, From, Ref} ->
d("loop -> received sync_set request"),
Res = [snmpm:sync_set(Id, TargetName, VAV) ||