From 5c2be4d01720a8833fe8e8b71e25ffe946026771 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Thu, 20 Sep 2012 17:00:03 +0200 Subject: [common_test] Add minor test suite for ct_snmp --- lib/common_test/test/Makefile | 4 +- lib/common_test/test/ct_snmp_SUITE.erl | 152 +++++++++++++++++++++++++++++++++ lib/common_test/test/snmp.cfg | 21 +++++ 3 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 lib/common_test/test/ct_snmp_SUITE.erl create mode 100644 lib/common_test/test/snmp.cfg (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/Makefile b/lib/common_test/test/Makefile index 686ee43aa3..33f47e3baf 100644 --- a/lib/common_test/test/Makefile +++ b/lib/common_test/test/Makefile @@ -51,7 +51,8 @@ MODULES= \ ct_basic_html_SUITE \ ct_auto_compile_SUITE \ ct_verbosity_SUITE \ - ct_shell_SUITE + ct_shell_SUITE \ + ct_snmp_SUITE ERL_FILES= $(MODULES:%=%.erl) @@ -106,6 +107,7 @@ release_tests_spec: $(INSTALL_DIR) "$(RELSYSDIR)" $(INSTALL_DATA) $(ERL_FILES) $(COVERFILE) "$(RELSYSDIR)" $(INSTALL_DATA) common_test.spec "$(RELSYSDIR)" + $(INSTALL_DATA) snmp.cfg "$(RELSYSDIR)" chmod -R u+w "$(RELSYSDIR)" @tar cf - *_SUITE_data | (cd "$(RELSYSDIR)"; tar xf -) diff --git a/lib/common_test/test/ct_snmp_SUITE.erl b/lib/common_test/test/ct_snmp_SUITE.erl new file mode 100644 index 0000000000..9e4bbedcfb --- /dev/null +++ b/lib/common_test/test/ct_snmp_SUITE.erl @@ -0,0 +1,152 @@ +%%-------------------------------------------------------------------- +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2012. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%%---------------------------------------------------------------------- +%% File: ct_snmp_SUITE.erl +%% +%% Description: +%% This file contains the test cases for the ct_snmp API. +%% +%% @author Support +%% @doc Test of SNMP support in common_test +%% @end +%%---------------------------------------------------------------------- +%%---------------------------------------------------------------------- +-module(ct_snmp_SUITE). +-include_lib("common_test/include/ct.hrl"). +-include_lib("snmp/include/STANDARD-MIB.hrl"). +-include_lib("snmp/include/snmp_types.hrl"). + +-compile(export_all). + +%% Default timetrap timeout (set in init_per_testcase). +-define(default_timeout, ?t:minutes(1)). + +%% SNMP user stuff +-behaviour(snmpm_user). +-export([handle_error/3, + handle_agent/5, + handle_pdu/4, + handle_trap/3, + handle_inform/3, + handle_report/3]). + + +suite() -> + [{require, snmp_mgr_agent, snmp}, + {require, snmp_app_cfg, snmp_app}]. + +all() -> + [start_stop, + {group,get_set}]. + + +groups() -> + [{get_set,[get_values,get_next_values,set_values]}]. + +init_per_group(get_set, Config) -> + ok = ct_snmp:start(Config,snmp_mgr_agent,snmp_app_cfg), + Config. + +end_per_group(get_set, Config) -> + ok = ct_snmp:stop(Config), + Config. + +init_per_testcase(_Case, Config) -> + Dog = test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + +end_per_testcase(_Case, Config) -> + Dog=?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +init_per_suite(Config) -> + Config. + +end_per_suite(Config) -> + Config. + +break(_Config) -> + test_server:break(""), + ok. + +start_stop(Config) -> + ok = ct_snmp:start(Config,snmp_mgr_agent,snmp_app_cfg), + timer:sleep(1000), + {snmp,_,_} = lists:keyfind(snmp,1,application:which_applications()), + [_|_] = filelib:wildcard("*/*.conf",?config(priv_dir,Config)), + + ok = ct_snmp:stop(Config), + timer:sleep(1000), + false = lists:keyfind(snmp,1,application:which_applications()), + [] = filelib:wildcard("*/*.conf",?config(priv_dir,Config)), + ok. + +get_values(_Config) -> + Oids1 = [?sysDescr_instance, ?sysName_instance], + {noError,_,V1} = ct_snmp:get_values(agent_name,Oids1,snmp_mgr_agent), + [#varbind{oid=?sysDescr_instance,value="Erlang SNMP agent"}, + #varbind{oid=?sysName_instance,value="ct_test"}] = V1, + ok. + +get_next_values(_Config) -> + Oids2 = [?system], + {noError,_,V2} = ct_snmp:get_next_values(agent_name,Oids2,snmp_mgr_agent), + [#varbind{oid=?sysDescr_instance,value="Erlang SNMP agent"}] = V2, + ok. + +set_values(Config) -> + Oid3 = ?sysName_instance, + NewName = "ct_test changed by " ++ atom_to_list(?MODULE), + VarsAndVals = [{Oid3,s,NewName}], + {noError,_,_} = + ct_snmp:set_values(agent_name,VarsAndVals,snmp_mgr_agent,Config), + + Oids4 = [?sysName_instance], + {noError,_,V4} = ct_snmp:get_values(agent_name,Oids4,snmp_mgr_agent), + [#varbind{oid=?sysName_instance,value=NewName}] = V4, + + ok. + + +%%%----------------------------------------------------------------- +%%% SNMP Manager User callback +handle_error(ReqId, Reason, UserData) -> + erlang:display({handle_error,ReqId, Reason, UserData}), + ignore. + +handle_agent(Addr, Port, Type, SnmpInfo, UserData) -> + erlang:display({handle_agent,Addr, Port, Type, SnmpInfo, UserData}), + ignore. + +handle_pdu(TargetName, ReqId, SnmpPduInfo, UserData) -> + erlang:display({handle_pdu,TargetName, ReqId, SnmpPduInfo, UserData}), + ignore. + +handle_trap(TargetName, SnmpTrapInfo, UserData) -> + erlang:display({handle_trap,TargetName, SnmpTrapInfo, UserData}), + ignore. + +handle_inform(TargetName, SnmpInformInfo, UserData) -> + erlang:display({handle_inform,TargetName, SnmpInformInfo, UserData}), + ignore. + +handle_report(TargetName, SnmpReportInfo, UserData) -> + erlang:display({handle_report,TargetName, SnmpReportInfo, UserData}), + ignore. diff --git a/lib/common_test/test/snmp.cfg b/lib/common_test/test/snmp.cfg new file mode 100644 index 0000000000..e83e66742d --- /dev/null +++ b/lib/common_test/test/snmp.cfg @@ -0,0 +1,21 @@ +%% -*- erlang -*- +{snmp, [{start_agent,true}, + {users,[{user_name,[ct_snmp_SUITE,[]]}]}, + {managed_agents,[{agent_name, [user_name, {127,0,0,1}, 4000, + [{engine_id,"ct_snmp_SUITE-Engine"}, + {version,v2}]]}]}, + {engine_id,"ct_snmp_SUITE-Engine"}, + {agent_vsns,[v1,v2]} + ]}. +{snmp_app,[{manager, [{config, [{verbosity, silence}]}, + {server,[{verbosity,silence}]}, + {net_if,[{verbosity,silence}]}, + {versions,[v1,v2]} + ]}, + {agent, [{config, [{verbosity, silence}]}, + {net_if,[{verbosity,silence}]}, + {mib_server,[{verbosity,silence}]}, + {local_db,[{verbosity,silence}]}, + {agent_verbosity,silence}, + {versions,[v1,v2]} + ]}]}. -- cgit v1.2.3 From a9007fd4a3e1eea2d88c4cc51b2344e24aacf50c Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Fri, 21 Sep 2012 10:25:37 +0200 Subject: [common_test] Updated (minimized) config for ct_snmp test after fixing bugs Bugs reported in OTP-10432 allowed the config for ct_snmp test to specify only one version for agent and manager. --- lib/common_test/test/snmp.cfg | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/snmp.cfg b/lib/common_test/test/snmp.cfg index e83e66742d..a96e4db9d8 100644 --- a/lib/common_test/test/snmp.cfg +++ b/lib/common_test/test/snmp.cfg @@ -5,17 +5,16 @@ [{engine_id,"ct_snmp_SUITE-Engine"}, {version,v2}]]}]}, {engine_id,"ct_snmp_SUITE-Engine"}, - {agent_vsns,[v1,v2]} + {agent_vsns,[v2]} ]}. {snmp_app,[{manager, [{config, [{verbosity, silence}]}, {server,[{verbosity,silence}]}, {net_if,[{verbosity,silence}]}, - {versions,[v1,v2]} + {versions,[v2]} ]}, {agent, [{config, [{verbosity, silence}]}, {net_if,[{verbosity,silence}]}, {mib_server,[{verbosity,silence}]}, {local_db,[{verbosity,silence}]}, - {agent_verbosity,silence}, - {versions,[v1,v2]} + {agent_verbosity,silence} ]}]}. -- cgit v1.2.3 From be0284d6ae701ce55d066112964a60ef003e6158 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Fri, 21 Sep 2012 11:51:41 +0200 Subject: [common_test] Moved ct_snmp_SUITE into data dir and run as other ct tests --- lib/common_test/test/Makefile | 1 - lib/common_test/test/ct_snmp_SUITE.erl | 219 ++++++++++----------- lib/common_test/test/ct_snmp_SUITE_data/snmp.cfg | 20 ++ .../test/ct_snmp_SUITE_data/snmp1_SUITE.erl | 152 ++++++++++++++ lib/common_test/test/snmp.cfg | 20 -- 5 files changed, 276 insertions(+), 136 deletions(-) create mode 100644 lib/common_test/test/ct_snmp_SUITE_data/snmp.cfg create mode 100644 lib/common_test/test/ct_snmp_SUITE_data/snmp1_SUITE.erl delete mode 100644 lib/common_test/test/snmp.cfg (limited to 'lib/common_test/test') diff --git a/lib/common_test/test/Makefile b/lib/common_test/test/Makefile index 33f47e3baf..60c5bd4ff5 100644 --- a/lib/common_test/test/Makefile +++ b/lib/common_test/test/Makefile @@ -107,7 +107,6 @@ release_tests_spec: $(INSTALL_DIR) "$(RELSYSDIR)" $(INSTALL_DATA) $(ERL_FILES) $(COVERFILE) "$(RELSYSDIR)" $(INSTALL_DATA) common_test.spec "$(RELSYSDIR)" - $(INSTALL_DATA) snmp.cfg "$(RELSYSDIR)" chmod -R u+w "$(RELSYSDIR)" @tar cf - *_SUITE_data | (cd "$(RELSYSDIR)"; tar xf -) diff --git a/lib/common_test/test/ct_snmp_SUITE.erl b/lib/common_test/test/ct_snmp_SUITE.erl index 9e4bbedcfb..848752b816 100644 --- a/lib/common_test/test/ct_snmp_SUITE.erl +++ b/lib/common_test/test/ct_snmp_SUITE.erl @@ -1,4 +1,4 @@ -%%-------------------------------------------------------------------- +%% %% %CopyrightBegin% %% %% Copyright Ericsson AB 2012. All Rights Reserved. @@ -16,137 +16,126 @@ %% %% %CopyrightEnd% %% -%%---------------------------------------------------------------------- -%% File: ct_snmp_SUITE.erl -%% -%% Description: -%% This file contains the test cases for the ct_snmp API. -%% -%% @author Support -%% @doc Test of SNMP support in common_test -%% @end -%%---------------------------------------------------------------------- -%%---------------------------------------------------------------------- + +%%%------------------------------------------------------------------- +%%% File: ct_snmp_SUITE +%%% +%%% Description: +%%% Test ct_snmp module +%%% +%%%------------------------------------------------------------------- -module(ct_snmp_SUITE). --include_lib("common_test/include/ct.hrl"). --include_lib("snmp/include/STANDARD-MIB.hrl"). --include_lib("snmp/include/snmp_types.hrl"). -compile(export_all). -%% Default timetrap timeout (set in init_per_testcase). --define(default_timeout, ?t:minutes(1)). +-include_lib("common_test/include/ct.hrl"). +-include_lib("common_test/include/ct_event.hrl"). + +-define(eh, ct_test_support_eh). + +%%-------------------------------------------------------------------- +%% TEST SERVER CALLBACK FUNCTIONS +%%-------------------------------------------------------------------- + +%%-------------------------------------------------------------------- +%% Description: Since Common Test starts another Test Server +%% instance, the tests need to be performed on a separate node (or +%% there will be clashes with logging processes etc). +%%-------------------------------------------------------------------- +init_per_suite(Config) -> + Config1 = ct_test_support:init_per_suite(Config), + Config1. + +end_per_suite(Config) -> + ct_test_support:end_per_suite(Config). -%% SNMP user stuff --behaviour(snmpm_user). --export([handle_error/3, - handle_agent/5, - handle_pdu/4, - handle_trap/3, - handle_inform/3, - handle_report/3]). +init_per_testcase(TestCase, Config) -> + ct_test_support:init_per_testcase(TestCase, Config). +end_per_testcase(TestCase, Config) -> + ct_test_support:end_per_testcase(TestCase, Config). -suite() -> - [{require, snmp_mgr_agent, snmp}, - {require, snmp_app_cfg, snmp_app}]. +suite() -> [{ct_hooks,[ts_install_cth]}]. all() -> - [start_stop, - {group,get_set}]. + [ + default + ]. +%%-------------------------------------------------------------------- +%% TEST CASES +%%-------------------------------------------------------------------- -groups() -> - [{get_set,[get_values,get_next_values,set_values]}]. +%%%----------------------------------------------------------------- +%%% +default(Config) when is_list(Config) -> + DataDir = ?config(data_dir, Config), + Suite = filename:join(DataDir, "snmp1_SUITE"), + CfgFile = filename:join(DataDir, "snmp.cfg"), + {Opts,ERPid} = setup([{suite,Suite},{config,CfgFile}, + {label,default}], Config), -init_per_group(get_set, Config) -> - ok = ct_snmp:start(Config,snmp_mgr_agent,snmp_app_cfg), - Config. + ok = execute(default, Opts, ERPid, Config). -end_per_group(get_set, Config) -> - ok = ct_snmp:stop(Config), - Config. -init_per_testcase(_Case, Config) -> - Dog = test_server:timetrap(?default_timeout), - [{watchdog, Dog}|Config]. +%%%----------------------------------------------------------------- +%%% HELP FUNCTIONS +%%%----------------------------------------------------------------- -end_per_testcase(_Case, Config) -> - Dog=?config(watchdog, Config), - test_server:timetrap_cancel(Dog), - ok. +setup(Test, Config) -> + Opts0 = ct_test_support:get_opts(Config), + Level = ?config(trace_level, Config), + EvHArgs = [{cbm,ct_test_support},{trace_level,Level}], + Opts = Opts0 ++ [{event_handler,{?eh,EvHArgs}}|Test], + ERPid = ct_test_support:start_event_receiver(Config), + {Opts,ERPid}. -init_per_suite(Config) -> - Config. +execute(Name, Opts, ERPid, Config) -> + ok = ct_test_support:run(Opts, Config), + Events = ct_test_support:get_events(ERPid, Config), -end_per_suite(Config) -> - Config. - -break(_Config) -> - test_server:break(""), - ok. - -start_stop(Config) -> - ok = ct_snmp:start(Config,snmp_mgr_agent,snmp_app_cfg), - timer:sleep(1000), - {snmp,_,_} = lists:keyfind(snmp,1,application:which_applications()), - [_|_] = filelib:wildcard("*/*.conf",?config(priv_dir,Config)), - - ok = ct_snmp:stop(Config), - timer:sleep(1000), - false = lists:keyfind(snmp,1,application:which_applications()), - [] = filelib:wildcard("*/*.conf",?config(priv_dir,Config)), - ok. - -get_values(_Config) -> - Oids1 = [?sysDescr_instance, ?sysName_instance], - {noError,_,V1} = ct_snmp:get_values(agent_name,Oids1,snmp_mgr_agent), - [#varbind{oid=?sysDescr_instance,value="Erlang SNMP agent"}, - #varbind{oid=?sysName_instance,value="ct_test"}] = V1, - ok. - -get_next_values(_Config) -> - Oids2 = [?system], - {noError,_,V2} = ct_snmp:get_next_values(agent_name,Oids2,snmp_mgr_agent), - [#varbind{oid=?sysDescr_instance,value="Erlang SNMP agent"}] = V2, - ok. - -set_values(Config) -> - Oid3 = ?sysName_instance, - NewName = "ct_test changed by " ++ atom_to_list(?MODULE), - VarsAndVals = [{Oid3,s,NewName}], - {noError,_,_} = - ct_snmp:set_values(agent_name,VarsAndVals,snmp_mgr_agent,Config), - - Oids4 = [?sysName_instance], - {noError,_,V4} = ct_snmp:get_values(agent_name,Oids4,snmp_mgr_agent), - [#varbind{oid=?sysName_instance,value=NewName}] = V4, - - ok. + ct_test_support:log_events(Name, + reformat(Events, ?eh), + ?config(priv_dir, Config), + Opts), + + TestEvents = events_to_check(Name,Config), + ct_test_support:verify_events(TestEvents, Events, Config). +reformat(Events, EH) -> + ct_test_support:reformat(Events, EH). %%%----------------------------------------------------------------- -%%% SNMP Manager User callback -handle_error(ReqId, Reason, UserData) -> - erlang:display({handle_error,ReqId, Reason, UserData}), - ignore. - -handle_agent(Addr, Port, Type, SnmpInfo, UserData) -> - erlang:display({handle_agent,Addr, Port, Type, SnmpInfo, UserData}), - ignore. - -handle_pdu(TargetName, ReqId, SnmpPduInfo, UserData) -> - erlang:display({handle_pdu,TargetName, ReqId, SnmpPduInfo, UserData}), - ignore. - -handle_trap(TargetName, SnmpTrapInfo, UserData) -> - erlang:display({handle_trap,TargetName, SnmpTrapInfo, UserData}), - ignore. - -handle_inform(TargetName, SnmpInformInfo, UserData) -> - erlang:display({handle_inform,TargetName, SnmpInformInfo, UserData}), - ignore. - -handle_report(TargetName, SnmpReportInfo, UserData) -> - erlang:display({handle_report,TargetName, SnmpReportInfo, UserData}), - ignore. +%%% TEST EVENTS +%%%----------------------------------------------------------------- +events_to_check(_TestName,Config) -> + {module,_} = code:load_abs(filename:join(?config(data_dir,Config), + snmp1_SUITE)), + TCs = get_tcs(), + code:purge(snmp1_SUITE), + code:delete(snmp1_SUITE), + + OneTest = + [{?eh,start_logging,{'DEF','RUNDIR'}}] ++ + [{?eh,tc_done,{snmp1_SUITE,TC,ok}} || TC <- TCs] ++ + [{?eh,stop_logging,[]}], + + %% 2 tests (ct:run_test + script_start) is default + OneTest ++ OneTest. + + +get_tcs() -> + All = snmp1_SUITE:all(), + Groups = + try snmp1_SUITE:groups() + catch error:undef -> [] + end, + flatten_tcs(All,Groups). + +flatten_tcs([H|T],Groups) when is_atom(H) -> + [H|flatten_tcs(T,Groups)]; +flatten_tcs([{group,Group}|T],Groups) -> + TCs = proplists:get_value(Group,Groups), + flatten_tcs(TCs ++ T,Groups); +flatten_tcs([],_) -> + []. diff --git a/lib/common_test/test/ct_snmp_SUITE_data/snmp.cfg b/lib/common_test/test/ct_snmp_SUITE_data/snmp.cfg new file mode 100644 index 0000000000..b0ac0e6a96 --- /dev/null +++ b/lib/common_test/test/ct_snmp_SUITE_data/snmp.cfg @@ -0,0 +1,20 @@ +%% -*- erlang -*- +{snmp, [{start_agent,true}, + {users,[{user_name,[snmp1_SUITE,[]]}]}, + {managed_agents,[{agent_name, [user_name, {127,0,0,1}, 4000, + [{engine_id,"ct_snmp-test-engine"}, + {version,v2}]]}]}, + {engine_id,"ct_snmp-test-engine"}, + {agent_vsns,[v2]} + ]}. +{snmp_app,[{manager, [{config, [{verbosity, silence}]}, + {server,[{verbosity,silence}]}, + {net_if,[{verbosity,silence}]}, + {versions,[v2]} + ]}, + {agent, [{config, [{verbosity, silence}]}, + {net_if,[{verbosity,silence}]}, + {mib_server,[{verbosity,silence}]}, + {local_db,[{verbosity,silence}]}, + {agent_verbosity,silence} + ]}]}. diff --git a/lib/common_test/test/ct_snmp_SUITE_data/snmp1_SUITE.erl b/lib/common_test/test/ct_snmp_SUITE_data/snmp1_SUITE.erl new file mode 100644 index 0000000000..dcc5c5378b --- /dev/null +++ b/lib/common_test/test/ct_snmp_SUITE_data/snmp1_SUITE.erl @@ -0,0 +1,152 @@ +%%-------------------------------------------------------------------- +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2012. All Rights Reserved. +%% +%% The contents of this file are subject to the Erlang Public License, +%% Version 1.1, (the "License"); you may not use this file except in +%% compliance with the License. You should have received a copy of the +%% Erlang Public License along with this software. If not, it can be +%% retrieved online at http://www.erlang.org/. +%% +%% Software distributed under the License is distributed on an "AS IS" +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%% the License for the specific language governing rights and limitations +%% under the License. +%% +%% %CopyrightEnd% +%% +%%---------------------------------------------------------------------- +%% File: ct_snmp_SUITE.erl +%% +%% Description: +%% This file contains the test cases for the ct_snmp API. +%% +%% @author Support +%% @doc Test of SNMP support in common_test +%% @end +%%---------------------------------------------------------------------- +%%---------------------------------------------------------------------- +-module(snmp1_SUITE). +-include_lib("common_test/include/ct.hrl"). +-include_lib("snmp/include/STANDARD-MIB.hrl"). +-include_lib("snmp/include/snmp_types.hrl"). + +-compile(export_all). + +%% Default timetrap timeout (set in init_per_testcase). +-define(default_timeout, ?t:minutes(1)). + +%% SNMP user stuff +-behaviour(snmpm_user). +-export([handle_error/3, + handle_agent/5, + handle_pdu/4, + handle_trap/3, + handle_inform/3, + handle_report/3]). + + +suite() -> + [{require, snmp_mgr_agent, snmp}, + {require, snmp_app_cfg, snmp_app}]. + +all() -> + [start_stop, + {group,get_set}]. + + +groups() -> + [{get_set,[get_values,get_next_values,set_values]}]. + +init_per_group(get_set, Config) -> + ok = ct_snmp:start(Config,snmp_mgr_agent,snmp_app_cfg), + Config. + +end_per_group(get_set, Config) -> + ok = ct_snmp:stop(Config), + Config. + +init_per_testcase(_Case, Config) -> + Dog = test_server:timetrap(?default_timeout), + [{watchdog, Dog}|Config]. + +end_per_testcase(_Case, Config) -> + Dog=?config(watchdog, Config), + test_server:timetrap_cancel(Dog), + ok. + +init_per_suite(Config) -> + Config. + +end_per_suite(Config) -> + Config. + +break(_Config) -> + test_server:break(""), + ok. + +start_stop(Config) -> + ok = ct_snmp:start(Config,snmp_mgr_agent,snmp_app_cfg), + timer:sleep(1000), + {snmp,_,_} = lists:keyfind(snmp,1,application:which_applications()), + [_|_] = filelib:wildcard("*/*.conf",?config(priv_dir,Config)), + + ok = ct_snmp:stop(Config), + timer:sleep(1000), + false = lists:keyfind(snmp,1,application:which_applications()), + [] = filelib:wildcard("*/*.conf",?config(priv_dir,Config)), + ok. + +get_values(_Config) -> + Oids1 = [?sysDescr_instance, ?sysName_instance], + {noError,_,V1} = ct_snmp:get_values(agent_name,Oids1,snmp_mgr_agent), + [#varbind{oid=?sysDescr_instance,value="Erlang SNMP agent"}, + #varbind{oid=?sysName_instance,value="ct_test"}] = V1, + ok. + +get_next_values(_Config) -> + Oids2 = [?system], + {noError,_,V2} = ct_snmp:get_next_values(agent_name,Oids2,snmp_mgr_agent), + [#varbind{oid=?sysDescr_instance,value="Erlang SNMP agent"}] = V2, + ok. + +set_values(Config) -> + Oid3 = ?sysName_instance, + NewName = "ct_test changed by " ++ atom_to_list(?MODULE), + VarsAndVals = [{Oid3,s,NewName}], + {noError,_,_} = + ct_snmp:set_values(agent_name,VarsAndVals,snmp_mgr_agent,Config), + + Oids4 = [?sysName_instance], + {noError,_,V4} = ct_snmp:get_values(agent_name,Oids4,snmp_mgr_agent), + [#varbind{oid=?sysName_instance,value=NewName}] = V4, + + ok. + + +%%%----------------------------------------------------------------- +%%% SNMP Manager User callback +handle_error(ReqId, Reason, UserData) -> + erlang:display({handle_error,ReqId, Reason, UserData}), + ignore. + +handle_agent(Addr, Port, Type, SnmpInfo, UserData) -> + erlang:display({handle_agent,Addr, Port, Type, SnmpInfo, UserData}), + ignore. + +handle_pdu(TargetName, ReqId, SnmpPduInfo, UserData) -> + erlang:display({handle_pdu,TargetName, ReqId, SnmpPduInfo, UserData}), + ignore. + +handle_trap(TargetName, SnmpTrapInfo, UserData) -> + erlang:display({handle_trap,TargetName, SnmpTrapInfo, UserData}), + ignore. + +handle_inform(TargetName, SnmpInformInfo, UserData) -> + erlang:display({handle_inform,TargetName, SnmpInformInfo, UserData}), + ignore. + +handle_report(TargetName, SnmpReportInfo, UserData) -> + erlang:display({handle_report,TargetName, SnmpReportInfo, UserData}), + ignore. diff --git a/lib/common_test/test/snmp.cfg b/lib/common_test/test/snmp.cfg deleted file mode 100644 index a96e4db9d8..0000000000 --- a/lib/common_test/test/snmp.cfg +++ /dev/null @@ -1,20 +0,0 @@ -%% -*- erlang -*- -{snmp, [{start_agent,true}, - {users,[{user_name,[ct_snmp_SUITE,[]]}]}, - {managed_agents,[{agent_name, [user_name, {127,0,0,1}, 4000, - [{engine_id,"ct_snmp_SUITE-Engine"}, - {version,v2}]]}]}, - {engine_id,"ct_snmp_SUITE-Engine"}, - {agent_vsns,[v2]} - ]}. -{snmp_app,[{manager, [{config, [{verbosity, silence}]}, - {server,[{verbosity,silence}]}, - {net_if,[{verbosity,silence}]}, - {versions,[v2]} - ]}, - {agent, [{config, [{verbosity, silence}]}, - {net_if,[{verbosity,silence}]}, - {mib_server,[{verbosity,silence}]}, - {local_db,[{verbosity,silence}]}, - {agent_verbosity,silence} - ]}]}. -- cgit v1.2.3