]> git.proxmox.com Git - mirror_frr.git/commitdiff
tests: Added new tests to bgp-basic-functionality-topo1
authorKuldeep Kashyap <kashyapk@vmware.com>
Wed, 1 Apr 2020 05:30:38 +0000 (05:30 +0000)
committerKuldeep Kashyap <kashyapk@vmware.com>
Wed, 8 Apr 2020 12:21:26 +0000 (12:21 +0000)
1. Added 2 new test cases to bgp-basic-functionality-topo1
2. Enhanced 2 tests to run for both static routes and network advvertise command

Signed-off-by: Kuldeep Kashyap <kashyapk@vmware.com>
tests/topotests/bgp-basic-functionality-topo1/test_bgp_basic_functionality.py
tests/topotests/bgp-ecmp-topo2/test_ebgp_ecmp_topo2.py
tests/topotests/bgp-ecmp-topo2/test_ibgp_ecmp_topo2.py

index 7a74b629804b8204abc0555954b315719c7bf92a..1b2faa601a8514e7ca9e6eadbdd777f383c82b0b 100755 (executable)
@@ -233,6 +233,112 @@ def test_bgp_config_with_4byte_as_number(request):
     write_test_footer(tc_name)
 
 
+def test_BGP_config_with_invalid_ASN_p2(request):
+    """
+    Configure BGP with invalid ASN(ex - 0, reserved ASN) and verify test case
+    ended up with error
+    """
+
+    tgen = get_topogen()
+    global BGP_CONVERGENCE
+
+    if BGP_CONVERGENCE != True:
+        pytest.skip('skipped because of BGP Convergence failure')
+
+    # test case name
+    tc_name = request.node.name
+    write_test_header(tc_name)
+
+    # Api call to modify AS number
+    input_dict = {
+        "r1": {
+            "bgp":{
+                "local_as": 0,
+            }
+        },
+        "r2": {
+            "bgp":{
+                "local_as": 0,
+            }
+        },
+        "r3": {
+            "bgp":{
+                "local_as": 0,
+            }
+        },
+        "r4": {
+            "bgp":{
+                "local_as": 64000,
+            }
+        }
+    }
+    result = modify_as_number(tgen, topo, input_dict)
+    try:
+        assert result is True
+    except AssertionError:
+        logger.info("Expected behaviour: {}".format(result))
+        logger.info("BGP config is not created because of invalid ASNs")
+
+    write_test_footer(tc_name)
+
+
+def test_BGP_config_with_2byteAS_and_4byteAS_number_p1(request):
+    """
+    Configure BGP with 4 byte and 2 byte ASN and verify BGP is converged
+    """
+
+    tgen = get_topogen()
+    global BGP_CONVERGENCE
+
+    if BGP_CONVERGENCE != True:
+        pytest.skip('skipped because of BGP Convergence failure')
+
+    # test case name
+    tc_name = request.node.name
+    write_test_header(tc_name)
+
+    # Api call to modify AS number
+    input_dict = {
+        "r1": {
+            "bgp":{
+                "local_as": 131079
+            }
+        },
+        "r2": {
+            "bgp":{
+                "local_as": 131079
+            }
+        },
+        "r3": {
+            "bgp":{
+                "local_as": 131079
+            }
+        },
+        "r4": {
+            "bgp":{
+                "local_as": 111
+            }
+        }
+    }
+    result = modify_as_number(tgen, topo, input_dict)
+    if result != True:
+        assert False, "Testcase " + tc_name + " :Failed \n Error: {}".\
+        format(result)
+
+    result = verify_as_numbers(tgen, topo, input_dict)
+    if result != True:
+        assert False, "Testcase " + tc_name + " :Failed \n Error: {}".\
+        format(result)
+
+    # Api call verify whether BGP is converged
+    result = verify_bgp_convergence(tgen, topo)
+    if result != True:
+        assert False, "Testcase " + tc_name + " :Failed \n Error: {}".\
+            format(result)
+
+    write_test_footer(tc_name)
+
+
 def test_bgp_timers_functionality(request):
     """
     Test to modify bgp timers and verify timers functionality.
index bad421768cf289576808068407e58a410b2e8002..fd3e7fd7d37e77a46e7b924028e5b8a87a7ea749 100755 (executable)
@@ -305,7 +305,8 @@ def test_modify_ecmp_max_paths(request, ecmp_num, test_type):
     write_test_footer(tc_name)
 
 
-def test_ecmp_after_clear_bgp(request):
+@pytest.mark.parametrize("test_type", ["redist_static", "advertise_nw"])
+def test_ecmp_after_clear_bgp(request, test_type):
     """ Verify BGP table and RIB in DUT after clear BGP routes and neighbors"""
 
     tc_name = request.node.name
@@ -318,7 +319,7 @@ def test_ecmp_after_clear_bgp(request):
     dut = "r3"
     protocol = "bgp"
 
-    static_or_nw(tgen, topo, tc_name, "redist_static", "r2")
+    static_or_nw(tgen, topo, tc_name, test_type, "r2")
     for addr_type in ADDR_TYPES:
         input_dict_1 = {"r3": {"static_routes": [{"network": NETWORK[addr_type]}]}}
 
@@ -466,14 +467,10 @@ def test_ecmp_remove_redistribute_static(request):
     write_test_footer(tc_name)
 
 
-def test_ecmp_shut_bgp_neighbor(request):
-    """
-    Disable/Shut selected paths nexthops and verify other next are installed in
-    the RIB of DUT. Enable interfaces and verify RIB count.
-
-    Shut BGP neigbors one by one and verify BGP and routing table updated
-    accordingly in DUT
-    """
+@pytest.mark.parametrize("test_type", ["redist_static", "advertise_nw"])
+def test_ecmp_shut_bgp_neighbor(request, test_type):
+    """ Shut BGP neigbors one by one and verify BGP and routing table updated
+        accordingly in DUT """
 
     tc_name = request.node.name
     write_test_header(tc_name)
@@ -485,7 +482,7 @@ def test_ecmp_shut_bgp_neighbor(request):
     protocol = "bgp"
 
     reset_config_on_routers(tgen)
-    static_or_nw(tgen, topo, tc_name, "redist_static", "r2")
+    static_or_nw(tgen, topo, tc_name, test_type, "r2")
 
     for addr_type in ADDR_TYPES:
         input_dict = {"r3": {"static_routes": [{"network": NETWORK[addr_type]}]}}
@@ -534,7 +531,7 @@ def test_ecmp_shut_bgp_neighbor(request):
     result = interface_status(tgen, topo, input_dict_1)
     assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
 
-    static_or_nw(tgen, topo, tc_name, "redist_static", "r2")
+    static_or_nw(tgen, topo, tc_name, test_type, "r2")
     for addr_type in ADDR_TYPES:
         input_dict = {"r3": {"static_routes": [{"network": NETWORK[addr_type]}]}}
 
index 9271a780bf0406e317faedf4a1aa5b9ec9ebc297..94ffc71ef6f2622d8d2e1cb5761ce5c05fd55d5f 100755 (executable)
@@ -306,7 +306,8 @@ def test_modify_ecmp_max_paths(request, ecmp_num, test_type):
     write_test_footer(tc_name)
 
 
-def test_ecmp_after_clear_bgp(request):
+@pytest.mark.parametrize("test_type", ["redist_static", "advertise_nw"])
+def test_ecmp_after_clear_bgp(request, test_type):
     """ Verify BGP table and RIB in DUT after clear BGP routes and neighbors"""
 
     tc_name = request.node.name
@@ -319,7 +320,7 @@ def test_ecmp_after_clear_bgp(request):
     dut = "r3"
     protocol = "bgp"
 
-    static_or_nw(tgen, topo, tc_name, "redist_static", "r2")
+    static_or_nw(tgen, topo, tc_name, test_type, "r2")
     for addr_type in ADDR_TYPES:
         input_dict_1 = {"r3": {"static_routes": [{"network": NETWORK[addr_type]}]}}
 
@@ -467,7 +468,8 @@ def test_ecmp_remove_redistribute_static(request):
     write_test_footer(tc_name)
 
 
-def test_ecmp_shut_bgp_neighbor(request):
+@pytest.mark.parametrize("test_type", ["redist_static", "advertise_nw"])
+def test_ecmp_shut_bgp_neighbor(request, test_type):
     """ Shut BGP neigbors one by one and verify BGP and routing table updated
         accordingly in DUT """
 
@@ -481,7 +483,7 @@ def test_ecmp_shut_bgp_neighbor(request):
     protocol = "bgp"
 
     reset_config_on_routers(tgen)
-    static_or_nw(tgen, topo, tc_name, "redist_static", "r2")
+    static_or_nw(tgen, topo, tc_name, test_type, "r2")
 
     for addr_type in ADDR_TYPES:
         input_dict = {"r3": {"static_routes": [{"network": NETWORK[addr_type]}]}}
@@ -530,7 +532,7 @@ def test_ecmp_shut_bgp_neighbor(request):
     result = interface_status(tgen, topo, input_dict_1)
     assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
 
-    static_or_nw(tgen, topo, tc_name, "redist_static", "r2")
+    static_or_nw(tgen, topo, tc_name, test_type, "r2")
     for addr_type in ADDR_TYPES:
         input_dict = {"r3": {"static_routes": [{"network": NETWORK[addr_type]}]}}