diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-09 13:16:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-09 13:16:35 +0000 |
commit | e2bbf175a2184bd76f6c54ccf8456babeb1a46fc (patch) | |
tree | f0b76550d6e6f500ada964a3a4ee933a45e5a6f1 /tests/topotests/simple_snmp_test | |
parent | Initial commit. (diff) | |
download | frr-e2bbf175a2184bd76f6c54ccf8456babeb1a46fc.tar.xz frr-e2bbf175a2184bd76f6c54ccf8456babeb1a46fc.zip |
Adding upstream version 9.1.upstream/9.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/topotests/simple_snmp_test')
-rw-r--r-- | tests/topotests/simple_snmp_test/r1/bgpd.conf | 6 | ||||
-rw-r--r-- | tests/topotests/simple_snmp_test/r1/isisd.conf | 46 | ||||
-rw-r--r-- | tests/topotests/simple_snmp_test/r1/snmpd.conf | 18 | ||||
-rw-r--r-- | tests/topotests/simple_snmp_test/r1/zebra.conf | 22 | ||||
-rwxr-xr-x | tests/topotests/simple_snmp_test/test_simple_snmp.py | 118 |
5 files changed, 210 insertions, 0 deletions
diff --git a/tests/topotests/simple_snmp_test/r1/bgpd.conf b/tests/topotests/simple_snmp_test/r1/bgpd.conf new file mode 100644 index 0000000..00d1e17 --- /dev/null +++ b/tests/topotests/simple_snmp_test/r1/bgpd.conf @@ -0,0 +1,6 @@ +log file /tmp/bgpd.log debugging +! +router bgp 100 + bgp router-id 1.1.1.1 + +agentx diff --git a/tests/topotests/simple_snmp_test/r1/isisd.conf b/tests/topotests/simple_snmp_test/r1/isisd.conf new file mode 100644 index 0000000..435abde --- /dev/null +++ b/tests/topotests/simple_snmp_test/r1/isisd.conf @@ -0,0 +1,46 @@ +log stdout debugging +! +! debug isis route-events +! debug isis events +! +interface r1-eth0 + ip router isis ISIS1 + ipv6 router isis ISIS1 + isis circuit-type level-1 + no isis hello padding + isis hello-interval 1 + isis hello-multiplier 10 + isis network point-to-point +! +interface r1-eth1 + ip router isis ISIS1 + ipv6 router isis ISIS1 + isis circuit-type level-1 + no isis hello padding + isis hello-interval 1 + isis hello-multiplier 10 + isis network point-to-point +! +interface r1-eth2 + ip router isis ISIS1 + ipv6 router isis ISIS1 + isis circuit-type level-1 + no isis hello padding + isis hello-interval 1 + isis hello-multiplier 10 + isis network point-to-point +! +interface lo + ip router isis ISIS1 + ipv6 router isis ISIS1 + isis circuit-type level-1 + isis passive + no isis hello padding +! +router isis ISIS1 + net 01.1111.0000.0000.0001.00 + is-type level-1 + topology ipv6-unicast +! +line vty +! diff --git a/tests/topotests/simple_snmp_test/r1/snmpd.conf b/tests/topotests/simple_snmp_test/r1/snmpd.conf new file mode 100644 index 0000000..cdcd9a2 --- /dev/null +++ b/tests/topotests/simple_snmp_test/r1/snmpd.conf @@ -0,0 +1,18 @@ +agentAddress udp:161 + +com2sec public 1.1.1.1 public + +group public_group v1 public +group public_group v2c public + +access public_group "" any noauth prefix all all none + +view all included .1 + +iquerySecName frr +rouser frr + +master agentx + +agentXSocket /etc/frr/agentx +agentXPerms 777 755 root frr diff --git a/tests/topotests/simple_snmp_test/r1/zebra.conf b/tests/topotests/simple_snmp_test/r1/zebra.conf new file mode 100644 index 0000000..5281d00 --- /dev/null +++ b/tests/topotests/simple_snmp_test/r1/zebra.conf @@ -0,0 +1,22 @@ +log file zebra.log +! +interface r1-eth0 + ip address 192.168.12.12/24 + ipv6 address 2000:1:1:12::12/64 +! +interface r1-eth1 + ip address 192.168.13.13/24 + ipv6 address 2000:1:1:13::13/64 +! +interface r1-eth2 + ip address 192.168.14.14/24 + ipv6 address 2000:1:1:14::14/64 +! +! +interface lo + ip address 1.1.1.1/32 + ipv6 address 2000:1:1:1::1/128 +! +! +! +line vty diff --git a/tests/topotests/simple_snmp_test/test_simple_snmp.py b/tests/topotests/simple_snmp_test/test_simple_snmp.py new file mode 100755 index 0000000..ee02c7b --- /dev/null +++ b/tests/topotests/simple_snmp_test/test_simple_snmp.py @@ -0,0 +1,118 @@ +#!/usr/bin/env python +# SPDX-License-Identifier: ISC + +# +# test_simple_snmp.py +# Part of NetDEF Topology Tests +# +# Copyright (c) 2020 by Volta Networks +# + +""" +test_bgp_simple snmp.py: Test snmp infrastructure. +""" + +import os +import sys +import pytest + +# Save the Current Working Directory to find configuration files. +CWD = os.path.dirname(os.path.realpath(__file__)) +sys.path.append(os.path.join(CWD, "../")) + +# pylint: disable=C0413 +# Import topogen and topotest helpers +from lib.topogen import Topogen, TopoRouter, get_topogen +from lib.snmptest import SnmpTester + + +pytestmark = [pytest.mark.bgpd, pytest.mark.isisd, pytest.mark.snmp] + + +def setup_module(mod): + "Sets up the pytest environment" + + # skip tests is SNMP not installed + if not os.path.isfile("/usr/sbin/snmpd"): + error_msg = "SNMP not installed - skipping" + pytest.skip(error_msg) + # This function initiates the topology build with Topogen... + topodef = {"s1": "r1", "s2": "r1", "s3": "r1"} + tgen = Topogen(topodef, mod.__name__) + # ... and here it calls Mininet initialization functions. + tgen.start_topology() + + r1 = tgen.gears["r1"] + + r1.run("ip addr add 192.168.12.12/24 dev r1-eth0") + r1.run("ip -6 addr add 2000:1:1:12::12/64 dev r1-eth0") + r1.run("ip addr add 192.168.13.13/24 dev r1-eth1") + r1.run("ip -6 addr add 2000:1:1:13::13/64 dev r1-eth1") + r1.run("ip addr add 192.168.14.14/24 dev r1-eth2") + r1.run("ip -6 addr add 2000:1:1:14::14/64 dev r1-eth2") + r1.run("ip addr add 1.1.1.1/32 dev lo") + r1.run("ip -6 addr add 2000:1:1:1::1/128 dev lo") + r1.run("ip addr show") + + router_list = tgen.routers() + + # For all registered routers, load the zebra configuration file + for rname, router in router_list.items(): + router.load_config( + TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname)) + ) + router.load_config( + TopoRouter.RD_ISIS, os.path.join(CWD, "{}/isisd.conf".format(rname)) + ) + router.load_config( + TopoRouter.RD_BGP, + os.path.join(CWD, "{}/bgpd.conf".format(rname)), + "-M snmp", + ) + router.load_config( + TopoRouter.RD_SNMP, + os.path.join(CWD, "{}/snmpd.conf".format(rname)), + "-Le -Ivacm_conf,usmConf,iquery -V -DAgentX,trap", + ) + + # After loading the configurations, this function loads configured daemons. + tgen.start_router() + + +def teardown_module(mod): + "Teardown the pytest environment" + tgen = get_topogen() + + # This function tears down the whole topology. + tgen.stop_topology() + + +def test_r1_bgp_version(): + "Wait for protocol convergence" + tgen = get_topogen() + + # Skip if previous fatal error condition is raised + if tgen.routers_have_failure(): + pytest.skip(tgen.errors) + + # tgen.mininet_cli() + r1 = tgen.gears["r1"] + r1_snmp = SnmpTester(r1, "1.1.1.1", "public", "2c") + assert r1_snmp.test_oid("bgpVersin", None) + assert r1_snmp.test_oid("bgpVersion", "10") + assert r1_snmp.test_oid_walk("bgpVersion", ["10"]) + assert r1_snmp.test_oid_walk("bgpVersion", ["10"], ["0"]) + + +def test_memory_leak(): + "Run the memory leak test and report results." + tgen = get_topogen() + if not tgen.is_memleak_enabled(): + pytest.skip("Memory leak test/report is disabled") + + tgen.report_memory_leaks() + + +if __name__ == "__main__": + args = ["-s"] + sys.argv[1:] + sys.exit(pytest.main(args)) |