]> git.proxmox.com Git - mirror_frr.git/commitdiff
tests: add basic nexthop group functionality test
authorStephen Worley <sworley@cumulusnetworks.com>
Tue, 31 Dec 2019 22:10:58 +0000 (17:10 -0500)
committerStephen Worley <sworley@cumulusnetworks.com>
Wed, 15 Jan 2020 21:39:19 +0000 (16:39 -0500)
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 <sworley@cumulusnetworks.com>
tests/topotests/all-protocol-startup/r1/ipv4_routes.ref
tests/topotests/all-protocol-startup/r1/zebra.conf
tests/topotests/all-protocol-startup/test_all_protocol_startup.py

index a7d6fe11a6dd313915e9742ad93fbcb116ec098d..61d17a61b3c3bd244659ba4068daf9d2b1d2373d 100644 (file)
@@ -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
index 85c867696485e02a9c07965ba78ccc1ebb5d6390..fbf827604f2f1e43ff6e0d56324d0427e55cb1db 100644 (file)
@@ -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
index 9658c080c0c396a5f33ba1c34533db4943eff9ec..16609221c195334b596a20127169a4d5f0df55da 100755 (executable)
@@ -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