From f92f88d36162ee7202c9b382846f04420c2b5a83 Mon Sep 17 00:00:00 2001 From: Jafar Al-Gharaibeh Date: Sat, 22 Apr 2023 13:10:16 -0500 Subject: [PATCH] tests: clear the ospf neighbor to force a state change Signed-off-by: Jafar Al-Gharaibeh --- .../ospf_metric_propagation/r1/frr.conf | 6 +-- .../ospf_metric_propagation/r2/frr.conf | 6 +-- .../ospf_metric_propagation/r3/frr.conf | 6 +-- .../ospf_metric_propagation/r4/frr.conf | 6 +-- .../ospf_metric_propagation/ra/frr.conf | 6 +-- .../ospf_metric_propagation/rb/frr.conf | 6 +-- .../ospf_metric_propagation/rc/frr.conf | 4 +- .../test_ospf_metric_propagation.py | 39 ++++++++++++------- 8 files changed, 45 insertions(+), 34 deletions(-) diff --git a/tests/topotests/ospf_metric_propagation/r1/frr.conf b/tests/topotests/ospf_metric_propagation/r1/frr.conf index 9f388dbd0f..85230494dd 100644 --- a/tests/topotests/ospf_metric_propagation/r1/frr.conf +++ b/tests/topotests/ospf_metric_propagation/r1/frr.conf @@ -8,18 +8,18 @@ interface r1-eth0 ip address 10.0.1.1/24 ip ospf cost 100 ip ospf hello-interval 1 - ip ospf dead-interval 3 + ip ospf dead-interval 30 ! interface r1-eth1 vrf blue ip address 10.0.10.1/24 ip ospf hello-interval 1 - ip ospf dead-interval 3 + ip ospf dead-interval 30 ! ! interface r1-eth2 vrf green ip address 10.0.91.1/24 ip ospf hello-interval 1 - ip ospf dead-interval 3 + ip ospf dead-interval 30 ! ! router ospf diff --git a/tests/topotests/ospf_metric_propagation/r2/frr.conf b/tests/topotests/ospf_metric_propagation/r2/frr.conf index 469ae5da88..e67a374ff5 100644 --- a/tests/topotests/ospf_metric_propagation/r2/frr.conf +++ b/tests/topotests/ospf_metric_propagation/r2/frr.conf @@ -8,18 +8,18 @@ interface r2-eth0 ip address 10.0.1.2/24 ip ospf cost 100 ip ospf hello-interval 1 - ip ospf dead-interval 3 + ip ospf dead-interval 30 ! interface r2-eth1 vrf blue ip address 10.0.20.2/24 ip ospf hello-interval 1 - ip ospf dead-interval 3 + ip ospf dead-interval 30 ! interface r2-eth2 vrf green ip address 10.0.70.2/24 ip ospf cost 1000 ip ospf hello-interval 1 - ip ospf dead-interval 3 + ip ospf dead-interval 30 ! router ospf ospf router-id 10.0.255.2 diff --git a/tests/topotests/ospf_metric_propagation/r3/frr.conf b/tests/topotests/ospf_metric_propagation/r3/frr.conf index 8dbbaf0fc4..175851d427 100644 --- a/tests/topotests/ospf_metric_propagation/r3/frr.conf +++ b/tests/topotests/ospf_metric_propagation/r3/frr.conf @@ -8,18 +8,18 @@ interface r3-eth0 ip address 10.0.3.3/24 ip ospf cost 100 ip ospf hello-interval 1 - ip ospf dead-interval 3 + ip ospf dead-interval 30 ! interface r3-eth1 vrf blue ip address 10.0.30.3/24 ip ospf hello-interval 1 - ip ospf dead-interval 3 + ip ospf dead-interval 30 ! interface r3-eth2 vrf green ip address 10.0.80.3/24 ip ospf cost 1000 ip ospf hello-interval 1 - ip ospf dead-interval 3 + ip ospf dead-interval 30 ! router ospf ospf router-id 10.0.255.3 diff --git a/tests/topotests/ospf_metric_propagation/r4/frr.conf b/tests/topotests/ospf_metric_propagation/r4/frr.conf index af1005063b..70a47e34fa 100644 --- a/tests/topotests/ospf_metric_propagation/r4/frr.conf +++ b/tests/topotests/ospf_metric_propagation/r4/frr.conf @@ -8,17 +8,17 @@ interface r4-eth0 ip address 10.0.3.4/24 ip ospf cost 100 ip ospf hello-interval 1 - ip ospf dead-interval 3 + ip ospf dead-interval 30 ! interface r4-eth1 vrf blue ip address 10.0.40.4/24 ip ospf hello-interval 1 - ip ospf dead-interval 3 + ip ospf dead-interval 30 ! interface r4-eth2 vrf green ip address 10.0.94.4/24 ip ospf hello-interval 1 - ip ospf dead-interval 3 + ip ospf dead-interval 30 ! router ospf ospf router-id 10.0.255.4 diff --git a/tests/topotests/ospf_metric_propagation/ra/frr.conf b/tests/topotests/ospf_metric_propagation/ra/frr.conf index 0bc2ec5679..7be9e5c33e 100644 --- a/tests/topotests/ospf_metric_propagation/ra/frr.conf +++ b/tests/topotests/ospf_metric_propagation/ra/frr.conf @@ -7,17 +7,17 @@ ip forwarding interface ra-eth0 ip address 10.0.50.5/24 ip ospf hello-interval 1 - ip ospf dead-interval 3 + ip ospf dead-interval 30 ! interface ra-eth1 ip address 10.0.10.5/24 ip ospf hello-interval 1 - ip ospf dead-interval 3 + ip ospf dead-interval 30 ! interface ra-eth2 ip address 10.0.20.5/24 ip ospf hello-interval 1 - ip ospf dead-interval 3 + ip ospf dead-interval 30 ! router ospf ospf router-id 10.0.255.5 diff --git a/tests/topotests/ospf_metric_propagation/rb/frr.conf b/tests/topotests/ospf_metric_propagation/rb/frr.conf index 6f540d125e..a7dbf82278 100644 --- a/tests/topotests/ospf_metric_propagation/rb/frr.conf +++ b/tests/topotests/ospf_metric_propagation/rb/frr.conf @@ -7,17 +7,17 @@ ip forwarding interface rb-eth0 ip address 10.0.50.6/24 ip ospf hello-interval 1 - ip ospf dead-interval 3 + ip ospf dead-interval 30 ! interface rb-eth1 ip address 10.0.30.6/24 ip ospf hello-interval 1 - ip ospf dead-interval 3 + ip ospf dead-interval 30 ! interface rb-eth2 ip address 10.0.40.6/24 ip ospf hello-interval 1 - ip ospf dead-interval 3 + ip ospf dead-interval 30 ! router ospf ospf router-id 10.0.255.6 diff --git a/tests/topotests/ospf_metric_propagation/rc/frr.conf b/tests/topotests/ospf_metric_propagation/rc/frr.conf index 9fc0ef718f..f5a2ed7c4f 100644 --- a/tests/topotests/ospf_metric_propagation/rc/frr.conf +++ b/tests/topotests/ospf_metric_propagation/rc/frr.conf @@ -7,12 +7,12 @@ ip forwarding interface rc-eth0 ip address 10.0.70.7/24 ip ospf hello-interval 1 - ip ospf dead-interval 3 + ip ospf dead-interval 30 ! interface rc-eth1 ip address 10.0.80.7/24 ip ospf hello-interval 1 - ip ospf dead-interval 3 + ip ospf dead-interval 30 ! router ospf ospf router-id 10.0.255.7 diff --git a/tests/topotests/ospf_metric_propagation/test_ospf_metric_propagation.py b/tests/topotests/ospf_metric_propagation/test_ospf_metric_propagation.py index 709e07649b..4d78bd2372 100644 --- a/tests/topotests/ospf_metric_propagation/test_ospf_metric_propagation.py +++ b/tests/topotests/ospf_metric_propagation/test_ospf_metric_propagation.py @@ -71,7 +71,6 @@ def build_topo(tgen): tgen.add_router("h1") tgen.add_router("h2") - # Interconect router 1, 2 switch = tgen.add_switch("s1-2") switch.add_link(tgen.gears["r1"]) @@ -127,6 +126,7 @@ def build_topo(tgen): switch.add_link(tgen.gears["r3"]) switch.add_link(tgen.gears["rc"]) + def setup_module(mod): logger.info("OSPF Metric Propagation:\n {}".format(TOPOLOGY)) @@ -148,8 +148,12 @@ def setup_module(mod): for cmd in vrf_setup_cmds: tgen.net["r{}".format(routern)].cmd(cmd) for routern in range(1, 5): - tgen.net["r{}".format(routern)].cmd("ip link set dev r{}-eth1 vrf blue up".format(routern)) - tgen.net["r{}".format(routern)].cmd("ip link set dev r{}-eth2 vrf green up".format(routern)) + tgen.net["r{}".format(routern)].cmd( + "ip link set dev r{}-eth1 vrf blue up".format(routern) + ) + tgen.net["r{}".format(routern)].cmd( + "ip link set dev r{}-eth2 vrf green up".format(routern) + ) for rname, router in router_list.items(): logger.info("Loading router %s" % rname) @@ -181,7 +185,7 @@ def test_all_links_up(): test_func = partial( topotest.router_json_cmp, r1, "show ip route vrf green 10.0.94.2 json", expected ) - _, result = topotest.run_and_expect(test_func, None, count=40, wait=1) + _, result = topotest.run_and_expect(test_func, None, count=60, wait=1) assertmsg = "r1 JSON output mismatches" assert result is None, assertmsg @@ -202,7 +206,7 @@ def test_link_1_down(): test_func = partial( topotest.router_json_cmp, r1, "show ip route vrf green 10.0.94.2 json", expected ) - _, result = topotest.run_and_expect(test_func, None, count=20, wait=1) + _, result = topotest.run_and_expect(test_func, None, count=60, wait=1) assertmsg = "r1 JSON output mismatches" assert result is None, assertmsg @@ -216,6 +220,10 @@ def test_link_1_2_down(): pytest.skip("skipped because of router(s) failure") tgen.net["r2"].cmd("ip link set dev r2-eth1 down") + tgen.net["r2"].cmd("ip link set dev r2-eth2 down") + # ospf dead-interval is set to 30 seconds, wait 35 seconds to clear the neighbor + sleep(35) + tgen.net["r2"].cmd("ip link set dev r2-eth2 up") r1 = tgen.gears["r1"] json_file = "{}/r1/show_ip_route-3.json".format(CWD) @@ -223,7 +231,7 @@ def test_link_1_2_down(): test_func = partial( topotest.router_json_cmp, r1, "show ip route vrf green 10.0.94.2 json", expected ) - _, result = topotest.run_and_expect(test_func, None, count=20, wait=1) + _, result = topotest.run_and_expect(test_func, None, count=60, wait=1) assertmsg = "r1 JSON output mismatches" assert result is None, assertmsg @@ -238,8 +246,8 @@ def test_link_1_2_3_down(): tgen.net["r3"].cmd("ip link set dev r3-eth0 down") tgen.net["r3"].cmd("ip link set dev r3-eth1 down") - # ospf dead-interval is set to 3 seconds, wait 5 seconds to clear the neighbor - sleep(5) + # ospf dead-interval is set to 30 seconds, wait 35 seconds to clear the neighbor + sleep(35) tgen.net["r3"].cmd("ip link set dev r3-eth0 up") r1 = tgen.gears["r1"] @@ -248,11 +256,12 @@ def test_link_1_2_3_down(): test_func = partial( topotest.router_json_cmp, r1, "show ip route vrf green 10.0.94.2 json", expected ) - _, result = topotest.run_and_expect(test_func, None, count=20, wait=1) + _, result = topotest.run_and_expect(test_func, None, count=60, wait=1) assertmsg = "r1 JSON output mismatches" assert result is None, assertmsg + def test_link_1_2_3_4_down(): "Test path R1 -> R2 -> Rc -> R3 -> R4" tgen = get_topogen() @@ -268,11 +277,12 @@ def test_link_1_2_3_4_down(): test_func = partial( topotest.router_json_cmp, r1, "show ip route vrf green 10.0.94.2 json", expected ) - _, result = topotest.run_and_expect(test_func, None, count=20, wait=1) + _, result = topotest.run_and_expect(test_func, None, count=60, wait=1) assertmsg = "r1 JSON output mismatches" assert result is None, assertmsg + def test_link_1_2_4_down(): "Test path R1 -> R2 -> Rc -> R3 -> R4" tgen = get_topogen() @@ -289,11 +299,12 @@ def test_link_1_2_4_down(): test_func = partial( topotest.router_json_cmp, r1, "show ip route vrf green 10.0.94.2 json", expected ) - _, result = topotest.run_and_expect(test_func, None, count=20, wait=1) + _, result = topotest.run_and_expect(test_func, None, count=60, wait=1) assertmsg = "r1 JSON output mismatches" assert result is None, assertmsg + def test_link_1_4_down(): "Test path R1 -> R2 -> Ra -> Rb -> R3 -> R4" tgen = get_topogen() @@ -310,7 +321,7 @@ def test_link_1_4_down(): test_func = partial( topotest.router_json_cmp, r1, "show ip route vrf green 10.0.94.2 json", expected ) - _, result = topotest.run_and_expect(test_func, None, count=20, wait=1) + _, result = topotest.run_and_expect(test_func, None, count=60, wait=1) assertmsg = "r1 JSON output mismatches" assert result is None, assertmsg @@ -332,7 +343,7 @@ def test_link_4_down(): test_func = partial( topotest.router_json_cmp, r1, "show ip route vrf green 10.0.94.2 json", expected ) - _, result = topotest.run_and_expect(test_func, None, count=20, wait=1) + _, result = topotest.run_and_expect(test_func, None, count=60, wait=1) assertmsg = "r1 JSON output mismatches" assert result is None, assertmsg @@ -354,7 +365,7 @@ def test_link_1_2_3_4_up(): test_func = partial( topotest.router_json_cmp, r1, "show ip route vrf green 10.0.94.2 json", expected ) - _, result = topotest.run_and_expect(test_func, None, count=20, wait=1) + _, result = topotest.run_and_expect(test_func, None, count=60, wait=1) assertmsg = "r1 JSON output mismatches" assert result is None, assertmsg -- 2.39.5