]> git.puffer.fish Git - mirror/frr.git/commitdiff
topotest: improve common_config.py 4708/head
authorRafael Zalamena <rzalamena@opensourcerouting.org>
Mon, 22 Jul 2019 16:16:35 +0000 (13:16 -0300)
committerRafael Zalamena <rzalamena@opensourcerouting.org>
Tue, 23 Jul 2019 13:28:56 +0000 (10:28 -0300)
Don't wait for `True` results when the return type is a string.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
tests/topotests/bgp-prefix-list-topo1/test_prefix_lists.py
tests/topotests/lib/common_config.py

index 25a346f20d6b22e442aebd86a2f381cffbec78dc..d3892e9d07d4d4aa576f984ef1de053e3ebeb462 100755 (executable)
@@ -385,7 +385,7 @@ def test_ip_prefix_lists_out_permit(request):
     assert result is True, "Testcase {} : Failed \n Error: {}".format(
         tc_name, result)
 
-    result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol)
+    result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, expected=False)
     assert result is not True, "Testcase {} : Failed \n Error: {}".format(
         tc_name, result)
     write_test_footer(tc_name)
@@ -496,7 +496,7 @@ def test_ip_prefix_lists_in_deny_and_permit_any(request):
     # Verifying RIB routes
     dut = "r3"
     protocol = "bgp"
-    result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol)
+    result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, expected=False)
     assert result is not True, "Testcase {} : Failed \n Error: {}".format(
         tc_name, result)
 
@@ -713,7 +713,7 @@ def test_ip_prefix_lists_out_deny_and_permit_any(request):
     # Verifying RIB routes
     dut = "r4"
     protocol = "bgp"
-    result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol)
+    result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, expected=False)
     assert result is not True, "Testcase {} : Failed \n Error: {}".format(
         tc_name, result)
 
@@ -858,7 +858,7 @@ def test_modify_prefix_lists_in_permit_to_deny(request):
     # Verifying RIB routes
     dut = "r3"
     protocol = "bgp"
-    result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol)
+    result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, expected=False)
     assert result is not True, "Testcase {} : Failed \n Error: {}".format(
         tc_name, result)
 
@@ -971,7 +971,7 @@ def test_modify_prefix_lists_in_deny_to_permit(request):
     # Verifying RIB routes
     dut = "r3"
     protocol = "bgp"
-    result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol)
+    result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, expected=False)
     assert result is not True, "Testcase {} : Failed \n Error: {}".format(
         tc_name, result)
 
@@ -1151,7 +1151,7 @@ def test_modify_prefix_lists_out_permit_to_deny(request):
     # Verifying RIB routes
     dut = "r4"
     protocol = "bgp"
-    result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol)
+    result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, expected=False)
     assert result is not True, "Testcase {} : Failed \n Error: {}".format(
         tc_name, result)
 
@@ -1264,7 +1264,7 @@ def test_modify_prefix_lists_out_deny_to_permit(request):
     # Verifying RIB routes
     dut = "r4"
     protocol = "bgp"
-    result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol)
+    result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, expected=False)
     assert result is not True, "Testcase {} : Failed \n Error: {}".format(
         tc_name, result)
 
@@ -1438,7 +1438,7 @@ def test_ip_prefix_lists_implicit_deny(request):
     # Verifying RIB routes
     dut = "r4"
     protocol = "bgp"
-    result = verify_rib(tgen, "ipv4", dut, input_dict_1, protocol=protocol)
+    result = verify_rib(tgen, "ipv4", dut, input_dict_1, protocol=protocol, expected=False)
     assert result is not True, "Testcase {} : Failed \n Error: {}".format(
         tc_name, result)
 
index a2ad307f8b75212a2e97a436e72bd548332182ce..75880cfd285171191593036d06879fb7e5033ce5 100644 (file)
@@ -1261,14 +1261,21 @@ def _verify_rib(tgen, addr_type, dut, input_dict, next_hop=None, protocol=None):
     return True
 
 
-def verify_rib(tgen, addr_type, dut, input_dict, next_hop=None, protocol=None):
-    "Wrapper function for `_verify_rib` that tries multiple time to get results."
+def verify_rib(tgen, addr_type, dut, input_dict, next_hop=None, protocol=None, expected=True):
+    """
+    Wrapper function for `_verify_rib` that tries multiple time to get results.
+
+    When the expected result is `False` we actually should expect for an string instead.
+    """
 
     # Use currying to hide the parameters and create a test function.
     test_func = partial(_verify_rib, tgen, addr_type, dut, input_dict, next_hop, protocol)
 
     # Call the test function and expect it to return True, otherwise try it again.
-    _, result = topotest.run_and_expect(test_func, True, count=20, wait=6)
+    if expected is True:
+        _, result = topotest.run_and_expect(test_func, True, count=20, wait=6)
+    else:
+        _, result = topotest.run_and_expect_type(test_func, str, count=20, wait=6)
 
     # Return as normal.
     return result