summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/topotests/bgp-ecmp-topo2/test_ebgp_ecmp_topo2.py6
-rw-r--r--tests/topotests/bgp-ecmp-topo2/test_ibgp_ecmp_topo2.py6
-rw-r--r--tests/topotests/lib/common_config.py277
-rw-r--r--tests/topotests/route-scale/r1/installed.routes.json8
-rw-r--r--tests/topotests/route-scale/test_route_scale.py25
5 files changed, 51 insertions, 271 deletions
diff --git a/tests/topotests/bgp-ecmp-topo2/test_ebgp_ecmp_topo2.py b/tests/topotests/bgp-ecmp-topo2/test_ebgp_ecmp_topo2.py
index 12069a12dc..54a3c699f3 100644
--- a/tests/topotests/bgp-ecmp-topo2/test_ebgp_ecmp_topo2.py
+++ b/tests/topotests/bgp-ecmp-topo2/test_ebgp_ecmp_topo2.py
@@ -292,6 +292,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,
@@ -299,7 +303,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
)
diff --git a/tests/topotests/bgp-ecmp-topo2/test_ibgp_ecmp_topo2.py b/tests/topotests/bgp-ecmp-topo2/test_ibgp_ecmp_topo2.py
index 50aa281d34..73724ac069 100644
--- a/tests/topotests/bgp-ecmp-topo2/test_ibgp_ecmp_topo2.py
+++ b/tests/topotests/bgp-ecmp-topo2/test_ibgp_ecmp_topo2.py
@@ -293,6 +293,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,
@@ -300,7 +304,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
)
diff --git a/tests/topotests/lib/common_config.py b/tests/topotests/lib/common_config.py
index d83f946c42..e42992e294 100644
--- a/tests/topotests/lib/common_config.py
+++ b/tests/topotests/lib/common_config.py
@@ -2559,6 +2559,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
@@ -2576,6 +2577,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
-----
@@ -2739,7 +2742,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)
@@ -3019,262 +3038,6 @@ def verify_fib_routes(tgen, addr_type, dut, input_dict, next_hop=None):
for st_rt in ip_list:
st_rt = str(ipaddress.ip_network(frr_unicode(st_rt)))
- # st_rt = str(ipaddr.IPNetwork(unicode(st_rt)))
-
- _addr_type = validate_ip_address(st_rt)
- if _addr_type != addr_type:
- continue
-
- if st_rt in rib_routes_json:
- st_found = True
- found_routes.append(st_rt)
-
- if next_hop:
- if type(next_hop) is not list:
- next_hop = [next_hop]
-
- count = 0
- for nh in next_hop:
- for nh_dict in rib_routes_json[st_rt][0][
- "nexthops"
- ]:
- if nh_dict["ip"] != nh:
- continue
- else:
- count += 1
-
- if count == len(next_hop):
- nh_found = True
- else:
- missing_routes.append(st_rt)
- errormsg = (
- "Nexthop {} is Missing"
- " for route {} in "
- "RIB of router {}\n".format(
- next_hop, st_rt, dut
- )
- )
- return errormsg
-
- else:
- missing_routes.append(st_rt)
-
- if len(missing_routes) > 0:
- errormsg = "[DUT: {}]: Missing route in FIB:" " {}".format(
- dut, missing_routes
- )
- return errormsg
-
- if nh_found:
- logger.info(
- "Found next_hop {} for all routes in RIB"
- " of router {}\n".format(next_hop, dut)
- )
-
- if found_routes:
- logger.info(
- "[DUT: %s]: Verified routes in FIB, found" " routes are: %s\n",
- dut,
- found_routes,
- )
-
- continue
-
- if "bgp" in input_dict[routerInput]:
- if (
- "advertise_networks"
- not in input_dict[routerInput]["bgp"]["address_family"][addr_type][
- "unicast"
- ]
- ):
- continue
-
- found_routes = []
- missing_routes = []
- advertise_network = input_dict[routerInput]["bgp"]["address_family"][
- addr_type
- ]["unicast"]["advertise_networks"]
-
- # Continue if there are no network advertise
- if len(advertise_network) == 0:
- continue
-
- for advertise_network_dict in advertise_network:
- if "vrf" in advertise_network_dict:
- cmd = "{} vrf {} json".format(command, static_route["vrf"])
- else:
- cmd = "{} json".format(command)
-
- rib_routes_json = run_frr_cmd(rnode, cmd, isjson=True)
-
- # Verifying output dictionary rib_routes_json is not empty
- if bool(rib_routes_json) is False:
- errormsg = "No route found in rib of router {}..".format(router)
- return errormsg
-
- start_ip = advertise_network_dict["network"]
- if "no_of_network" in advertise_network_dict:
- no_of_network = advertise_network_dict["no_of_network"]
- else:
- no_of_network = 1
-
- # Generating IPs for verification
- ip_list = generate_ips(start_ip, no_of_network)
- st_found = False
- nh_found = False
-
- for st_rt in ip_list:
- # st_rt = str(ipaddr.IPNetwork(unicode(st_rt)))
- st_rt = str(ipaddress.ip_network(frr_unicode(st_rt)))
-
- _addr_type = validate_ip_address(st_rt)
- if _addr_type != addr_type:
- continue
-
- if st_rt in rib_routes_json:
- st_found = True
- found_routes.append(st_rt)
-
- if next_hop:
- if type(next_hop) is not list:
- next_hop = [next_hop]
-
- count = 0
- for nh in next_hop:
- for nh_dict in rib_routes_json[st_rt][0]["nexthops"]:
- if nh_dict["ip"] != nh:
- continue
- else:
- count += 1
-
- if count == len(next_hop):
- nh_found = True
- else:
- missing_routes.append(st_rt)
- errormsg = (
- "Nexthop {} is Missing"
- " for route {} in "
- "RIB of router {}\n".format(next_hop, st_rt, dut)
- )
- return errormsg
- else:
- missing_routes.append(st_rt)
-
- if len(missing_routes) > 0:
- errormsg = "[DUT: {}]: Missing route in FIB: " "{} \n".format(
- dut, missing_routes
- )
- return errormsg
-
- if nh_found:
- logger.info(
- "Found next_hop {} for all routes in RIB"
- " of router {}\n".format(next_hop, dut)
- )
-
- if found_routes:
- logger.info(
- "[DUT: {}]: Verified routes FIB"
- ", found routes are: {}\n".format(dut, found_routes)
- )
-
- logger.debug("Exiting lib API: {}".format(sys._getframe().f_code.co_name))
- return True
-
-
-@retry(attempts=5, wait=2, return_is_str=True, initial_wait=2)
-def verify_fib_routes(tgen, addr_type, dut, input_dict, next_hop=None):
- """
- Data will be read from input_dict or input JSON file, API will generate
- same prefixes, which were redistributed by either create_static_routes() or
- advertise_networks_using_network_command() and will verify next_hop and
- each prefix/routes is present in "show ip/ipv6 fib json"
- command o/p.
-
- Parameters
- ----------
- * `tgen` : topogen object
- * `addr_type` : ip type, ipv4/ipv6
- * `dut`: Device Under Test, for which user wants to test the data
- * `input_dict` : input dict, has details of static routes
- * `next_hop`[optional]: next_hop which needs to be verified,
- default: static
-
- Usage
- -----
- input_routes_r1 = {
- "r1": {
- "static_routes": [{
- "network": ["1.1.1.1/32],
- "next_hop": "Null0",
- "vrf": "RED"
- }]
- }
- }
- result = result = verify_fib_routes(tgen, "ipv4, "r1", input_routes_r1)
-
- Returns
- -------
- errormsg(str) or True
- """
-
- logger.debug("Entering lib API: {}".format(sys._getframe().f_code.co_name))
-
- router_list = tgen.routers()
- for routerInput in input_dict.keys():
- for router, rnode in router_list.items():
- if router != dut:
- continue
-
- logger.info("Checking router %s FIB routes:", router)
-
- # Verifying RIB routes
- if addr_type == "ipv4":
- command = "show ip fib"
- else:
- command = "show ipv6 fib"
-
- found_routes = []
- missing_routes = []
-
- if "static_routes" in input_dict[routerInput]:
- static_routes = input_dict[routerInput]["static_routes"]
-
- for static_route in static_routes:
- if "vrf" in static_route and static_route["vrf"] is not None:
-
- logger.info(
- "[DUT: {}]: Verifying routes for VRF:"
- " {}".format(router, static_route["vrf"])
- )
-
- cmd = "{} vrf {}".format(command, static_route["vrf"])
-
- else:
- cmd = "{}".format(command)
-
- cmd = "{} json".format(cmd)
-
- rib_routes_json = run_frr_cmd(rnode, cmd, isjson=True)
-
- # Verifying output dictionary rib_routes_json is not empty
- if bool(rib_routes_json) is False:
- errormsg = "[DUT: {}]: No route found in fib".format(router)
- return errormsg
-
- network = static_route["network"]
- if "no_of_ip" in static_route:
- no_of_ip = static_route["no_of_ip"]
- else:
- no_of_ip = 1
-
- # Generating IPs for verification
- ip_list = generate_ips(network, no_of_ip)
- st_found = False
- nh_found = False
-
- for st_rt in ip_list:
- st_rt = str(ipaddress.ip_network(frr_unicode(st_rt)))
_addr_type = validate_ip_address(st_rt)
if _addr_type != addr_type:
diff --git a/tests/topotests/route-scale/r1/installed.routes.json b/tests/topotests/route-scale/r1/installed.routes.json
index 25d209f9eb..24a45dca81 100644
--- a/tests/topotests/route-scale/r1/installed.routes.json
+++ b/tests/topotests/route-scale/r1/installed.routes.json
@@ -6,11 +6,11 @@
"type":"connected"
},
{
- "fib":1000000,
- "rib":1000000,
+ "fib":200000,
+ "rib":200000,
"type":"sharp"
}
],
- "routesTotal":1000032,
- "routesTotalFib":1000032
+ "routesTotal":200032,
+ "routesTotalFib":200032
}
diff --git a/tests/topotests/route-scale/test_route_scale.py b/tests/topotests/route-scale/test_route_scale.py
index 8aedfc198c..bbd6ef8d60 100644
--- a/tests/topotests/route-scale/test_route_scale.py
+++ b/tests/topotests/route-scale/test_route_scale.py
@@ -122,15 +122,20 @@ def run_one_setup(r1, s):
expected_installed = s["expect_in"]
expected_removed = s["expect_rem"]
- count = s["count"]
+ retries = s["retries"]
wait = s["wait"]
- logger.info("Testing 1 million routes X {} ecmp".format(s["ecmp"]))
+ for d in expected_installed["routes"]:
+ if d["type"] == "sharp":
+ count = d["rib"]
+ break
+
+ logger.info("Testing {} routes X {} ecmp".format(count, s["ecmp"]))
r1.vtysh_cmd(
"sharp install route 1.0.0.0 \
- nexthop-group {} 1000000".format(
- s["nhg"]
+ nexthop-group {} {}".format(
+ s["nhg"], count
),
isjson=False,
)
@@ -138,21 +143,21 @@ def run_one_setup(r1, s):
test_func = partial(
topotest.router_json_cmp, r1, "show ip route summary json", expected_installed
)
- success, result = topotest.run_and_expect(test_func, None, count, wait)
+ success, result = topotest.run_and_expect(test_func, None, retries, wait)
assert success, "Route scale test install failed:\n{}".format(result)
output = r1.vtysh_cmd("sharp data route", isjson=False)
- logger.info("1 million routes X {} ecmp installed".format(s["ecmp"]))
+ logger.info("{} routes X {} ecmp installed".format(count, s["ecmp"]))
logger.info(output)
- r1.vtysh_cmd("sharp remove route 1.0.0.0 1000000", isjson=False)
+ r1.vtysh_cmd("sharp remove route 1.0.0.0 {}".format(count), isjson=False)
test_func = partial(
topotest.router_json_cmp, r1, "show ip route summary json", expected_removed
)
- success, result = topotest.run_and_expect(test_func, None, count, wait)
+ success, result = topotest.run_and_expect(test_func, None, retries, wait)
assert success, "Route scale test remove failed:\n{}".format(result)
output = r1.vtysh_cmd("sharp data route", isjson=False)
- logger.info("1 million routes x {} ecmp removed".format(s["ecmp"]))
+ logger.info("{} routes x {} ecmp removed".format(count, s["ecmp"]))
logger.info(output)
@@ -174,7 +179,7 @@ def test_route_install():
# dict keys of params: ecmp number, corresponding nhg name, timeout,
# number of times to wait
- scale_keys = ["ecmp", "nhg", "wait", "count", "expect_in", "expect_rem"]
+ scale_keys = ["ecmp", "nhg", "wait", "retries", "expect_in", "expect_rem"]
# Table of defaults, used for timeout values and 'expected' objects
scale_defaults = dict(