From dd2da503cdad1f75cd9539f47e9d308a3f2a26f5 Mon Sep 17 00:00:00 2001 From: nguggarigoud Date: Fri, 18 Sep 2020 15:10:54 +0530 Subject: [PATCH] tests: Optimising a step for not true case. 1. Optimising a step for not true case. 2. Fixing a timing issue in route calculation script. Signed-off-by: nguggarigoud --- .../ospf_basic_functionality/test_ospf_lan.py | 2 +- .../test_ospf_rte_calc.py | 25 ++++++++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_lan.py b/tests/topotests/ospf_basic_functionality/test_ospf_lan.py index 968cb608e8..f261104206 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_lan.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_lan.py @@ -431,7 +431,7 @@ def test_ospf_lan_tc1_p0(request): intf = topo["routers"]["r0"]["links"]["s1"]["interface"] shutdown_bringup_interface(tgen, dut, intf, False) - result = verify_ospf_neighbor(tgen, topo, dut, lan=True) + result = verify_ospf_neighbor(tgen, topo, dut, lan=True, expected=False) assert result is not True, "Testcase {} : Failed \n Error: {}".format( tc_name, result ) diff --git a/tests/topotests/ospf_basic_functionality/test_ospf_rte_calc.py b/tests/topotests/ospf_basic_functionality/test_ospf_rte_calc.py index 5e0e35854e..2c6bcf0162 100644 --- a/tests/topotests/ospf_basic_functionality/test_ospf_rte_calc.py +++ b/tests/topotests/ospf_basic_functionality/test_ospf_rte_calc.py @@ -65,6 +65,10 @@ from lib.ospf import ( # Global variables topo = None + +# number of retries. +nretry = 5 + # Reading the data from JSON File for topology creation jsonFile = "{}/ospf_rte_calc.json".format(CWD) try: @@ -220,7 +224,6 @@ def red_connected(dut, config=True): # ################################## -@pytest.mark.precommit def test_ospf_redistribution_tc5_p0(request): """Test OSPF intra area route calculations.""" tc_name = request.node.name @@ -257,7 +260,7 @@ def test_ospf_redistribution_tc5_p0(request): result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, next_hop=nh) assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) - step("Delete the ip address on newly configured loopback of R0") + step("Delete the ip address on newly configured interface of R0") topo1 = { "r0": { "links": { @@ -274,9 +277,12 @@ def test_ospf_redistribution_tc5_p0(request): assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) dut = "r1" - result = verify_ospf_rib( - tgen, dut, input_dict, next_hop=nh, attempts=5, expected=False - ) + for num in range(0, nretry): + result = verify_ospf_rib( + tgen, dut, input_dict, next_hop=nh, expected=False) + if result is not True: + break + assert result is not True, "Testcase {} : Failed \n Error: {}".format( tc_name, result ) @@ -392,9 +398,11 @@ def test_ospf_redistribution_tc6_p0(request): assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result) dut = "r1" - result = verify_ospf_rib( - tgen, dut, input_dict, next_hop=nh, attempts=5, expected=False - ) + for num in range(0, nretry): + result = verify_ospf_rib( + tgen, dut, input_dict, next_hop=nh, expected=False) + if result is not True: + break assert result is not True, "Testcase {} : Failed \n Error: {}".format( tc_name, result ) @@ -407,7 +415,6 @@ def test_ospf_redistribution_tc6_p0(request): input_dict, protocol=protocol, next_hop=nh, - attempts=5, expected=False, ) assert result is not True, "Testcase {} : Failed \n Error: {}".format( -- 2.39.5