From: naveen Date: Tue, 14 Apr 2020 06:34:36 +0000 (+0530) Subject: tests: Enchanced static routing testsuits X-Git-Tag: frr-8.0.1~712^2~8 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=ee51a3d9ec604b0d732a4d8a41d24a6bd140c92f;p=mirror_frr.git tests: Enchanced static routing testsuits 1. BGP timers are modified to reduce the run time. 2. Static sleeps are removed from the scripts. Signed-off-by: naveen --- 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 54a3c699f..28a1b98eb 100644 --- a/tests/topotests/bgp-ecmp-topo2/test_ebgp_ecmp_topo2.py +++ b/tests/topotests/bgp-ecmp-topo2/test_ebgp_ecmp_topo2.py @@ -312,9 +312,9 @@ def test_modify_ecmp_max_paths(request, ecmp_num, test_type): write_test_footer(tc_name) - +@pytest.mark.parametrize("ecmp_num", ["8", "16", "32"]) @pytest.mark.parametrize("test_type", ["redist_static", "advertise_nw"]) -def test_ecmp_after_clear_bgp(request, test_type): +def test_ecmp_after_clear_bgp(request, ecmp_num, test_type): """ Verify BGP table and RIB in DUT after clear BGP routes and neighbors""" tc_name = request.node.name @@ -337,7 +337,7 @@ def test_ecmp_after_clear_bgp(request, test_type): addr_type, dut, input_dict_1, - next_hop=NEXT_HOPS[addr_type], + next_hop=NEXT_HOPS[addr_type][:int(ecmp_num)], protocol=protocol, ) assert result is True, "Testcase {} : Failed \n Error: {}".format( @@ -360,7 +360,7 @@ def test_ecmp_after_clear_bgp(request, test_type): addr_type, dut, input_dict_1, - next_hop=NEXT_HOPS[addr_type], + next_hop=NEXT_HOPS[addr_type][:int(ecmp_num)], protocol=protocol, ) assert result is True, "Testcase {} : Failed \n Error: {}".format( 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 73724ac06..4d8003c4b 100644 --- a/tests/topotests/bgp-ecmp-topo2/test_ibgp_ecmp_topo2.py +++ b/tests/topotests/bgp-ecmp-topo2/test_ibgp_ecmp_topo2.py @@ -313,9 +313,9 @@ def test_modify_ecmp_max_paths(request, ecmp_num, test_type): write_test_footer(tc_name) - +@pytest.mark.parametrize("ecmp_num", ["8", "16", "32"]) @pytest.mark.parametrize("test_type", ["redist_static", "advertise_nw"]) -def test_ecmp_after_clear_bgp(request, test_type): +def test_ecmp_after_clear_bgp(request, ecmp_num, test_type): """ Verify BGP table and RIB in DUT after clear BGP routes and neighbors""" tc_name = request.node.name @@ -338,7 +338,7 @@ def test_ecmp_after_clear_bgp(request, test_type): addr_type, dut, input_dict_1, - next_hop=NEXT_HOPS[addr_type], + next_hop=NEXT_HOPS[addr_type][:int(ecmp_num)], protocol=protocol, ) assert result is True, "Testcase {} : Failed \n Error: {}".format( @@ -361,7 +361,7 @@ def test_ecmp_after_clear_bgp(request, test_type): addr_type, dut, input_dict_1, - next_hop=NEXT_HOPS[addr_type], + next_hop=NEXT_HOPS[addr_type][:int(ecmp_num)], protocol=protocol, ) assert result is True, "Testcase {} : Failed \n Error: {}".format( diff --git a/tests/topotests/static_routing_with_ebgp/static_routes_topo1_ebgp.json b/tests/topotests/static_routing_with_ebgp/static_routes_topo1_ebgp.json index 9d337f6cd..7099043ad 100644 --- a/tests/topotests/static_routing_with_ebgp/static_routes_topo1_ebgp.json +++ b/tests/topotests/static_routing_with_ebgp/static_routes_topo1_ebgp.json @@ -73,7 +73,10 @@ "neighbor": { "r3": { "dest_link": { - "r2": {} + "r2": { + "keepalivetimer": 1, + "holddowntimer": 4 + } } } } @@ -84,7 +87,10 @@ "neighbor": { "r3": { "dest_link": { - "r2": {} + "r2": { + "keepalivetimer": 1, + "holddowntimer": 4 + } } } } @@ -121,7 +127,10 @@ "neighbor": { "r2": { "dest_link": { - "r3": {} + "r3": { + "keepalivetimer": 1, + "holddowntimer": 4 + } } } } @@ -132,7 +141,10 @@ "neighbor": { "r2": { "dest_link": { - "r3": {} + "r3": { + "keepalivetimer": 1, + "holddowntimer": 4 + } } } } diff --git a/tests/topotests/static_routing_with_ebgp/static_routes_topo2_ebgp.json b/tests/topotests/static_routing_with_ebgp/static_routes_topo2_ebgp.json index fc849d807..91820b049 100644 --- a/tests/topotests/static_routing_with_ebgp/static_routes_topo2_ebgp.json +++ b/tests/topotests/static_routing_with_ebgp/static_routes_topo2_ebgp.json @@ -141,14 +141,38 @@ "neighbor": { "r3": { "dest_link": { - "r2-link0": {}, - "r2-link1": {}, - "r2-link2": {}, - "r2-link3": {}, - "r2-link4": {}, - "r2-link5": {}, - "r2-link6": {}, - "r2-link7": {} + "r2-link0": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link1": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link2": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link3": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link4": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link5": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link6": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link7": { + "keepalivetimer": 1, + "holddowntimer": 4 + } } } }, @@ -162,14 +186,38 @@ "neighbor": { "r3": { "dest_link": { - "r2-link0": {}, - "r2-link1": {}, - "r2-link2": {}, - "r2-link3": {}, - "r2-link4": {}, - "r2-link5": {}, - "r2-link6": {}, - "r2-link7": {} + "r2-link0": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link1": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link2": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link3": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link4": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link5": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link6": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link7": { + "keepalivetimer": 1, + "holddowntimer": 4 + } } } }, @@ -229,14 +277,38 @@ "neighbor": { "r2": { "dest_link": { - "r3-link0": {}, - "r3-link1": {}, - "r3-link2": {}, - "r3-link3": {}, - "r3-link4": {}, - "r3-link5": {}, - "r3-link6": {}, - "r3-link7": {} + "r3-link0": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link1": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link2": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link3": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link4": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link5": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link6": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link7": { + "keepalivetimer": 1, + "holddowntimer": 4 + } } } } @@ -247,14 +319,38 @@ "neighbor": { "r2": { "dest_link": { - "r3-link0": {}, - "r3-link1": {}, - "r3-link2": {}, - "r3-link3": {}, - "r3-link4": {}, - "r3-link5": {}, - "r3-link6": {}, - "r3-link7": {} + "r3-link0": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link1": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link2": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link3": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link4": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link5": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link6": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link7": { + "keepalivetimer": 1, + "holddowntimer": 4 + } } } } diff --git a/tests/topotests/static_routing_with_ebgp/static_routes_topo3_ebgp.json b/tests/topotests/static_routing_with_ebgp/static_routes_topo3_ebgp.json index 7c1d7f879..5246a311e 100644 --- a/tests/topotests/static_routing_with_ebgp/static_routes_topo3_ebgp.json +++ b/tests/topotests/static_routing_with_ebgp/static_routes_topo3_ebgp.json @@ -113,7 +113,10 @@ "neighbor": { "r3": { "dest_link": { - "r2-link0": {} + "r2-link0": { + "keepalivetimer": 1, + "holddowntimer": 4 + } } } } @@ -124,7 +127,10 @@ "neighbor": { "r3": { "dest_link": { - "r2-link0": {} + "r2-link0": { + "keepalivetimer": 1, + "holddowntimer": 4 + } } } } @@ -153,7 +159,10 @@ "neighbor": { "r2": { "dest_link": { - "r3-link0": {} + "r3-link0": { + "keepalivetimer": 1, + "holddowntimer": 4 + } } } } @@ -164,7 +173,10 @@ "neighbor": { "r2": { "dest_link": { - "r3-link0": {} + "r3-link0": { + "keepalivetimer": 1, + "holddowntimer": 4 + } } } } diff --git a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo1_ebgp.py b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo1_ebgp.py index 7a31ec53c..f9da18868 100644 --- a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo1_ebgp.py +++ b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo1_ebgp.py @@ -35,7 +35,6 @@ import time import os import pytest import ipaddr -from time import sleep # Save the Current Working Directory to find configuration files. CWD = os.path.dirname(os.path.realpath(__file__)) @@ -533,7 +532,7 @@ def test_static_route_2nh_p0_tc_1_ebgp(request): step("Reload the FRR router") # stop/start -> restart FRR router and verify stop_router(tgen, "r2") - sleep(5) + start_router(tgen, "r2") dut = "r2" @@ -990,7 +989,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ebgp(request): step("Reload the FRR router") # stop/start -> restart FRR router and verify stop_router(tgen, "r2") - sleep(5) + start_router(tgen, "r2") step( diff --git a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo2_ebgp.py b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo2_ebgp.py index e9ca4d7ae..698d581b1 100644 --- a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo2_ebgp.py +++ b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo2_ebgp.py @@ -471,7 +471,7 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): intf = topo["routers"]["r2"]["links"]["r1-link{}".format(randnum)]["interface"] shutdown_bringup_interface(tgen, dut, intf, False) - sleep(5) + step("Random no shut of the nexthop interfaces") # Bringup interface @@ -564,7 +564,7 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): step("Reload the FRR router") # stop/start -> restart FRR router and verify stop_router(tgen, "r2") - sleep(5) + start_router(tgen, "r2") step( @@ -607,7 +607,8 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ebgp(request): intf = topo["routers"]["r2"]["links"]["r3-link{}".format(intfr)]["interface"] shutdown_bringup_interface(tgen, dut, intf, False) - sleep(200) + # sleep for twice the holddowntimer so that bgp deletes the neighbors. + sleep(8) step("verify bgp convergence as all interface are shut") @@ -1046,7 +1047,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ebgp(request): step("Reload the FRR router") # stop/start -> restart FRR router and verify stop_router(tgen, "r2") - sleep(5) + start_router(tgen, "r2") for addr_type in ADDR_TYPES: @@ -1511,7 +1512,7 @@ def test_static_route_8nh_diff_AD_ebgp_ecmp_p1_tc8_ebgp(request): step("Reload the FRR router") # stop/start -> restart FRR router and verify stop_router(tgen, "r2") - sleep(5) + start_router(tgen, "r2") for addr_type in ADDR_TYPES: @@ -1950,7 +1951,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): step("Reload the FRR router") # stop/start -> restart FRR router and verify stop_router(tgen, "r2") - sleep(5) + start_router(tgen, "r2") step("After reloading, verify that routes are still present in R2.") @@ -1981,7 +1982,8 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): "interface" ] shutdown_bringup_interface(tgen, dut, intf, False) - sleep(180) + # sleep for twice the holddowntimer so that bgp deletes the neighbors. + sleep(8) step("verify bgp convergence as all interface are shut") bgp_convergence = verify_bgp_convergence(tgen, topo) @@ -2032,7 +2034,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): assert result is not True, "Testcase {} : Failed \nError: Routes " " are still present in RIB after BGP nbr is down".format(tc_name) - sleep(5) + dut = "r2" for intfr in range(0, 8): intf = topo["routers"]["r2"]["links"]["r3-link{}".format(intfr)][ @@ -2040,7 +2042,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ebgp(request): ] shutdown_bringup_interface(tgen, dut, intf, True) - sleep(5) + dut = "r3" for intfr in range(0, 8): intf = topo["routers"]["r3"]["links"]["r2-link{}".format(intfr)][ diff --git a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo3_ebgp.py b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo3_ebgp.py index e055a161c..3017b3c18 100644 --- a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo3_ebgp.py +++ b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo3_ebgp.py @@ -36,7 +36,6 @@ import time import os import pytest import ipaddr -from time import sleep from copy import deepcopy import random from re import search as re_search @@ -447,7 +446,6 @@ def test_staticroute_with_ecmp_p0_tc3_ebgp(request): step("Reload the FRR router") # stop/start -> restart FRR router and verify stop_router(tgen, "r2") - sleep(5) start_router(tgen, "r2") result = verify_rib( @@ -801,7 +799,6 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ebgp(request): step("Reload the FRR router") # stop/start -> restart FRR router and verify stop_router(tgen, "r2") - sleep(5) start_router(tgen, "r2") step( diff --git a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo4_ebgp.py b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo4_ebgp.py index a0894074c..14450cdab 100644 --- a/tests/topotests/static_routing_with_ebgp/test_static_routes_topo4_ebgp.py +++ b/tests/topotests/static_routing_with_ebgp/test_static_routes_topo4_ebgp.py @@ -36,7 +36,6 @@ import os import pytest import ipaddr import ipaddress -from time import sleep from copy import deepcopy # Save the Current Working Directory to find configuration files. diff --git a/tests/topotests/static_routing_with_ibgp/static_routes_topo1_ibgp.json b/tests/topotests/static_routing_with_ibgp/static_routes_topo1_ibgp.json index 5f263072a..99b197366 100644 --- a/tests/topotests/static_routing_with_ibgp/static_routes_topo1_ibgp.json +++ b/tests/topotests/static_routing_with_ibgp/static_routes_topo1_ibgp.json @@ -73,7 +73,10 @@ "neighbor": { "r3": { "dest_link": { - "r2": {} + "r2": { + "keepalivetimer": 1, + "holddowntimer": 4 + } } } } @@ -84,7 +87,10 @@ "neighbor": { "r3": { "dest_link": { - "r2": {} + "r2": { + "keepalivetimer": 1, + "holddowntimer": 4 + } } } } @@ -121,7 +127,10 @@ "neighbor": { "r2": { "dest_link": { - "r3": {} + "r3": { + "keepalivetimer": 1, + "holddowntimer": 4 + } } } } @@ -132,7 +141,10 @@ "neighbor": { "r2": { "dest_link": { - "r3": {} + "r3": { + "keepalivetimer": 1, + "holddowntimer": 4 + } } } } diff --git a/tests/topotests/static_routing_with_ibgp/static_routes_topo2_ibgp.json b/tests/topotests/static_routing_with_ibgp/static_routes_topo2_ibgp.json index 7537e5cf9..47596a0a1 100644 --- a/tests/topotests/static_routing_with_ibgp/static_routes_topo2_ibgp.json +++ b/tests/topotests/static_routing_with_ibgp/static_routes_topo2_ibgp.json @@ -140,15 +140,41 @@ "unicast": { "neighbor": { "r3": { + + "dest_link": { - "r2-link0": {}, - "r2-link1": {}, - "r2-link2": {}, - "r2-link3": {}, - "r2-link4": {}, - "r2-link5": {}, - "r2-link6": {}, - "r2-link7": {} + "r2-link0": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link1": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link2": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link3": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link4": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link5": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link6": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link7": { + "keepalivetimer": 1, + "holddowntimer": 4 + } } } }, @@ -161,15 +187,41 @@ "unicast": { "neighbor": { "r3": { + + "dest_link": { - "r2-link0": {}, - "r2-link1": {}, - "r2-link2": {}, - "r2-link3": {}, - "r2-link4": {}, - "r2-link5": {}, - "r2-link6": {}, - "r2-link7": {} + "r2-link0": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link1": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link2": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link3": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link4": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link5": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link6": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r2-link7": { + "keepalivetimer": 1, + "holddowntimer": 4 + } } } }, @@ -228,15 +280,41 @@ "unicast": { "neighbor": { "r2": { + + "dest_link": { - "r3-link0": {}, - "r3-link1": {}, - "r3-link2": {}, - "r3-link3": {}, - "r3-link4": {}, - "r3-link5": {}, - "r3-link6": {}, - "r3-link7": {} + "r3-link0": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link1": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link2": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link3": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link4": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link5": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link6": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link7": { + "keepalivetimer": 1, + "holddowntimer": 4 + } } } } @@ -246,15 +324,41 @@ "unicast": { "neighbor": { "r2": { + + "dest_link": { - "r3-link0": {}, - "r3-link1": {}, - "r3-link2": {}, - "r3-link3": {}, - "r3-link4": {}, - "r3-link5": {}, - "r3-link6": {}, - "r3-link7": {} + "r3-link0": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link1": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link2": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link3": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link4": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link5": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link6": { + "keepalivetimer": 1, + "holddowntimer": 4 + }, + "r3-link7": { + "keepalivetimer": 1, + "holddowntimer": 4 + } } } } diff --git a/tests/topotests/static_routing_with_ibgp/static_routes_topo3_ibgp.json b/tests/topotests/static_routing_with_ibgp/static_routes_topo3_ibgp.json index 3346609c5..4e27229f3 100644 --- a/tests/topotests/static_routing_with_ibgp/static_routes_topo3_ibgp.json +++ b/tests/topotests/static_routing_with_ibgp/static_routes_topo3_ibgp.json @@ -113,7 +113,10 @@ "neighbor": { "r3": { "dest_link": { - "r2-link0": {} + "r2-link0": { + "keepalivetimer": 1, + "holddowntimer": 4 + } } } } @@ -124,7 +127,10 @@ "neighbor": { "r3": { "dest_link": { - "r2-link0": {} + "r2-link0": { + "keepalivetimer": 1, + "holddowntimer": 4 + } } } } @@ -153,7 +159,10 @@ "neighbor": { "r2": { "dest_link": { - "r3-link0": {} + "r3-link0": { + "keepalivetimer": 1, + "holddowntimer": 4 + } } } } @@ -164,7 +173,10 @@ "neighbor": { "r2": { "dest_link": { - "r3-link0": {} + "r3-link0": { + "keepalivetimer": 1, + "holddowntimer": 4 + } } } } diff --git a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo1_ibgp.py b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo1_ibgp.py index dc68f16ac..cf4868123 100644 --- a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo1_ibgp.py +++ b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo1_ibgp.py @@ -35,7 +35,6 @@ import time import os import pytest import ipaddr -from time import sleep from copy import deepcopy # Save the Current Working Directory to find configuration files. @@ -532,7 +531,7 @@ def test_static_route_2nh_p0_tc_1_ibgp(request): step("Reload the FRR router") # stop/start -> restart FRR router and verify stop_router(tgen, "r2") - sleep(5) + start_router(tgen, "r2") dut = "r2" @@ -989,7 +988,7 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): step("Reload the FRR router") # stop/start -> restart FRR router and verify stop_router(tgen, "r2") - sleep(5) + start_router(tgen, "r2") step( @@ -1071,243 +1070,6 @@ def test_static_route_2nh_admin_dist_p0_tc_2_ibgp(request): write_test_footer(tc_name) -""" -def test_same_rte_from_bgp_static_P0_tc5(request): - - #Verify RIB status when same route advertise via BGP and static - #route - - - tc_name = request.node.name - write_test_header(tc_name) - tgen = get_topogen() - # Don't run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - - NEXT_HOP_IP = populate_nh() - step('Configure iBGP IPv4 peering between R2 and R3 router.') - reset_config_on_routers(tgen) - step( - 'Configure IPv4 static route (10.1.1.1/24) in R2 with next hop' - 'N1 (28.1.1.2 ) and N2 (29.1.1.2) , Static route next-hop present' - 'on R1') - - for addr_type in ADDR_TYPES: - input_dict_4 = { - "r2": { - "static_routes": [ - { - "network": NETWORK[addr_type], - "next_hop": NEXT_HOP_IP['nh1'][addr_type] - }, - { - "network": NETWORK[addr_type], - "next_hop": NEXT_HOP_IP['nh2'][addr_type] - } - ] - } - } - logger.info("Configure static routes") - result = create_static_routes(tgen, input_dict_4) - assert result is True, "Testcase {} : Failed \n Error: {}".format( - tc_name, result) - - step('Configure redistribute static in BGP.') - for addr_type in ADDR_TYPES: - input_dict_2 = { - "r2": { - "bgp": { - "address_family": { - addr_type: { - "unicast": { - "redistribute": [{ - "redist_type": "static" - }] - } - } - } - } - } - } - result = create_router_bgp(tgen, topo, input_dict_2) - assert result is True, "Testcase {} : Failed \n Error: {}".format( - tc_name, result) - step("Verify on R3 , route receive on R3 BGP table ") - dut = 'r3' - result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" - " still present in RIB".format(tc_name) - - step("Verify route installed in the RIB and FIB of R3") - protocol = 'bgp' - result = verify_rib( - tgen, addr_type, dut, input_dict_4, protocol=protocol) - assert result is True, "Testcase {} : Failed \nError: Route is" - " still present in RIB".format(tc_name) - - step( - 'Configure 2 links/interfaces between R1 and R3 , keep one' - 'interface in shut (active) state and other interface in no shut' - '(inactive) state') - dut = 'r3' - intf = topo['routers']['r3']['links']['r1-link0']['interface'] - shutdown_bringup_interface(tgen, dut, intf, False) - - step( - 'Configure same static route (10.1.1.1/24) in R3 with inactive' - 'nexthop interface') - - step( - 'Configure same static route 10.1.1.1/24) again in R3 with' - 'active nexthop interface') - for addr_type in ADDR_TYPES: - input_dict_4 = { - "r3": { - "static_routes": [ - { - "network": NETWORK[addr_type], - "next_hop": topo['routers']['r1']['links']['r3-link0'][ - addr_type] - }, - { - "network": NETWORK[addr_type], - "next_hop": topo['routers']['r1']['links']['r3-link1'][ - addr_type] - } - ] - } - } - logger.info("Configure static routes") - result = create_static_routes(tgen, input_dict_4) - assert result is True, "Testcase {} : Failed \n Error: {}".format( - tc_name, result) - - step( - "Verify when static route configure with inactive nexthop , " - "verify BGP received route is active in the RIB and FIB") - dut = 'r3' - result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" - " missing in BGP RIB".format(tc_name) - - protocol = 'bgp' - result = verify_rib( - tgen, addr_type, dut, input_dict_4, protocol=protocol, fib=True) - assert result is True, "Testcase {} : Failed \nError: Route is" - " missing in RIB".format(tc_name) - - step('Remove the redistribute static knob from R2 router') - for addr_type in ADDR_TYPES: - input_dict_2 = { - "r2": { - "bgp": { - "address_family": { - addr_type: { - "unicast": { - "redistribute": [{ - "redist_type": "static", - "delete": True - }] - } - } - } - } - } - } - result = create_router_bgp(tgen, topo, input_dict_2) - assert result is True, "Testcase {} : Failed \n Error: {}".format( - tc_name, result) - - step( - "After removing /adding the redistribute static knob , " - "BGP received route is deleted and added in RIB of R3 ") - dut = 'r3' - result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is not True, "Testcase {} : Failed \nError: Route is" - " still present in RIB".format(tc_name) - - protocol = 'bgp' - result = verify_rib( - tgen, addr_type, dut, input_dict_4, protocol=protocol, fib=True) - assert result is not True, "Testcase {} : Failed \nError: Route is" - " still present in RIB".format(tc_name) - - step('Configure the redistribute static knob again on R2 router') - for addr_type in ADDR_TYPES: - input_dict_2 = { - "r2": { - "bgp": { - "address_family": { - addr_type: { - "unicast": { - "redistribute": [{ - "redist_type": "static", - }] - } - } - } - } - } - } - result = create_router_bgp(tgen, topo, input_dict_2) - assert result is True, "Testcase {} : Failed \n Error: {}".format( - tc_name, result) - dut = 'r3' - result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" - " missing in BGP RIB".format(tc_name) - - protocol = 'bgp' - result = verify_rib( - tgen, addr_type, dut, input_dict_4, protocol=protocol, fib=True) - assert result is True, "Testcase {} : Failed \nError: Route is" - " missing in RIB".format(tc_name) - - step( - 'Remove the static route on R3 configured with active' - 'interface') - for addr_type in ADDR_TYPES: - input_dict_4 = { - "r3": { - "static_routes": [ - { - "network": NETWORK[addr_type], - "next_hop": topo['routers']['r1']['links']['r3-link0'][ - addr_type], - "delete": True - }, - { - "network": NETWORK[addr_type], - "next_hop": topo['routers']['r1']['links']['r3-link1'][ - addr_type], - "delete": True - } - ] - } - } - logger.info("Configure static routes") - result = create_static_routes(tgen, input_dict_4) - assert result is True, "Testcase {} : Failed \n Error: {}".format( - tc_name, result) - step( - "After removing the static route with active nexthop verify " - "BGP received route is became active in RIB and FIB") - dut = 'r3' - result = verify_bgp_rib(tgen, addr_type, dut, input_dict_4) - assert result is True, "Testcase {} : Failed \nError: Route is" - " missing in BGP RIB".format(tc_name) - - protocol = 'bgp' - result = verify_rib( - tgen, addr_type, dut, input_dict_4, protocol=protocol, fib=True) - assert result is True, "Testcase {} : Failed \nError: Route is" - " missing in RIB".format(tc_name) - - write_test_footer(tc_name) -""" - - if __name__ == "__main__": args = ["-s"] + sys.argv[1:] sys.exit(pytest.main(args)) diff --git a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo2_ibgp.py b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo2_ibgp.py index 0e051d691..a9dee567d 100644 --- a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo2_ibgp.py +++ b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo2_ibgp.py @@ -473,7 +473,7 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): intf = topo["routers"]["r2"]["links"]["r1-link{}".format(randnum)]["interface"] shutdown_bringup_interface(tgen, dut, intf, False) - sleep(5) + step("Random no shut of the nexthop interfaces") # Bringup interface @@ -566,7 +566,7 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): step("Reload the FRR router") # stop/start -> restart FRR router and verify stop_router(tgen, "r2") - sleep(5) + start_router(tgen, "r2") step( @@ -609,7 +609,8 @@ def test_static_rte_with_8ecmp_nh_p1_tc9_ibgp(request): intf = topo["routers"]["r2"]["links"]["r3-link{}".format(intfr)]["interface"] shutdown_bringup_interface(tgen, dut, intf, False) - sleep(200) + # sleep for twice the holddowntimer so that bgp deletes the neighbors. + sleep(8) step("verify bgp convergence as all interface are shut") @@ -1062,7 +1063,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc6_ibgp(request): step("Reload the FRR router") # stop/start -> restart FRR router and verify stop_router(tgen, "r2") - sleep(5) + start_router(tgen, "r2") for addr_type in ADDR_TYPES: @@ -1530,7 +1531,7 @@ def test_static_route_8nh_diff_AD_ibgp_ecmp_p1_tc7_ibgp(request): step("Reload the FRR router") # stop/start -> restart FRR router and verify stop_router(tgen, "r2") - sleep(5) + start_router(tgen, "r2") for addr_type in ADDR_TYPES: @@ -1969,7 +1970,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): step("Reload the FRR router") # stop/start -> restart FRR router and verify stop_router(tgen, "r2") - sleep(5) + start_router(tgen, "r2") step("After reloading, verify that routes are still present in R2.") @@ -2000,7 +2001,8 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): "interface" ] shutdown_bringup_interface(tgen, dut, intf, False) - sleep(180) + # sleep for twice the holddowntimer so that bgp deletes the neighbors. + sleep(8) step("verify bgp convergence as all interface are shut") bgp_convergence = verify_bgp_convergence(tgen, topo) @@ -2051,7 +2053,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): assert result is not True, "Testcase {} : Failed \nError: Routes " " are still present in RIB after BGP nbr is down".format(tc_name) - sleep(5) + dut = "r2" for intfr in range(0, 8): intf = topo["routers"]["r2"]["links"]["r3-link{}".format(intfr)][ @@ -2059,7 +2061,7 @@ def test_static_route_8nh_diff_AD_bgp_ecmp_p1_tc10_ibgp(request): ] shutdown_bringup_interface(tgen, dut, intf, True) - sleep(5) + dut = "r3" for intfr in range(0, 8): intf = topo["routers"]["r3"]["links"]["r2-link{}".format(intfr)][ diff --git a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo3_ibgp.py b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo3_ibgp.py index 3458893f6..8e8b84f8a 100644 --- a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo3_ibgp.py +++ b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo3_ibgp.py @@ -36,7 +36,6 @@ import time import os import pytest import ipaddr -from time import sleep from copy import deepcopy import random from re import search as re_search @@ -447,7 +446,7 @@ def test_staticroute_with_ecmp_p0_tc3_ibgp(request): step("Reload the FRR router") # stop/start -> restart FRR router and verify stop_router(tgen, "r2") - sleep(5) + start_router(tgen, "r2") result = verify_rib( @@ -801,7 +800,7 @@ def test_staticroute_with_ecmp_with_diff_AD_p0_tc4_ibgp(request): step("Reload the FRR router") # stop/start -> restart FRR router and verify stop_router(tgen, "r2") - sleep(5) + start_router(tgen, "r2") step( diff --git a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo4_ibgp.py b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo4_ibgp.py index abc89b90e..269318428 100644 --- a/tests/topotests/static_routing_with_ibgp/test_static_routes_topo4_ibgp.py +++ b/tests/topotests/static_routing_with_ibgp/test_static_routes_topo4_ibgp.py @@ -26,7 +26,6 @@ Following tests are covered in the script. - Verify static route are blocked from route-map and prefix-list applied in BGP nbrs -- Verify Static route when FRR connected to 2 TOR """ import sys @@ -36,7 +35,6 @@ import os import pytest import ipaddr import ipaddress -from time import sleep from copy import deepcopy # Save the Current Working Directory to find configuration files. @@ -47,14 +45,12 @@ sys.path.append(os.path.join(CWD, "../lib/")) # Import topogen and topotest helpers from mininet.topo import Topo from lib.topogen import Topogen, get_topogen -from time import sleep from lib.common_config import ( start_topology, write_test_header, write_test_footer, reset_config_on_routers, - verify_kernel_ping, verify_rib, create_static_routes, check_address_types, @@ -987,227 +983,6 @@ def test_static_routes_rmap_pfxlist_p0_tc7_ibgp(request): write_test_footer(tc_name) -def test_static_routes_tor_p0_tc5_ibgp(request): - """Verify Static route when FRR connected to 2 TOR.""" - tc_name = request.node.name - write_test_header(tc_name) - tgen = get_topogen() - # Don't run this test if we have any failure. - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - step("Configure link between FRR to FRR1 & FRR2 as shown in the topology.") - step("Attach 2 VMs (vm1 & vm2) to FRR, vm3 to FRR1 ,vm4 to FRR2.") - step("Configure Ipv4 and ipv6 addresses on all the interfaces.") - - reset_config_on_routers(tgen) - - def_nw = {"ipv4": "0.0.0.0/0", "ipv6": "0::0/0"} - step( - "Configure the static route (ipv4 & ipv6) on FRR to vm3 and vm4 " - "with next hop as FRR1 and FRR2 respectively." - ) - for addr_type in ADDR_TYPES: - # Enable static routes - for vm in ["vm1", "vm2", "vm3", "vm6"]: - input_dict_4 = { - vm: { - "static_routes": [ - { - "network": def_nw[addr_type], - "next_hop": topo["routers"]["r2"]["links"][vm][ - addr_type - ].split("/")[0], - } - ] - } - } - logger.info("Configure static routes") - result = create_static_routes(tgen, input_dict_4) - assert result is True, "Testcase {} : Failed \n Error: {}".format( - tc_name, result - ) - - input_dict_4 = { - "vm4": { - "static_routes": [ - { - "network": def_nw[addr_type], - "next_hop": topo["routers"]["r1"]["links"]["vm4"][ - addr_type - ].split("/")[0], - } - ] - } - } - logger.info("Configure static routes") - result = create_static_routes(tgen, input_dict_4) - assert result is True, "Testcase {} : Failed \n Error: {}".format( - tc_name, result - ) - - input_dict_4 = { - "vm5": { - "static_routes": [ - { - "network": def_nw[addr_type], - "next_hop": topo["routers"]["r3"]["links"]["vm5"][ - addr_type - ].split("/")[0], - } - ] - } - } - logger.info("Configure static routes") - result = create_static_routes(tgen, input_dict_4) - assert result is True, "Testcase {} : Failed \n Error: {}".format( - tc_name, result - ) - - input_dict_4 = { - "r1": { - "static_routes": [ - { - "network": topo["routers"]["vm1"]["links"]["r2"][ - addr_type - ].split("/")[0] - + "/16", - "next_hop": topo["routers"]["r2"]["links"]["r1-link0"][ - addr_type - ].split("/")[0], - }, - { - "network": topo["routers"]["vm2"]["links"]["r2"][ - addr_type - ].split("/")[0] - + "/16", - "next_hop": topo["routers"]["r2"]["links"]["r1-link0"][ - addr_type - ].split("/")[0], - }, - ] - } - } - - logger.info("Configure static routes") - result = create_static_routes(tgen, input_dict_4) - assert result is True, "Testcase {} : Failed \n Error: {}".format( - tc_name, result - ) - - # Enable static routes - input_dict_4 = { - "r3": { - "static_routes": [ - { - "network": topo["routers"]["vm3"]["links"]["r2"][ - addr_type - ].split("/")[0] - + "/16", - "next_hop": topo["routers"]["r2"]["links"]["r3-link0"][ - addr_type - ].split("/")[0], - }, - { - "network": topo["routers"]["vm6"]["links"]["r2"][ - addr_type - ].split("/")[0] - + "/16", - "next_hop": topo["routers"]["r2"]["links"]["r3-link0"][ - addr_type - ].split("/")[0], - }, - ] - } - } - - logger.info("Configure static routes") - result = create_static_routes(tgen, input_dict_4) - assert result is True, "Testcase {} : Failed \n Error: {}".format( - tc_name, result - ) - - # Enable static routes - input_dict_4 = { - "r2": { - "static_routes": [ - { - "network": topo["routers"]["vm4"]["links"]["r1"][ - addr_type - ].split("/")[0] - + "/16", - "next_hop": topo["routers"]["r1"]["links"]["r2-link0"][ - addr_type - ].split("/")[0], - }, - { - "network": topo["routers"]["vm5"]["links"]["r3"][ - addr_type - ].split("/")[0] - + "/16", - "next_hop": topo["routers"]["r3"]["links"]["r2-link0"][ - addr_type - ].split("/")[0], - }, - { - "network": topo["routers"]["vm4"]["links"]["r1"][addr_type], - "next_hop": topo["routers"]["r1"]["links"]["r2-link0"][ - addr_type - ].split("/")[0], - }, - { - "network": topo["routers"]["vm5"]["links"]["r3"][addr_type], - "next_hop": topo["routers"]["r3"]["links"]["r2-link0"][ - addr_type - ].split("/")[0], - }, - { - "network": topo["routers"]["r1"]["links"]["vm4"][addr_type], - "next_hop": topo["routers"]["r1"]["links"]["r2-link0"][ - addr_type - ].split("/")[0], - }, - { - "network": topo["routers"]["r3"]["links"]["vm5"][addr_type], - "next_hop": topo["routers"]["r3"]["links"]["r2-link0"][ - addr_type - ].split("/")[0], - }, - ] - } - } - - logger.info("Configure static routes") - result = create_static_routes(tgen, input_dict_4) - assert result is True, "Testcase {} : Failed \n Error: {}".format( - tc_name, result - ) - sleep(10) - step( - "Ping from all the vms for both ipv4 and ipv6 address. " - "All the ping should pass." - ) - - step("ping from vm4 to vm1 vm2") - vm4tovm1 = topo["routers"]["vm1"]["links"]["r2"][addr_type].split("/")[0] - result = verify_kernel_ping(tgen, "vm4", vm4tovm1, count=1, addrtype=addr_type) - assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) - - vm4tovm2 = topo["routers"]["vm2"]["links"]["r2"][addr_type].split("/")[0] - result = verify_kernel_ping(tgen, "vm4", vm4tovm2, count=1, addrtype=addr_type) - assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) - - step("ping from vm5 to vm3 vm6") - vm5tovm3 = topo["routers"]["vm3"]["links"]["r2"][addr_type].split("/")[0] - result = verify_kernel_ping(tgen, "vm5", vm5tovm3, count=1, addrtype=addr_type) - assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) - - vm5tovm6 = topo["routers"]["vm6"]["links"]["r2"][addr_type].split("/")[0] - result = verify_kernel_ping(tgen, "vm5", vm5tovm6, count=1, addrtype=addr_type) - assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) - - write_test_footer(tc_name) - - if __name__ == "__main__": args = ["-s"] + sys.argv[1:] sys.exit(pytest.main(args))