From 485e8b5662dbecdb9f2e1a3e0a88dbfaffd640b2 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Mon, 20 Sep 2021 23:23:47 -0300 Subject: [PATCH] tests: check if OSPF opaque attributes are installed in the RIB Signed-off-by: Renato Westphal --- tests/topotests/zebra_opaque/r3/ospf6d.conf | 8 ++++ tests/topotests/zebra_opaque/r3/ospfd.conf | 8 ++++ tests/topotests/zebra_opaque/r3/zebra.conf | 5 ++ tests/topotests/zebra_opaque/r4/ospf6d.conf | 8 ++++ tests/topotests/zebra_opaque/r4/ospfd.conf | 8 ++++ tests/topotests/zebra_opaque/r4/zebra.conf | 5 ++ .../zebra_opaque/test_zebra_opaque.py | 48 +++++++++++++++++-- 7 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 tests/topotests/zebra_opaque/r3/ospf6d.conf create mode 100644 tests/topotests/zebra_opaque/r3/ospfd.conf create mode 100644 tests/topotests/zebra_opaque/r3/zebra.conf create mode 100644 tests/topotests/zebra_opaque/r4/ospf6d.conf create mode 100644 tests/topotests/zebra_opaque/r4/ospfd.conf create mode 100644 tests/topotests/zebra_opaque/r4/zebra.conf diff --git a/tests/topotests/zebra_opaque/r3/ospf6d.conf b/tests/topotests/zebra_opaque/r3/ospf6d.conf new file mode 100644 index 0000000000..bf3d18c6dd --- /dev/null +++ b/tests/topotests/zebra_opaque/r3/ospf6d.conf @@ -0,0 +1,8 @@ +! +interface r3-eth0 + ipv6 ospf6 area 0 + ipv6 ospf6 hello-interval 2 + ipv6 ospf6 dead-interval 10 +! +router ospf6 +! diff --git a/tests/topotests/zebra_opaque/r3/ospfd.conf b/tests/topotests/zebra_opaque/r3/ospfd.conf new file mode 100644 index 0000000000..fdc7a97866 --- /dev/null +++ b/tests/topotests/zebra_opaque/r3/ospfd.conf @@ -0,0 +1,8 @@ +! +interface r3-eth0 + ip ospf area 0 + ip ospf hello-interval 2 + ip ospf dead-interval 10 +! +router ospf +! diff --git a/tests/topotests/zebra_opaque/r3/zebra.conf b/tests/topotests/zebra_opaque/r3/zebra.conf new file mode 100644 index 0000000000..744f2f1f78 --- /dev/null +++ b/tests/topotests/zebra_opaque/r3/zebra.conf @@ -0,0 +1,5 @@ +! +int r3-eth0 + ip address 192.168.1.1/24 + ipv6 address 2001:db8:1::1/64 +! diff --git a/tests/topotests/zebra_opaque/r4/ospf6d.conf b/tests/topotests/zebra_opaque/r4/ospf6d.conf new file mode 100644 index 0000000000..3b6846ff13 --- /dev/null +++ b/tests/topotests/zebra_opaque/r4/ospf6d.conf @@ -0,0 +1,8 @@ +! +interface r4-eth0 + ipv6 ospf6 area 0 + ipv6 ospf6 hello-interval 2 + ipv6 ospf6 dead-interval 10 +! +router ospf6 +! diff --git a/tests/topotests/zebra_opaque/r4/ospfd.conf b/tests/topotests/zebra_opaque/r4/ospfd.conf new file mode 100644 index 0000000000..6e08beebca --- /dev/null +++ b/tests/topotests/zebra_opaque/r4/ospfd.conf @@ -0,0 +1,8 @@ +! +interface r4-eth0 + ip ospf area 0 + ip ospf hello-interval 2 + ip ospf dead-interval 10 +! +router ospf +! diff --git a/tests/topotests/zebra_opaque/r4/zebra.conf b/tests/topotests/zebra_opaque/r4/zebra.conf new file mode 100644 index 0000000000..5916f5f882 --- /dev/null +++ b/tests/topotests/zebra_opaque/r4/zebra.conf @@ -0,0 +1,5 @@ +! +int r4-eth0 + ip address 192.168.1.2/24 + ipv6 address 2001:db8:1::2/64 +! diff --git a/tests/topotests/zebra_opaque/test_zebra_opaque.py b/tests/topotests/zebra_opaque/test_zebra_opaque.py index 2983df3ed6..202e28a178 100644 --- a/tests/topotests/zebra_opaque/test_zebra_opaque.py +++ b/tests/topotests/zebra_opaque/test_zebra_opaque.py @@ -35,11 +35,11 @@ sys.path.append(os.path.join(CWD, "../")) from lib import topotest from lib.topogen import Topogen, TopoRouter, get_topogen -pytestmark = [pytest.mark.bgpd] +pytestmark = [pytest.mark.bgpd, pytest.mark.ospfd, pytest.mark.ospf6d] def setup_module(mod): - topodef = {"s1": ("r1", "r2")} + topodef = {"s1": ("r1", "r2"), "s2": ("r3", "r4")} tgen = Topogen(topodef, mod.__name__) tgen.start_topology() @@ -52,6 +52,12 @@ def setup_module(mod): router.load_config( TopoRouter.RD_BGP, os.path.join(CWD, "{}/bgpd.conf".format(rname)) ) + router.load_config( + TopoRouter.RD_OSPF, os.path.join(CWD, "{}/ospfd.conf".format(rname)) + ) + router.load_config( + TopoRouter.RD_OSPF6, os.path.join(CWD, "{}/ospf6d.conf".format(rname)) + ) tgen.start_router() @@ -67,8 +73,6 @@ def test_zebra_opaque(): if tgen.routers_have_failure(): pytest.skip(tgen.errors) - router = tgen.gears["r1"] - def _bgp_converge(router): output = json.loads(router.vtysh_cmd("show ip route 192.168.1.0/24 json")) expected = { @@ -81,11 +85,45 @@ def test_zebra_opaque(): } return topotest.json_cmp(output, expected) + def _ospf_converge(router): + output = json.loads(router.vtysh_cmd("show ip route 192.168.1.0/24 json")) + expected = { + "192.168.1.0/24": [ + { + "ospfPathType": "Intra-Area", + "ospfAreaId": "0.0.0.0", + } + ] + } + return topotest.json_cmp(output, expected) + + def _ospf6_converge(router): + output = json.loads(router.vtysh_cmd("show ipv6 route 2001:db8:1::/64 json")) + expected = { + "2001:db8:1::/64": [ + { + "ospfPathType": "Intra-Area", + "ospfAreaId": "0.0.0.0", + } + ] + } + return topotest.json_cmp(output, expected) + + router = tgen.gears["r1"] test_func = functools.partial(_bgp_converge, router) success, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5) - assert result is None, 'Cannot see BGP community aliases "{}"'.format(router) + router = tgen.gears["r3"] + test_func = functools.partial(_ospf_converge, router) + success, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5) + assert result is None, 'Cannot see OSPFv2 opaque attributes "{}"'.format(router) + + router = tgen.gears["r3"] + test_func = functools.partial(_ospf6_converge, router) + success, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5) + assert result is None, 'Cannot see OSPFv3 opaque attributes "{}"'.format(router) + if __name__ == "__main__": args = ["-s"] + sys.argv[1:] -- 2.39.5