]> git.puffer.fish Git - mirror/frr.git/commitdiff
tests: only test count of nexthops in bgp max-paths test
authorMark Stapp <mjs@voltanet.io>
Tue, 10 Nov 2020 14:50:50 +0000 (09:50 -0500)
committerIgor Ryzhov <iryzhov@nfware.com>
Tue, 17 Nov 2020 18:07:58 +0000 (21:07 +0300)
Add support to compare the number of RIB nexthops, rather than the
specific nexthop addresses. Use this in the bgp_ecmp topotests that
test maximum-paths - testing the specific nexthops is wrong there,
it's not deterministic and we get spurious failures.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
tests/topotests/bgp-ecmp-topo2/test_ebgp_ecmp_topo2.py
tests/topotests/bgp-ecmp-topo2/test_ibgp_ecmp_topo2.py
tests/topotests/lib/common_config.py

index 6068f5f831dc7e6c4c7d0b7f443cefc7dd072016..9cb3046f005960d55bc1375572e72a94d7442752 100755 (executable)
@@ -296,6 +296,10 @@ def test_modify_ecmp_max_paths(request, ecmp_num, test_type):
         input_dict_1 = {"r3": {"static_routes": [{"network": NETWORK[addr_type]}]}}
 
         logger.info("Verifying %s routes on r3", addr_type)
+
+        # Only test the count of nexthops; the actual nexthop addresses
+        # can vary and are not deterministic.
+        #
         result = verify_rib(
             tgen,
             addr_type,
@@ -303,7 +307,9 @@ def test_modify_ecmp_max_paths(request, ecmp_num, test_type):
             input_dict_1,
             next_hop=NEXT_HOPS[addr_type][: int(ecmp_num)],
             protocol=protocol,
+            count_only=True
         )
+
         assert result is True, "Testcase {} : Failed \n Error: {}".format(
             tc_name, result
         )
index ae54019a0fc3fa1ac3286d40db4d26c8505cfbd5..96cdabf79bff23d3100f3550b9e96e263f2deccf 100755 (executable)
@@ -297,6 +297,10 @@ def test_modify_ecmp_max_paths(request, ecmp_num, test_type):
         input_dict_1 = {"r3": {"static_routes": [{"network": NETWORK[addr_type]}]}}
 
         logger.info("Verifying %s routes on r3", addr_type)
+
+        # Test only the count of nexthops, not the specific nexthop addresses -
+        # they're not deterministic
+        #
         result = verify_rib(
             tgen,
             addr_type,
@@ -304,7 +308,9 @@ def test_modify_ecmp_max_paths(request, ecmp_num, test_type):
             input_dict_1,
             next_hop=NEXT_HOPS[addr_type][: int(ecmp_num)],
             protocol=protocol,
+            count_only=True
         )
+
         assert result is True, "Testcase {} : Failed \n Error: {}".format(
             tc_name, result
         )
index a5385b0fcb4d107cbdc17ab6b28dd5f14ebb8b44..d5bc3ce2a9f0f073aa3188ba6bd098ff15abf498 100644 (file)
@@ -2475,6 +2475,7 @@ def verify_rib(
     tag=None,
     metric=None,
     fib=None,
+    count_only=False
 ):
     """
     Data will be read from input_dict or input JSON file, API will generate
@@ -2492,6 +2493,8 @@ def verify_rib(
     * `next_hop`[optional]: next_hop which needs to be verified,
                            default: static
     * `protocol`[optional]: protocol, default = None
+    * `count_only`[optional]: count of nexthops only, not specific addresses,
+                              default = False
 
     Usage
     -----
@@ -2655,7 +2658,23 @@ def verify_rib(
                                     for rib_r in rib_routes_json[st_rt][0]["nexthops"]
                                 ]
 
-                                if found_hops:
+                                # Check only the count of nexthops
+                                if count_only:
+                                    if len(next_hop) == len(found_hops):
+                                        nh_found = True
+                                    else:
+                                        errormsg = (
+                                            "Nexthops are missing for "
+                                            "route {} in RIB of router {}: "
+                                            "expected {}, found {}\n".format(
+                                                st_rt, dut, len(next_hop),
+                                                len(found_hops)
+                                            )
+                                        )
+                                        return errormsg
+
+                                # Check the actual nexthops
+                                elif found_hops:
                                     missing_list_of_nexthops = set(
                                         found_hops
                                     ).difference(next_hop)