aboutsummaryrefslogtreecommitdiffstats
path: root/lib/snmp/test
diff options
context:
space:
mode:
Diffstat (limited to 'lib/snmp/test')
-rw-r--r--lib/snmp/test/snmp_agent_test.erl28
-rw-r--r--lib/snmp/test/snmp_compiler_test.erl62
-rw-r--r--lib/snmp/test/snmp_manager_test.erl43
-rw-r--r--lib/snmp/test/snmp_test_data/OTP14196-MIB.mib47
-rw-r--r--lib/snmp/test/snmp_test_data/Test-LLDP-MIB.mib251
-rw-r--r--lib/snmp/test/snmp_to_snmpnet_SUITE.erl25
6 files changed, 423 insertions, 33 deletions
diff --git a/lib/snmp/test/snmp_agent_test.erl b/lib/snmp/test/snmp_agent_test.erl
index 3c1a6f2afd..2ed2c4580c 100644
--- a/lib/snmp/test/snmp_agent_test.erl
+++ b/lib/snmp/test/snmp_agent_test.erl
@@ -605,7 +605,12 @@ init_per_group(multiple_reqs_3 = GroupName, Config) ->
init_per_group(test_multi_threaded = GroupName, Config) ->
init_mt(snmp_test_lib:init_group_top_dir(GroupName, Config));
init_per_group(test_v3 = GroupName, Config) ->
- init_v3(snmp_test_lib:init_group_top_dir(GroupName, Config));
+ case snmp_test_lib:crypto_start() of
+ ok ->
+ init_v3(snmp_test_lib:init_group_top_dir(GroupName, Config));
+ _ ->
+ {skip, "Crypto did not start"}
+ end;
init_per_group(test_v1_v2 = GroupName, Config) ->
init_v1_v2(snmp_test_lib:init_group_top_dir(GroupName, Config));
init_per_group(test_v2 = GroupName, Config) ->
@@ -631,11 +636,26 @@ init_per_group(mib_storage_varm_dets = GroupName, Config) ->
init_varm_mib_storage_dets(
snmp_test_lib:init_group_top_dir(GroupName, Config));
init_per_group(mib_storage_size_check_mnesia = GroupName, Config) ->
- init_size_check_msm(snmp_test_lib:init_group_top_dir(GroupName, Config));
+ case snmp_test_lib:crypto_start() of
+ ok ->
+ init_size_check_msm(snmp_test_lib:init_group_top_dir(GroupName, Config));
+ _ ->
+ {skip, "Crypto did not start"}
+ end;
init_per_group(mib_storage_size_check_dets = GroupName, Config) ->
- init_size_check_msd(snmp_test_lib:init_group_top_dir(GroupName, Config));
+ case snmp_test_lib:crypto_start() of
+ ok ->
+ init_size_check_msm(snmp_test_lib:init_group_top_dir(GroupName, Config));
+ _ ->
+ {skip, "Crypto did not start"}
+ end;
init_per_group(mib_storage_size_check_ets = GroupName, Config) ->
- init_size_check_mse(snmp_test_lib:init_group_top_dir(GroupName, Config));
+ case snmp_test_lib:crypto_start() of
+ ok ->
+ init_size_check_msm(snmp_test_lib:init_group_top_dir(GroupName, Config));
+ _ ->
+ {skip, "Crypto did not start"}
+ end;
init_per_group(mib_storage_mnesia = GroupName, Config) ->
init_mib_storage_mnesia(snmp_test_lib:init_group_top_dir(GroupName,
Config));
diff --git a/lib/snmp/test/snmp_compiler_test.erl b/lib/snmp/test/snmp_compiler_test.erl
index 9b3c2bfd2c..0a7b729d1f 100644
--- a/lib/snmp/test/snmp_compiler_test.erl
+++ b/lib/snmp/test/snmp_compiler_test.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2003-2017. All Rights Reserved.
+%% Copyright Ericsson AB 2003-2018. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@@ -57,8 +57,9 @@
otp_8595/1,
otp_10799/1,
otp_10808/1,
- otp_14145/1
-
+ otp_14145/1,
+ otp_13014/1,
+ otp_14196/1
]).
%%----------------------------------------------------------------------
@@ -137,7 +138,8 @@ all() ->
groups() ->
[{tickets, [],
- [otp_6150, otp_8574, otp_8595, otp_10799, otp_10808, otp_14145]}].
+ [otp_6150, otp_8574, otp_8595, otp_10799, otp_10808, otp_14145,
+ otp_13014, otp_14196]}].
init_per_group(_GroupName, Config) ->
Config.
@@ -436,7 +438,7 @@ otp_10808(Config) when is_list(Config) ->
otp_14145(suite) ->
[];
otp_14145(Config) when is_list(Config) ->
- put(tname, otp10808),
+ put(tname, otp14145),
p("starting with Config: ~p~n", [Config]),
Dir = ?config(case_top_dir, Config),
@@ -457,6 +459,56 @@ otp_14145(Config) when is_list(Config) ->
%%======================================================================
+otp_13014(suite) ->
+ [];
+otp_13014(Config) when is_list(Config) ->
+ put(tname, otp13014),
+ p("starting with Config: ~p~n", [Config]),
+
+ Dir = ?config(case_top_dir, Config),
+ MibDir = ?config(mib_dir, Config),
+ MibName = "Test-LLDP-MIB",
+ MibFile = join(MibDir, MibName++".mib"),
+ ?line {ok, MibBin} =
+ snmpc:compile(MibFile, [{outdir, Dir},
+ {verbosity, log},
+ {group_check, false},
+ module_compliance]),
+ p("Mib: ~n~p~n", [MibBin]),
+ #mib{mes = MEs} = read_mib(MibBin),
+ Oid = [1,0,8802,1,1,2,1,1,7],
+ #me{
+ entrytype = table,
+ aliasname = lldpConfigManAddrTable,
+ assocList = [{table_info,TableInfo}]} =
+ lists:keyfind(Oid, #me.oid, MEs),
+ #table_info{
+ nbr_of_cols = 1,
+ first_accessible = 1,
+ not_accessible = [],
+ index_types = {augments,{lldpLocManAddrEntry,undefined}}} =
+ TableInfo,
+ ok.
+
+%%======================================================================
+
+otp_14196(suite) ->
+ [];
+otp_14196(Config) when is_list(Config) ->
+ put(tname, otp14196),
+ p("starting with Config: ~p~n", [Config]),
+
+ Dir = ?config(case_top_dir, Config),
+ MibDir = ?config(mib_dir, Config),
+ MibFile = join(MibDir, "OTP14196-MIB.mib"),
+ ?line {ok, Mib} =
+ snmpc:compile(MibFile, [{outdir, Dir}, {verbosity, trace}]),
+ p("Mib: ~n~p~n", [Mib]),
+ ok.
+
+
+%%======================================================================
+
augments_extra_info(suite) ->
[];
augments_extra_info(Config) when is_list(Config) ->
diff --git a/lib/snmp/test/snmp_manager_test.erl b/lib/snmp/test/snmp_manager_test.erl
index 71f4017d8b..6ced55f0cc 100644
--- a/lib/snmp/test/snmp_manager_test.erl
+++ b/lib/snmp/test/snmp_manager_test.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2003-2016. All Rights Reserved.
+%% Copyright Ericsson AB 2003-2017. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@@ -156,16 +156,25 @@ init_per_suite(Config0) when is_list(Config0) ->
?DBG("init_per_suite -> entry with"
"~n Config0: ~p", [Config0]),
- Config1 = snmp_test_lib:init_suite_top_dir(?MODULE, Config0),
- Config2 = snmp_test_lib:fix_data_dir(Config1),
-
- %% Mib-dirs
- %% data_dir is trashed by the test-server / common-test
- %% so there is no point in fixing it...
- MibDir = snmp_test_lib:lookup(data_dir, Config2),
- StdMibDir = filename:join([code:priv_dir(snmp), "mibs"]),
-
- [{mib_dir, MibDir}, {std_mib_dir, StdMibDir} | Config2].
+ %% Preferably this test SUITE should be divided into groups
+ %% so that if crypto does not work only v3 tests that
+ %% need crypto will be skipped, but as this is only a
+ %% problem with one legacy test machine, we will procrastinate
+ %% until we have a more important reason to fix this.
+ case snmp_test_lib:crypto_start() of
+ ok ->
+ Config1 = snmp_test_lib:init_suite_top_dir(?MODULE, Config0),
+ Config2 = snmp_test_lib:fix_data_dir(Config1),
+ %% Mib-dirs
+ %% data_dir is trashed by the test-server / common-test
+ %% so there is no point in fixing it...
+ MibDir = snmp_test_lib:lookup(data_dir, Config2),
+ StdMibDir = filename:join([code:priv_dir(snmp), "mibs"]),
+
+ [{mib_dir, MibDir}, {std_mib_dir, StdMibDir} | Config2];
+ _ ->
+ {skip, "Crypto did not start"}
+ end.
end_per_suite(Config) when is_list(Config) ->
@@ -1760,7 +1769,7 @@ do_simple_sync_get2(Node, TargetName, Oids, Get, PostVerify)
"~n Rem: ~w", [Reply, _Rem]),
%% verify that the operation actually worked:
- %% The order should be the same, so no need to seach
+ %% The order should be the same, so no need to search
?line ok = case Reply of
{noError, 0, [#varbind{oid = ?sysObjectID_instance,
value = SysObjectID},
@@ -2709,7 +2718,7 @@ do_simple_set2(Node, TargetName, VAVs, Set, PostVerify) ->
"~n Rem: ~w", [Reply, _Rem]),
%% verify that the operation actually worked:
- %% The order should be the same, so no need to seach
+ %% The order should be the same, so no need to search
%% The value we get should be exactly the same as we sent
?line ok = case Reply of
{noError, 0, [#varbind{oid = ?sysName_instance,
@@ -5118,10 +5127,10 @@ inform_swarm_collector(N) ->
%% Note that we need to deal with re-transmissions!
%% That is, the agent did not receive the ack in time,
-%% and therefor did a re-transmit. This means that we
-%% expect to receive more inform's then we actually
-%% sent. So for sucess we assume:
-%%
+%% and therefor did a re-transmit. This means that we
+%% expect to receive more inform's then we actually
+%% sent. So for success we assume:
+%%
%% SentAckCnt = N
%% RespCnt = N
%% RecvCnt >= N
diff --git a/lib/snmp/test/snmp_test_data/OTP14196-MIB.mib b/lib/snmp/test/snmp_test_data/OTP14196-MIB.mib
new file mode 100644
index 0000000000..0b3c718a02
--- /dev/null
+++ b/lib/snmp/test/snmp_test_data/OTP14196-MIB.mib
@@ -0,0 +1,47 @@
+OTP14196-MIB DEFINITIONS ::= BEGIN
+
+IMPORTS
+ MODULE-IDENTITY, OBJECT-TYPE, snmpModules, mib-2
+ FROM SNMPv2-SMI
+ TEXTUAL-CONVENTION
+ FROM SNMPv2-TC
+ OBJECT-GROUP
+ FROM SNMPv2-CONF
+ ;
+
+otp14196MIB MODULE-IDENTITY
+ LAST-UPDATED "1004210000Z"
+ ORGANIZATION ""
+ CONTACT-INFO
+ ""
+ DESCRIPTION
+ "Test mib for OTP-14196"
+ ::= { snmpModules 1 }
+
+testCompliances OBJECT IDENTIFIER ::= { otp14196MIB 1 }
+test OBJECT IDENTIFIER ::= { mib-2 15 }
+
+typeA OBJECT-TYPE
+ SYNTAX TypeAType
+ MAX-ACCESS accessible-for-notify
+ STATUS current
+ DESCRIPTION
+ "Test type for OTP-14196"
+ ::= { test 4711 }
+
+TypeAType ::= TEXTUAL-CONVENTION
+ STATUS current
+ DESCRIPTION
+ ""
+ SYNTAX INTEGER
+
+testGroups OBJECT IDENTIFIER ::= { testCompliances 1 }
+
+testGroupA OBJECT-GROUP
+ OBJECTS { typeA }
+ STATUS current
+ DESCRIPTION
+ ""
+ ::= { testGroups 17 }
+
+END
diff --git a/lib/snmp/test/snmp_test_data/Test-LLDP-MIB.mib b/lib/snmp/test/snmp_test_data/Test-LLDP-MIB.mib
new file mode 100644
index 0000000000..40a9fc79e1
--- /dev/null
+++ b/lib/snmp/test/snmp_test_data/Test-LLDP-MIB.mib
@@ -0,0 +1,251 @@
+Test-LLDP-MIB DEFINITIONS ::= BEGIN
+
+IMPORTS
+ MODULE-IDENTITY, OBJECT-TYPE, Integer32, Counter32, NOTIFICATION-TYPE
+ FROM SNMPv2-SMI
+ TEXTUAL-CONVENTION, TimeStamp, TruthValue
+ FROM SNMPv2-TC
+ SnmpAdminString
+ FROM SNMP-FRAMEWORK-MIB
+ MODULE-COMPLIANCE, OBJECT-GROUP, NOTIFICATION-GROUP
+ FROM SNMPv2-CONF;
+
+t-lldpMIB MODULE-IDENTITY
+ LAST-UPDATED "200505060000Z" -- May 06, 2005
+ ORGANIZATION "IEEE 802.1 Working Group"
+ CONTACT-INFO
+ " Contact: The Erlang/OTP team at Ericsson AB, Sweden
+
+ WG-URL: http://grouper.ieee.org/groups/802/1/index.html
+ WG-EMail: [email protected]
+
+ Contact: Paul Congdon
+ Postal: Hewlett-Packard Company
+ 8000 Foothills Blvd.
+ Roseville, CA 95747
+ USA
+ Tel: +1-916-785-5753
+ DESCRIPTION
+ "This is the ripped out bits and pieces of LLDP-MIB
+ that triggered a compilation problem for Erlang/OTP's
+ MIB compiler due to an AUGMENTS in lldpConfigManAddrEntry
+ refering to a not yet defined OBJECT-TYPE lldpLocManAddrEntry.
+ Rip and rewrite done 2017.
+
+ Management Information Base module for LLDP configuration,
+ statistics, local system data and remote systems data
+ components.
+
+ Copyright (C) IEEE (2005). This version of this MIB module
+ is published as subclause 12.1 of IEEE Std 802.1AB-2005;
+ see the standard itself for full legal notices."
+ REVISION "200505060000Z" -- May 06, 2005
+ DESCRIPTION
+ "Published as part of IEEE Std 802.1AB-2005 initial version."
+ ::= { iso std(0) iso8802(8802) ieee802dot1(1) ieee802dot1mibs(1) 2 }
+
+--lldpNotifications OBJECT IDENTIFIER ::= { lldpMIB 0 }
+lldpObjects OBJECT IDENTIFIER ::= { t-lldpMIB 1 }
+lldpConformance OBJECT IDENTIFIER ::= { t-lldpMIB 2 }
+
+--
+-- LLDP MIB Objects
+--
+
+lldpConfiguration OBJECT IDENTIFIER ::= { lldpObjects 1 }
+--lldpStatistics OBJECT IDENTIFIER ::= { lldpObjects 2 }
+lldpLocalSystemData OBJECT IDENTIFIER ::= { lldpObjects 3 }
+--lldpRemoteSystemsData OBJECT IDENTIFIER ::= { lldpObjects 4 }
+--lldpExtensions OBJECT IDENTIFIER ::= { lldpObjects 5 }
+
+
+
+LldpPortList ::= TEXTUAL-CONVENTION
+ STATUS current
+ DESCRIPTION
+ "Each octet within this value specifies a set of eight ports,
+ with the first octet specifying ports 1 through 8, the second
+ octet specifying ports 9 through 16, etc. Within each octet,
+ the most significant bit represents the lowest numbered port,
+ and the least significant bit represents the highest numbered
+ port. Thus, each port of the system is represented by a
+ single bit within the value of this object. If that bit has
+ a value of '1' then that port is included in the set of ports;
+ the port is not included if its bit has a value of '0'."
+ REFERENCE
+ "IETF RFC 2674 section 5"
+ SYNTAX OCTET STRING(SIZE(0..512))
+
+
+
+--
+-- lldpManAddrConfigTxPortsTable : selection of management addresses
+-- to be transmitted on a specified set
+-- of ports.
+--
+
+lldpConfigManAddrTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF LldpConfigManAddrEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "The table that controls selection of LLDP management address
+ TLV instances to be transmitted on individual ports."
+ ::= { lldpConfiguration 7 }
+
+lldpConfigManAddrEntry OBJECT-TYPE
+ SYNTAX LldpConfigManAddrEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "LLDP configuration information that specifies the set
+ of ports (represented as a PortList) on which the local
+ system management address instance will be transmitted.
+
+ This configuration object augments the lldpLocManAddrEntry,
+ therefore it is only present along with the management
+ address instance contained in the associated
+ lldpLocManAddrEntry entry.
+
+ Each active lldpConfigManAddrEntry must be restored from
+ non-volatile and re-created (along with the corresponding
+ lldpLocManAddrEntry) after a re-initialization of the
+ management system."
+ AUGMENTS { lldpLocManAddrEntry }
+ ::= { lldpConfigManAddrTable 1 }
+
+LldpConfigManAddrEntry ::= SEQUENCE {
+ lldpConfigManAddrPortsTxEnable LldpPortList
+}
+
+lldpConfigManAddrPortsTxEnable OBJECT-TYPE
+ SYNTAX LldpPortList
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "A set of ports that are identified by a PortList, in which
+ each port is represented as a bit. The corresponding local
+ system management address instance will be transmitted on the
+ member ports of the lldpManAddrPortsTxEnable.
+
+ The default value for lldpConfigManAddrPortsTxEnable object
+ is empty binary string, which means no ports are specified
+ for advertising indicated management address instance."
+ REFERENCE
+ "IEEE 802.1AB-2005 10.2.1.1"
+ DEFVAL { ''H } -- empty binary string
+ ::= { lldpConfigManAddrEntry 1 }
+
+
+--
+-- lldpLocManAddrTable : Management addresses of the local system
+--
+
+lldpLocManAddrTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF LldpLocManAddrEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "This table contains management address information on the
+ local system known to this agent."
+ ::= { lldpLocalSystemData 8 }
+
+lldpLocManAddrEntry OBJECT-TYPE
+ SYNTAX LldpLocManAddrEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Management address information about a particular chassis
+ component. There may be multiple management addresses
+ configured on the system identified by a particular
+ lldpLocChassisId. Each management address should have
+ distinct 'management address type' (lldpLocManAddrSubtype) and
+ 'management address' (lldpLocManAddr.)
+
+ Entries may be created and deleted in this table by the
+ agent."
+ INDEX { lldpLocManAddrIfId,
+ lldpLocManAddrLen }
+ ::= { lldpLocManAddrTable 1 }
+
+LldpLocManAddrEntry ::= SEQUENCE {
+ lldpLocManAddrIfId Integer32,
+ lldpLocManAddrLen Integer32,
+ lldpLocManAddrOID OBJECT IDENTIFIER
+}
+
+lldpLocManAddrIfId OBJECT-TYPE
+ SYNTAX Integer32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The integer value used to identify the interface number
+ regarding the management address component associated with
+ the local system."
+ REFERENCE
+ "IEEE 802.1AB-2005 9.5.9.6"
+ ::= { lldpLocManAddrEntry 1 }
+
+lldpLocManAddrLen OBJECT-TYPE
+ SYNTAX Integer32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The total length of the management address subtype and the
+ management address fields in LLDPDUs transmitted by the
+ local LLDP agent.
+
+ The management address length field is needed so that the
+ receiving systems that do not implement SNMP will not be
+ required to implement an iana family numbers/address length
+ equivalency table in order to decode the management adress."
+ REFERENCE
+ "IEEE 802.1AB-2005 9.5.9.2"
+ ::= { lldpLocManAddrEntry 2 }
+
+lldpLocManAddrOID OBJECT-TYPE
+ SYNTAX OBJECT IDENTIFIER
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The OID value used to identify the type of hardware component
+ or protocol entity associated with the management address
+ advertised by the local system agent."
+ REFERENCE
+ "IEEE 802.1AB-2005 9.5.9.8"
+ ::= { lldpLocManAddrEntry 3 }
+
+
+lldpGroups OBJECT IDENTIFIER ::= { lldpConformance 1 }
+
+lldpLocSysGroup OBJECT-GROUP
+ OBJECTS {
+ lldpLocManAddrIfId,
+ lldpLocManAddrLen,
+ lldpLocManAddrOID
+ }
+ STATUS current
+ DESCRIPTION
+ "The collection of objects which are used to represent LLDP
+ Local System Information.
+
+ This group is mandatory for agents which implement the LLDP
+ and have the capability of transmitting LLDP frames."
+ ::= { lldpGroups 6 }
+
+lldpConfigTxGroup OBJECT-GROUP
+ OBJECTS {
+ lldpConfigManAddrPortsTxEnable
+ }
+ STATUS current
+ DESCRIPTION
+ "The collection of objects which are used to configure the
+ LLDP implementation behavior.
+
+ This group is mandatory for agents which implement the LLDP
+ and have the capability of transmitting LLDP frames."
+ ::= { lldpGroups 3 }
+
+
+END
diff --git a/lib/snmp/test/snmp_to_snmpnet_SUITE.erl b/lib/snmp/test/snmp_to_snmpnet_SUITE.erl
index 24c14d86ea..6a3466b6e4 100644
--- a/lib/snmp/test/snmp_to_snmpnet_SUITE.erl
+++ b/lib/snmp/test/snmp_to_snmpnet_SUITE.erl
@@ -88,8 +88,17 @@ groups() ->
].
init_per_suite(Config) ->
- [{agent_port, ?AGENT_PORT}, {manager_port, ?MANAGER_PORT} | Config].
-
+ case re:run(os:cmd("snmpd -v"),"NET-SNMP", [{capture, first}]) of
+ nomatch ->
+ {skip, "snmpd is NOT NET-SNMP"};
+ {match, _} ->
+ case re:run(os:cmd("snmpd -v"),"5.4|5.6.2.1", [{capture, first}]) of
+ nomatch ->
+ [{agent_port, ?AGENT_PORT}, {manager_port, ?MANAGER_PORT} | Config];
+ {match, _} ->
+ {skip, "buggy snmpd"}
+ end
+ end.
end_per_suite(_Config) ->
ok.
@@ -322,7 +331,7 @@ snmpget(Oid, Transport, Config) ->
Args =
["-c", "public", net_snmp_version(Versions),
- "-m", "",
+ "-m", ":",
"-Cf",
net_snmp_addr_str(Transport),
oid_str(Oid)],
@@ -353,11 +362,13 @@ start_snmpd(Community, SysDescr, Config) ->
["--rocommunity"++domain_suffix(Domain)++"="
++Community++" "++inet_parse:ntoa(Ip)
|| {Domain, {Ip, _}} <- Targets],
+
SnmpdArgs =
- ["-f", "-r", %"-Dverbose",
- "-c", filename:join(DataDir, "snmpd.conf"),
- "-C", "-Lo",
- "-m", "",
+ ["-f", "-r", %"-Dverbose",
+ "-c", filename:join(DataDir, "snmpd.conf"),
+ "-C",
+ "-Lo",
+ "-m", ":",
"--sysDescr="++SysDescr,
"--agentXSocket=tcp:localhost:"++integer_to_list(Port)]
++ CommunityArgs