From: Stephen Worley Date: Tue, 31 Dec 2019 22:10:58 +0000 (-0500) Subject: tests: add basic nexthop group functionality test X-Git-Tag: base_7.4~415^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=8058df22d437f8d95f49f3a90b8f4c794a30bf92;p=mirror%2Ffrr.git tests: add basic nexthop group functionality test Add a very basic nexthop group functionality test. This test creates a 2-way ecmp group and installs a route with it using sharpd. Then we check to see that the nexthop groups are marked valid/installed in zebra. Signed-off-by: Stephen Worley --- diff --git a/tests/topotests/all-protocol-startup/r1/ipv4_routes.ref b/tests/topotests/all-protocol-startup/r1/ipv4_routes.ref index a7d6fe11a6..61d17a61b3 100644 --- a/tests/topotests/all-protocol-startup/r1/ipv4_routes.ref +++ b/tests/topotests/all-protocol-startup/r1/ipv4_routes.ref @@ -10,6 +10,8 @@ C>* 192.168.8.0/26 is directly connected, r1-eth8, XX:XX:XX C>* 192.168.9.0/26 is directly connected, r1-eth9, XX:XX:XX O 192.168.0.0/24 [110/10] is directly connected, r1-eth0, XX:XX:XX O 192.168.3.0/26 [110/10] is directly connected, r1-eth3, XX:XX:XX +S>* 1.1.1.1/32 [1/0] is directly connected, r1-eth0, XX:XX:XX +S>* 1.1.1.2/32 [1/0] is directly connected, r1-eth1, XX:XX:XX S>* 4.5.6.10/32 [1/0] via 192.168.0.2, r1-eth0, XX:XX:XX S>* 4.5.6.11/32 [1/0] via 192.168.0.2, r1-eth0, XX:XX:XX S>* 4.5.6.12/32 [1/0] is directly connected, r1-eth0, XX:XX:XX diff --git a/tests/topotests/all-protocol-startup/r1/zebra.conf b/tests/topotests/all-protocol-startup/r1/zebra.conf index 85c8676964..fbf827604f 100644 --- a/tests/topotests/all-protocol-startup/r1/zebra.conf +++ b/tests/topotests/all-protocol-startup/r1/zebra.conf @@ -26,6 +26,11 @@ ipv6 route 4:5::6:12/128 r1-eth0 # by zebra but not installed. ip route 4.5.6.15/32 192.168.0.2 255 ipv6 route 4:5::6:15/128 fc00:0:0:0::2 255 + +# Routes to put into a nexthop-group +ip route 1.1.1.1/32 r1-eth0 +ip route 1.1.1.2/32 r1-eth1 + ! interface r1-eth0 description to sw0 - no routing protocol diff --git a/tests/topotests/all-protocol-startup/test_all_protocol_startup.py b/tests/topotests/all-protocol-startup/test_all_protocol_startup.py index 9658c080c0..16609221c1 100755 --- a/tests/topotests/all-protocol-startup/test_all_protocol_startup.py +++ b/tests/topotests/all-protocol-startup/test_all_protocol_startup.py @@ -120,6 +120,7 @@ def setup_module(module): if net['r%s' % i].daemon_available('ldpd'): # Only test LDPd if it's installed and Kernel >= 4.5 net['r%s' % i].loadConf('ldpd', '%s/r%s/ldpd.conf' % (thisDir, i)) + net['r%s' % i].loadConf('sharpd') net['r%s' % i].startRouter() # For debugging after starting Quagga/FRR daemons, uncomment the next line @@ -346,6 +347,36 @@ def test_converge_protocols(): # For debugging after starting FRR/Quagga daemons, uncomment the next line ## CLI(net) +def test_nexthop_groups(): + global fatal_error + global net + + # Skip if previous fatal error condition is raised + if (fatal_error != ""): + pytest.skip(fatal_error) + + print("\n\n** Verifying Nexthop Groups") + print("******************************************\n") + + # Create a lib nexthop-group + net["r1"].cmd('vtysh -c "c t" -c "nexthop-group red" -c "nexthop 1.1.1.1" -c "nexthop 1.1.1.2"') + + # Create with sharpd using nexthop-group + net["r1"].cmd('vtysh -c "sharp install routes 2.2.2.1 nexthop-group red 1"') + + # Verify route and that zebra created NHGs for and they are valid/installed + output = net["r1"].cmd('vtysh -c "show ip route 2.2.2.1/32 nexthop-group"') + match = re.search(r"Nexthop Group ID: (\d+)", output); + assert match is not None, "Nexthop Group ID not found for sharpd route 2.2.2.1/32" + + nhe_id = int(match.group(1)) + + output = net["r1"].cmd('vtysh -c "show nexthop-group rib %d"' % nhe_id) + match = re.search(r"Valid", output) + assert match is not None, "Nexthop Group ID=%d not marked Valid" % nhe_id + + match = re.search(r"Installed", output) + assert match is not None, "Nexthop Group ID=%d not marked Installed" % nhe_id def test_rip_status(): global fatal_error