diff options
author | Kuldeep Kashyap <kashyapk@vmware.com> | 2020-02-25 21:30:10 +0100 |
---|---|---|
committer | Kuldeep Kashyap <kashyapk@vmware.com> | 2020-02-26 22:02:09 +0100 |
commit | b9f80297c82572824894803b41c56c529f1fd74b (patch) | |
tree | 3d5b7e82f688d7f64a470be5c63cc75f9ba9a5c5 /tests | |
parent | Merge pull request #5783 from ton31337/fix/bad_formatting_bgpd_gr (diff) | |
download | frr-b9f80297c82572824894803b41c56c529f1fd74b.tar.xz frr-b9f80297c82572824894803b41c56c529f1fd74b.zip |
tests: Modified scripts to optimize execution time for route-map test suite
1. Modified scripts to optimize execution time for route-map test suite
2. Removed unnecessary print statements from /lib/bgp.py
Signed-off-by: Kuldeep Kashyap <kashyapk@vmware.com>
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/topotests/bgp-route-map/test_route_map_topo1.py | 26 | ||||
-rwxr-xr-x | tests/topotests/bgp-route-map/test_route_map_topo2.py | 1259 | ||||
-rw-r--r-- | tests/topotests/lib/bgp.py | 4 |
3 files changed, 652 insertions, 637 deletions
diff --git a/tests/topotests/bgp-route-map/test_route_map_topo1.py b/tests/topotests/bgp-route-map/test_route_map_topo1.py index 86ec6c82d..22dd3a638 100755 --- a/tests/topotests/bgp-route-map/test_route_map_topo1.py +++ b/tests/topotests/bgp-route-map/test_route_map_topo1.py @@ -71,7 +71,7 @@ from time import sleep # Save the Current Working Directory to find configuration files. CWD = os.path.dirname(os.path.realpath(__file__)) -sys.path.append(os.path.join(CWD, '../')) +sys.path.append(os.path.join(CWD, "../")) # pylint: disable=C0413 # Import topogen and topotest helpers @@ -102,7 +102,7 @@ ADDR_TYPES = check_address_types() # Reading the data from JSON File for topology and configuration creation jsonFile = "{}/bgp_route_map_topo1.json".format(CWD) try: - with open(jsonFile, 'r') as topoJson: + with open(jsonFile, "r") as topoJson: topo = json.load(topoJson) except IOError: assert False, "Could not read file {}".format(jsonFile) @@ -442,11 +442,12 @@ def test_route_map_inbound_outbound_same_neighbor_p0(request): } } - result = verify_rib(tgen, adt, dut, input_dict_2, protocol=protocol) + result = verify_rib(tgen, adt, dut, input_dict_2, protocol=protocol, + expected=False) assert result is not True, "Testcase {} : Failed \n" - "Expected behavior: routes are not present in rib \n" - "Error: {}".format( + "routes are not present in rib \n Error: {}".format( tc_name, result) + logger.info("Expected behaviour: {}".format(result)) # Verifying RIB routes dut = "r4" @@ -461,11 +462,12 @@ def test_route_map_inbound_outbound_same_neighbor_p0(request): ] } } - result = verify_rib(tgen, adt, dut, input_dict, protocol=protocol) + result = verify_rib(tgen, adt, dut, input_dict, protocol=protocol, + expected=False) assert result is not True, "Testcase {} : Failed \n " - "Expected behavior: routes are not present in rib \n " - "Error: {}".format( + "routes are not present in rib \n Error: {}".format( tc_name, result) + logger.info("Expected behaviour: {}".format(result)) write_test_footer(tc_name) @@ -649,10 +651,14 @@ def test_route_map_with_action_values_combination_of_prefix_action_p0( } } - result = verify_rib(tgen, adt, dut, input_dict_2, protocol=protocol) + #tgen.mininet_cli() + result = verify_rib(tgen, adt, dut, input_dict_2, protocol=protocol, + expected=False) if "deny" in [prefix_action, rmap_action]: - assert result is not True, "Testcase {} : Failed \n Error: {}".\ + assert result is not True, "Testcase {} : Failed \n " + "Routes are still present \n Error: {}".\ format(tc_name, result) + logger.info("Expected behaviour: {}".format(result)) else: assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) diff --git a/tests/topotests/bgp-route-map/test_route_map_topo2.py b/tests/topotests/bgp-route-map/test_route_map_topo2.py index 7009fc97c..f2398c33f 100755 --- a/tests/topotests/bgp-route-map/test_route_map_topo2.py +++ b/tests/topotests/bgp-route-map/test_route_map_topo2.py @@ -32,17 +32,17 @@ TC_61: TC_50_1: Test modify/remove prefix-lists referenced by a route-map for match statement. -TC_50_1: +TC_50_2: Remove prefix-list referencec by route-map match cluase and verifying it reflecting as intended TC_51: Add and remove community-list referencec by route-map match cluase and verifying it reflecting as intended TC_45: - Test multiple match statements as part of a route-map's single + Test multiple match statements as part of a route-map"s single sequence number. (Logical OR-ed of multiple match statements) TC_44: - Test multiple match statements as part of a route-map's single + Test multiple match statements as part of a route-map"s single sequence number. (Logical AND of multiple match statements) TC_41: Test add/remove route-maps to specific neighbor and see if @@ -57,7 +57,7 @@ TC_48: Create route map setting local preference and weight to eBGP peeer and metric to ibgp peer and verifying it should not get advertised TC_43: - Test multiple set statements as part of a route-map's + Test multiple set statements as part of a route-map"s single sequence number. TC_54: Verify route-maps continue clause functionality. @@ -112,7 +112,7 @@ from time import sleep # Save the Current Working Directory to find configuration files. CWD = os.path.dirname(os.path.realpath(__file__)) -sys.path.append(os.path.join(CWD, '../')) +sys.path.append(os.path.join(CWD, "../")) # pylint: disable=C0413 # Import topogen and topotest helpers @@ -127,7 +127,8 @@ from lib.common_config import ( verify_rib, delete_route_maps, create_bgp_community_lists, interface_status, create_route_maps, create_prefix_lists, verify_route_maps, check_address_types, verify_bgp_community, - shutdown_bringup_interface, verify_prefix_lists, reset_config_on_routers) + shutdown_bringup_interface, verify_prefix_lists, reset_config_on_routers, + verify_create_community_list) from lib.topolog import logger from lib.bgp import ( verify_bgp_convergence, create_router_bgp, @@ -138,7 +139,7 @@ from lib.topojson import build_topo_from_json, build_config_from_json jsonFile = "{}/bgp_route_map_topo2.json".format(CWD) try: - with open(jsonFile, 'r') as topoJson: + with open(jsonFile, "r") as topoJson: topo = json.load(topoJson) except IOError: assert False, "Could not read file {}".format(jsonFile) @@ -198,14 +199,14 @@ def setup_module(mod): global bgp_convergence global ADDR_TYPES - # Don't run this test if we have any failure. + # Don"t run this test if we have any failure. if tgen.routers_have_failure(): pytest.skip(tgen.errors) # Api call verify whether BGP is converged bgp_convergence = verify_bgp_convergence(tgen, topo) - assert bgp_convergence is True, ('setup_module :Failed \n Error:' - ' {}'.format(bgp_convergence)) + assert bgp_convergence is True, ("setup_module :Failed \n Error:" + " {}".format(bgp_convergence)) logger.info("Running setup_module() done") @@ -241,7 +242,7 @@ def test_rmap_match_prefix_list_permit_in_and_outbound_prefixes_p0(): global bgp_convergence if bgp_convergence is not True: - pytest.skip('skipped because of BGP Convergence failure') + pytest.skip("skipped because of BGP Convergence failure") # test case name tc_name = inspect.stack()[0][3] @@ -250,20 +251,20 @@ def test_rmap_match_prefix_list_permit_in_and_outbound_prefixes_p0(): # Create ip prefix list input_dict_2 = { - 'r3': { - 'prefix_lists': { - 'ipv4': { - 'pf_list_1_ipv4': [{ - 'seqid': 10, - 'network': 'any', - 'action': 'permit', + "r3": { + "prefix_lists": { + "ipv4": { + "pf_list_1_ipv4": [{ + "seqid": 10, + "network": "any", + "action": "permit", }] }, - 'ipv6': { - 'pf_list_1_ipv6': [{ - 'seqid': 10, - 'network': 'any', - 'action': 'permit', + "ipv6": { + "pf_list_1_ipv6": [{ + "seqid": 10, + "network": "any", + "action": "permit", }] } } @@ -271,7 +272,7 @@ def test_rmap_match_prefix_list_permit_in_and_outbound_prefixes_p0(): } result = create_prefix_lists(tgen, input_dict_2) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) for addr_type in ADDR_TYPES: # Create route map @@ -280,7 +281,7 @@ def test_rmap_match_prefix_list_permit_in_and_outbound_prefixes_p0(): "route_maps": { "rmap_match_pf_1_{}".format(addr_type): [{ "action": "permit", - 'seq_id': '5', + "seq_id": "5", "match": { addr_type: { "prefix_lists": "pf_list_1_" + addr_type @@ -294,7 +295,7 @@ def test_rmap_match_prefix_list_permit_in_and_outbound_prefixes_p0(): ], "rmap_match_pf_2_{}".format(addr_type): [{ "action": "permit", - 'seq_id': '5', + "seq_id": "5", "match": { addr_type: { "prefix_lists": "pf_list_1_" + addr_type @@ -309,12 +310,12 @@ def test_rmap_match_prefix_list_permit_in_and_outbound_prefixes_p0(): } } result = create_route_maps(tgen, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Configure neighbor for route map input_dict_4 = { - 'r3': { + "r3": { "bgp": { "address_family": { "ipv4": { @@ -326,7 +327,7 @@ def test_rmap_match_prefix_list_permit_in_and_outbound_prefixes_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv4", - "direction": 'in' + "direction": "in" }] } } @@ -337,7 +338,7 @@ def test_rmap_match_prefix_list_permit_in_and_outbound_prefixes_p0(): "route_maps": [{ "name": "rmap_match_pf_2_ipv4", - "direction": 'out' + "direction": "out" }] } } @@ -354,7 +355,7 @@ def test_rmap_match_prefix_list_permit_in_and_outbound_prefixes_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv6", - "direction": 'in' + "direction": "in" }] } } @@ -365,7 +366,7 @@ def test_rmap_match_prefix_list_permit_in_and_outbound_prefixes_p0(): "route_maps": [{ "name": "rmap_match_pf_2_ipv6", - "direction": 'out' + "direction": "out" }] } } @@ -379,23 +380,23 @@ def test_rmap_match_prefix_list_permit_in_and_outbound_prefixes_p0(): } result = create_router_bgp(tgen, topo, input_dict_4) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying RIB routes - dut = 'r3' - protocol = 'bgp' + dut = "r3" + protocol = "bgp" input_dict = topo["routers"] # dual stack changes for addr_type in ADDR_TYPES: result4 = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result4 is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result4 is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result4) # Verifying BGP set attributes - dut = 'r3' + dut = "r3" routes = { "ipv4": ["10.0.20.1/32", "10.0.20.2/32"], "ipv6": ["1::1/128", "1::2/128"] @@ -405,21 +406,21 @@ def test_rmap_match_prefix_list_permit_in_and_outbound_prefixes_p0(): rmap_name = "rmap_match_pf_1_{}".format(addr_type) result4 = verify_bgp_attributes(tgen, addr_type, dut, routes[ addr_type],rmap_name, input_dict_3) - assert result4 is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result4 is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result4) # Verifying RIB routes - dut = 'r4' - protocol = 'bgp' + dut = "r4" + protocol = "bgp" # dual stack changes for addr_type in ADDR_TYPES: result4 = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result4 is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result4 is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result4) # Verifying BGP set attributes - dut = 'r4' + dut = "r4" routes = { "ipv4": ["10.0.20.1/32", "10.0.20.2/32"], "ipv6": ["1::1/128", "1::2/128"] @@ -429,7 +430,7 @@ def test_rmap_match_prefix_list_permit_in_and_outbound_prefixes_p0(): rmap_name = "rmap_match_pf_2_{}".format(addr_type) result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type], rmap_name, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) write_test_footer(tc_name) @@ -448,7 +449,7 @@ def test_modify_set_match_clauses_in_rmap_p0(): global bgp_convergence if bgp_convergence is not True: - pytest.skip('skipped because of BGP Convergence failure') + pytest.skip("skipped because of BGP Convergence failure") # test case name tc_name = inspect.stack()[0][3] @@ -458,37 +459,37 @@ def test_modify_set_match_clauses_in_rmap_p0(): # Create ip prefix list input_dict_2 = { - 'r3': { - 'prefix_lists': { - 'ipv4': { - 'pf_list_1_ipv4': [{ - 'seqid': 10, - 'network': 'any', - 'action': 'permit', + "r3": { + "prefix_lists": { + "ipv4": { + "pf_list_1_ipv4": [{ + "seqid": 10, + "network": "any", + "action": "permit", }], - 'pf_list_2_ipv4': [{ - 'seqid': 10, - 'network': 'any', - 'action': 'permit' + "pf_list_2_ipv4": [{ + "seqid": 10, + "network": "any", + "action": "permit" }] }, - 'ipv6': { - 'pf_list_1_ipv6': [{ - 'seqid': 10, - 'network': 'any', - 'action': 'permit', + "ipv6": { + "pf_list_1_ipv6": [{ + "seqid": 10, + "network": "any", + "action": "permit", }], - 'pf_list_2_ipv6': [{ - 'seqid': 10, - 'network': 'any', - 'action': 'permit' + "pf_list_2_ipv6": [{ + "seqid": 10, + "network": "any", + "action": "permit" }] } } } } result = create_prefix_lists(tgen, input_dict_2) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Create route map @@ -498,7 +499,7 @@ def test_modify_set_match_clauses_in_rmap_p0(): "route_maps": { "rmap_match_pf_1_{}".format(addr_type): [{ "action": "permit", - 'seq_id': '5', + "seq_id": "5", "match": { addr_type: { "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -510,7 +511,7 @@ def test_modify_set_match_clauses_in_rmap_p0(): }], "rmap_match_pf_2_{}".format(addr_type): [{ "action": "permit", - 'seq_id': '5', + "seq_id": "5", "match": { addr_type: { "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -524,12 +525,12 @@ def test_modify_set_match_clauses_in_rmap_p0(): } } result = create_route_maps(tgen, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Configure neighbor for route map input_dict_4 = { - 'r3': { + "r3": { "bgp": { "address_family": { "ipv4": { @@ -541,7 +542,7 @@ def test_modify_set_match_clauses_in_rmap_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv4", - "direction": 'in' + "direction": "in" }] } } @@ -552,7 +553,7 @@ def test_modify_set_match_clauses_in_rmap_p0(): "route_maps": [{ "name": "rmap_match_pf_2_ipv4", - "direction": 'out' + "direction": "out" }] } } @@ -569,7 +570,7 @@ def test_modify_set_match_clauses_in_rmap_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv6", - "direction": 'in' + "direction": "in" }] } } @@ -580,7 +581,7 @@ def test_modify_set_match_clauses_in_rmap_p0(): "route_maps": [{ "name": "rmap_match_pf_2_ipv6", - "direction": 'out' + "direction": "out" }] } } @@ -593,21 +594,21 @@ def test_modify_set_match_clauses_in_rmap_p0(): } } result = create_router_bgp(tgen, topo, input_dict_4) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying RIB routes - dut = 'r3' - protocol = 'bgp' + dut = "r3" + protocol = "bgp" input_dict = topo["routers"] for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying BGP set attributes - dut = 'r3' + dut = "r3" routes = { "ipv4": ["10.0.20.1/32", "10.0.20.2/32"], "ipv6": ["1::1/128", "1::2/128"] @@ -617,21 +618,21 @@ def test_modify_set_match_clauses_in_rmap_p0(): rmap_name = "rmap_match_pf_1_{}".format(addr_type) result4 = verify_bgp_attributes(tgen, addr_type, dut, routes[ addr_type],rmap_name, input_dict_3) - assert result4 is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result4 is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result4) # Verifying RIB routes - dut = 'r4' - protocol = 'bgp' + dut = "r4" + protocol = "bgp" # dual stack changes for addr_type in ADDR_TYPES: result4 = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result4 is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result4 is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result4) # Verifying BGP set attributes - dut = 'r4' + dut = "r4" routes = { "ipv4": ["10.0.20.1/32", "10.0.20.2/32"], "ipv6": ["1::1/128", "1::2/128"] @@ -640,7 +641,7 @@ def test_modify_set_match_clauses_in_rmap_p0(): rmap_name = "rmap_match_pf_2_{}".format(addr_type) result = verify_bgp_attributes(tgen, addr_type, dut, routes[ addr_type],rmap_name, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Modify set/match clause of in-used route map @@ -650,7 +651,7 @@ def test_modify_set_match_clauses_in_rmap_p0(): "route_maps": { "rmap_match_pf_1_{}".format(addr_type): [{ "action": "permit", - 'seq_id': '5', + "seq_id": "5", "match": { addr_type: { "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -662,7 +663,7 @@ def test_modify_set_match_clauses_in_rmap_p0(): }], "rmap_match_pf_2_{}".format(addr_type): [{ "action": "permit", - 'seq_id': '5', + "seq_id": "5", "match": { addr_type: { "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -676,20 +677,20 @@ def test_modify_set_match_clauses_in_rmap_p0(): } } result = create_route_maps(tgen, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying RIB routes - dut = 'r3' - protocol = 'bgp' + dut = "r3" + protocol = "bgp" for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying BGP set attributes - dut = 'r3' + dut = "r3" routes = { "ipv4": ["10.0.20.1/32", "10.0.20.2/32"], "ipv6": ["1::1/128", "1::2/128"] @@ -698,20 +699,20 @@ def test_modify_set_match_clauses_in_rmap_p0(): rmap_name = "rmap_match_pf_1_{}".format(addr_type) result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type], rmap_name, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying RIB routes - dut = 'r4' - protocol = 'bgp' + dut = "r4" + protocol = "bgp" for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying BGP set attributes - dut = 'r4' + dut = "r4" routes = { "ipv4": ["10.0.20.1/32", "10.0.20.2/32"], "ipv6": ["1::1/128", "1::2/128"] @@ -720,7 +721,7 @@ def test_modify_set_match_clauses_in_rmap_p0(): rmap_name = "rmap_match_pf_2_{}".format(addr_type) result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type], rmap_name, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) write_test_footer(tc_name) @@ -739,7 +740,7 @@ def test_delete_route_maps_p1(): global bgp_convergence if bgp_convergence is not True: - pytest.skip('skipped because of BGP Convergence failure') + pytest.skip("skipped because of BGP Convergence failure") # test case name tc_name = inspect.stack()[0][3] @@ -763,22 +764,22 @@ def test_delete_route_maps_p1(): } } result = create_route_maps(tgen, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Delete route maps for addr_type in ADDR_TYPES: input_dict = { - 'r3': { - 'route_maps': ['rmap_match_tag_1_{}'.format(addr_type)] + "r3": { + "route_maps": ["rmap_match_tag_1_{}".format(addr_type)] } } result = delete_route_maps(tgen, input_dict) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) result = verify_route_maps(tgen, input_dict) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) write_test_footer(tc_name) @@ -797,7 +798,7 @@ def test_modify_prefix_list_referenced_by_rmap_p0(): global bgp_convergence if bgp_convergence is not True: - pytest.skip('skipped because of BGP Convergence failure') + pytest.skip("skipped because of BGP Convergence failure") # test case name tc_name = inspect.stack()[0][3] @@ -806,27 +807,27 @@ def test_modify_prefix_list_referenced_by_rmap_p0(): # Create ip prefix list input_dict_2 = { - 'r3': { - 'prefix_lists': { - 'ipv4': { - 'pf_list_1_ipv4': [{ - 'seqid': 10, - 'network': 'any', - 'action': 'permit', + "r3": { + "prefix_lists": { + "ipv4": { + "pf_list_1_ipv4": [{ + "seqid": 10, + "network": "any", + "action": "permit", }] }, - 'ipv6': { - 'pf_list_1_ipv6': [{ - 'seqid': 100, - 'network': 'any', - 'action': 'permit', + "ipv6": { + "pf_list_1_ipv6": [{ + "seqid": 100, + "network": "any", + "action": "permit", }] } } } } result = create_prefix_lists(tgen, input_dict_2) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Create route map @@ -836,7 +837,7 @@ def test_modify_prefix_list_referenced_by_rmap_p0(): "route_maps": { "rmap_match_pf_1_{}".format(addr_type): [{ "action": "permit", - 'seq_id': '5', + "seq_id": "5", "match": { addr_type: { "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -849,7 +850,7 @@ def test_modify_prefix_list_referenced_by_rmap_p0(): }], "rmap_match_pf_2_{}".format(addr_type): [{ "action": "permit", - 'seq_id': '5', + "seq_id": "5", "match": { addr_type: { "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -863,12 +864,12 @@ def test_modify_prefix_list_referenced_by_rmap_p0(): } } result = create_route_maps(tgen, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Configure neighbor for route map input_dict_4 = { - 'r3': { + "r3": { "bgp": { "address_family": { "ipv4": { @@ -880,7 +881,7 @@ def test_modify_prefix_list_referenced_by_rmap_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv4", - "direction": 'in' + "direction": "in" }] } } @@ -891,7 +892,7 @@ def test_modify_prefix_list_referenced_by_rmap_p0(): "route_maps": [{ "name": "rmap_match_pf_2_ipv4", - "direction": 'out' + "direction": "out" }] } } @@ -908,7 +909,7 @@ def test_modify_prefix_list_referenced_by_rmap_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv6", - "direction": 'in' + "direction": "in" }] } } @@ -919,7 +920,7 @@ def test_modify_prefix_list_referenced_by_rmap_p0(): "route_maps": [{ "name": "rmap_match_pf_2_ipv6", - "direction": 'out' + "direction": "out" }] } } @@ -933,21 +934,21 @@ def test_modify_prefix_list_referenced_by_rmap_p0(): } result = create_router_bgp(tgen, topo, input_dict_4) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying RIB routes - dut = 'r3' - protocol = 'bgp' + dut = "r3" + protocol = "bgp" input_dict = topo["routers"] for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying BGP set attributes - dut = 'r3' + dut = "r3" routes = { "ipv4": ["10.0.20.1/32", "10.0.20.2/32"], "ipv6": ["1::1/128", "1::2/128"] @@ -956,20 +957,20 @@ def test_modify_prefix_list_referenced_by_rmap_p0(): rmap_name = "rmap_match_pf_1_{}".format(addr_type) result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type], rmap_name, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying RIB routes - dut = 'r4' - protocol = 'bgp' + dut = "r4" + protocol = "bgp" for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying BGP set attributes - dut = 'r4' + dut = "r4" routes = { "ipv4": ["10.0.20.1/32", "10.0.20.2/32"], "ipv6": ["1::1/128", "1::2/128"] @@ -979,55 +980,55 @@ def test_modify_prefix_list_referenced_by_rmap_p0(): rmap_name = "rmap_match_pf_2_{}".format(addr_type) result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type], rmap_name, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Modify ip prefix list input_dict_2 = { - 'r3': { - 'prefix_lists': { - 'ipv4': { - 'pf_list_1_ipv4': [{ - 'seqid': 10, - 'network': 'any', - 'action': 'deny' + "r3": { + "prefix_lists": { + "ipv4": { + "pf_list_1_ipv4": [{ + "seqid": 10, + "network": "any", + "action": "deny" }] }, - 'ipv6': { - 'pf_list_1_ipv6': [{ - 'seqid': 100, - 'network': 'any', - 'action': 'deny' + "ipv6": { + "pf_list_1_ipv6": [{ + "seqid": 100, + "network": "any", + "action": "deny" }] } } } } result = create_prefix_lists(tgen, input_dict_2) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) sleep(5) # Verifying RIB routes - dut = 'r3' - protocol = 'bgp' + dut = "r3" + protocol = "bgp" for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, - protocol=protocol) - assert result is not True, 'Testcase {} : Failed \n' - 'Expected behaviour: routes are not present \n ' - 'Error: {}'.format( + protocol=protocol, expected=False) + assert result is not True, "Testcase {} : Failed \n" + "routes are not present \n Error: {}".format( tc_name, result) + logger.info("Expected behaviour: {}".format(result)) # Verifying RIB routes - dut = 'r4' - protocol = 'bgp' + dut = "r4" + protocol = "bgp" for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, - protocol=protocol) - assert result is not True, 'Testcase {} : Failed \n' - 'Expected behaviour: routes are not present \n ' - 'Error: {}'.format( + protocol=protocol, expected=False) + assert result is not True, "Testcase {} : Failed \n" + "Expected behaviour: routes are not present \n " + "Error: {}".format( tc_name, result) write_test_footer(tc_name) @@ -1038,7 +1039,7 @@ def test_modify_prefix_list_referenced_by_rmap_p0(): def test_remove_prefix_list_referenced_by_rmap_p0(): """ - TC_50_1: + TC_50_2: Remove prefix-list referencec by route-map match cluase and verifying it reflecting as intended """ @@ -1046,7 +1047,7 @@ def test_remove_prefix_list_referenced_by_rmap_p0(): global bgp_convergence if bgp_convergence is not True: - pytest.skip('skipped because of BGP Convergence failure') + pytest.skip("skipped because of BGP Convergence failure") # test case name tc_name = inspect.stack()[0][3] @@ -1055,27 +1056,27 @@ def test_remove_prefix_list_referenced_by_rmap_p0(): # Create ip prefix list input_dict_2 = { - 'r3': { - 'prefix_lists': { - 'ipv4': { - 'pf_list_1_ipv4': [{ - 'seqid': 10, - 'network': 'any', - 'action': 'permit' + "r3": { + "prefix_lists": { + "ipv4": { + "pf_list_1_ipv4": [{ + "seqid": 10, + "network": "any", + "action": "permit" }] }, - 'ipv6': { - 'pf_list_1_ipv6': [{ - 'seqid': 100, - 'network': 'any', - 'action': 'permit' + "ipv6": { + "pf_list_1_ipv6": [{ + "seqid": 100, + "network": "any", + "action": "permit" }] } } } } result = create_prefix_lists(tgen, input_dict_2) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Create route map @@ -1085,7 +1086,7 @@ def test_remove_prefix_list_referenced_by_rmap_p0(): "route_maps": { "rmap_match_pf_1_{}".format(addr_type): [{ "action": "permit", - 'seq_id': '5', + "seq_id": "5", "match": { addr_type: { "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -1097,7 +1098,7 @@ def test_remove_prefix_list_referenced_by_rmap_p0(): }], "rmap_match_pf_2_{}".format(addr_type): [{ "action": "permit", - 'seq_id': '5', + "seq_id": "5", "match": { addr_type: { "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -1111,13 +1112,13 @@ def test_remove_prefix_list_referenced_by_rmap_p0(): } } result = create_route_maps(tgen, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Configure neighbor for route map for addr_type in ADDR_TYPES: input_dict_4 = { - 'r3': { + "r3": { "bgp": { "address_family": { "ipv4": { @@ -1129,7 +1130,7 @@ def test_remove_prefix_list_referenced_by_rmap_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv4", - "direction": 'in' + "direction": "in" }] } } @@ -1140,7 +1141,7 @@ def test_remove_prefix_list_referenced_by_rmap_p0(): "route_maps": [{ "name": "rmap_match_pf_2_ipv4", - "direction": 'out' + "direction": "out" }] } } @@ -1157,7 +1158,7 @@ def test_remove_prefix_list_referenced_by_rmap_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv6", - "direction": 'in' + "direction": "in" }] } } @@ -1168,7 +1169,7 @@ def test_remove_prefix_list_referenced_by_rmap_p0(): "route_maps": [{ "name": "rmap_match_pf_2_ipv6", - "direction": 'out' + "direction": "out" }] } } @@ -1181,21 +1182,21 @@ def test_remove_prefix_list_referenced_by_rmap_p0(): } } result = create_router_bgp(tgen, topo, input_dict_4) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying RIB routes - dut = 'r3' - protocol = 'bgp' + dut = "r3" + protocol = "bgp" input_dict = topo["routers"] for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying BGP set attributes - dut = 'r3' + dut = "r3" routes = { "ipv4": ["10.0.20.1/32", "10.0.20.2/32"], "ipv6": ["1::1/128", "1::2/128"] @@ -1204,20 +1205,20 @@ def test_remove_prefix_list_referenced_by_rmap_p0(): rmap_name = "rmap_match_pf_1_{}".format(addr_type) result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type], rmap_name, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying RIB routes - dut = 'r4' - protocol = 'bgp' + dut = "r4" + protocol = "bgp" for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying BGP set attributes - dut = 'r4' + dut = "r4" routes = { "ipv4": ["10.0.20.1/32", "10.0.20.2/32"], "ipv6": ["1::1/128", "1::2/128"] @@ -1226,67 +1227,67 @@ def test_remove_prefix_list_referenced_by_rmap_p0(): rmap_name = "rmap_match_pf_2_{}".format(addr_type) result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type], rmap_name, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Remove/Delete prefix list input_dict_3 = { - 'r3': { - 'prefix_lists': { - 'ipv4': { - 'pf_list_1_ipv4': [{ - 'seqid': 10, - 'network': 'any', - 'action': 'permit', - 'delete': True + "r3": { + "prefix_lists": { + "ipv4": { + "pf_list_1_ipv4": [{ + "seqid": 10, + "network": "any", + "action": "permit", + "delete": True }] }, - 'ipv6': { - 'pf_list_1_ipv6': [{ - 'seqid': 100, - 'network': 'any', - 'action': 'permit', - 'delete': True + "ipv6": { + "pf_list_1_ipv6": [{ + "seqid": 100, + "network": "any", + "action": "permit", + "delete": True }] } } } } result = create_prefix_lists(tgen, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) result = verify_prefix_lists(tgen, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Api call to clear bgp, so config changes would be reflected - dut = 'r3' + dut = "r3" result = clear_bgp_and_verify(tgen, topo, dut) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying RIB routes - dut = 'r3' - protocol = 'bgp' + dut = "r3" + protocol = "bgp" for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, - protocol=protocol) - assert result is not True, 'Testcase {} : Failed \n' - 'Expected behaviour: routes are not present \n ' - 'Error: {}'.format( + protocol=protocol, expected=False) + assert result is not True, "Testcase {} : Failed \n" + "routes are not present \n Error: {}".format( tc_name, result) + logger.info("Expected behaviour: {}".format(result)) # Verifying RIB routes - dut = 'r4' - protocol = 'bgp' + dut = "r4" + protocol = "bgp" for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, - protocol=protocol) - assert result is not True, 'Testcase {} : Failed \n' - 'Expected behaviour: routes are not present \n ' - 'Error: {}'.format( - tc_name, result) + protocol=protocol, expected=False) + assert result is not True, "Testcase {} : Failed \n" + "routes are not present \n Error: {}".\ + format(tc_name, result) + logger.info("Expected behaviour: {}".format(result)) write_test_footer(tc_name) @@ -1304,7 +1305,7 @@ def test_add_and_remove_community_list_referenced_by_rmap_p0(): global bgp_convergence if bgp_convergence is not True: - pytest.skip('skipped because of BGP Convergence failure') + pytest.skip("skipped because of BGP Convergence failure") # test case name tc_name = inspect.stack()[0][3] @@ -1329,12 +1330,12 @@ def test_add_and_remove_community_list_referenced_by_rmap_p0(): } } result = create_route_maps(tgen, input_dict_5) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Configure neighbor for route map input_dict_6 = { - 'r1': { + "r1": { "bgp": { "address_family": { "ipv4": { @@ -1345,7 +1346,7 @@ def test_add_and_remove_community_list_referenced_by_rmap_p0(): "r1": { "route_maps": [{ "name": "rm_r1_out_ipv4", - "direction": 'out' + "direction": "out" }] } } @@ -1361,7 +1362,7 @@ def test_add_and_remove_community_list_referenced_by_rmap_p0(): "r1": { "route_maps": [{ "name": "rm_r1_out_ipv6", - "direction": 'out' + "direction": "out" }] } } @@ -1375,7 +1376,7 @@ def test_add_and_remove_community_list_referenced_by_rmap_p0(): } result = create_router_bgp(tgen, topo, input_dict_6) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) for addr_type in ADDR_TYPES: @@ -1394,9 +1395,14 @@ def test_add_and_remove_community_list_referenced_by_rmap_p0(): } } result = create_bgp_community_lists(tgen, input_dict_1) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) + # Verify BGP large community is created + result = verify_create_community_list(tgen, input_dict_1) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result) + for addr_type in ADDR_TYPES: # Create route map input_dict_2 = { @@ -1415,12 +1421,12 @@ def test_add_and_remove_community_list_referenced_by_rmap_p0(): } } result = create_route_maps(tgen, input_dict_2) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Configure neighbor for route map input_dict_3 = { - 'r3': { + "r3": { "bgp": { "address_family": { "ipv4": { @@ -1431,7 +1437,7 @@ def test_add_and_remove_community_list_referenced_by_rmap_p0(): "r3": { "route_maps": [{ "name": "rm_r3_in_ipv4", - "direction": 'in' + "direction": "in" }] } } @@ -1447,7 +1453,7 @@ def test_add_and_remove_community_list_referenced_by_rmap_p0(): "r3": { "route_maps": [{ "name": "rm_r3_in_ipv6", - "direction": 'in' + "direction": "in" }] } } @@ -1461,33 +1467,33 @@ def test_add_and_remove_community_list_referenced_by_rmap_p0(): } result = create_router_bgp(tgen, topo, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) sleep(5) # Verifying RIB routes - dut = 'r3' - protocol = 'bgp' + dut = "r3" + protocol = "bgp" input_dict = topo["routers"] for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verify large-community-list - dut = 'r3' + dut = "r3" networks = { "ipv4": ["10.0.20.1/32", "10.0.20.2/32"], "ipv6": ["1::1/128", "1::2/128"] } input_dict_4 = { - 'largeCommunity': '1:1:1 1:2:3 2:1:1 2:2:2' + "largeCommunity": "1:1:1 1:2:3 2:1:1 2:2:2" } for addr_type in ADDR_TYPES: result = verify_bgp_community(tgen, addr_type, dut, networks[ addr_type],input_dict_4) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) write_test_footer(tc_name) @@ -1498,14 +1504,14 @@ def test_add_and_remove_community_list_referenced_by_rmap_p0(): def test_multiple_match_statement_in_route_map_logical_ORed_p0(): """ TC_45: - Test multiple match statements as part of a route-map's single + Test multiple match statements as part of a route-map"s single sequence number. (Logical OR-ed of multiple match statements) """ tgen = get_topogen() global bgp_convergence if bgp_convergence is not True: - pytest.skip('skipped because of BGP Convergence failure') + pytest.skip("skipped because of BGP Convergence failure") # test case name tc_name = inspect.stack()[0][3] @@ -1514,20 +1520,20 @@ def test_multiple_match_statement_in_route_map_logical_ORed_p0(): # Api call to advertise networks input_dict_nw1 = { - 'r1': { + "r1": { "bgp": { "address_family": { "ipv4": { "unicast": { "advertise_networks": [ - {"network": '10.0.30.1/32'} + {"network": "10.0.30.1/32"} ] } }, "ipv6": { "unicast": { "advertise_networks": [ - {"network": '1::1/128'} + {"network": "1::1/128"} ] } } @@ -1537,25 +1543,25 @@ def test_multiple_match_statement_in_route_map_logical_ORed_p0(): } result = create_router_bgp(tgen, topo, input_dict_nw1) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Api call to advertise networks input_dict_nw2 = { - 'r1': { + "r1": { "bgp": { "address_family": { "ipv4": { "unicast": { "advertise_networks": [ - {"network": '20.0.30.1/32'} + {"network": "20.0.30.1/32"} ] } }, "ipv6": { "unicast": { "advertise_networks": [ - {"network": '2::1/128'} + {"network": "2::1/128"} ] } } @@ -1565,57 +1571,57 @@ def test_multiple_match_statement_in_route_map_logical_ORed_p0(): } result = create_router_bgp(tgen, topo, input_dict_nw2) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Create ip prefix list input_dict_2 = { - 'r3': { - 'prefix_lists': { - 'ipv4': { - 'pf_list_1_ipv4': [{ - 'seqid': 10, - 'network': 'any', - 'action': 'permit' + "r3": { + "prefix_lists": { + "ipv4": { + "pf_list_1_ipv4": [{ + "seqid": 10, + "network": "any", + "action": "permit" }] }, - 'ipv6': { - 'pf_list_1_ipv6': [{ - 'seqid': 100, - 'network': 'any', - 'action': 'permit' + "ipv6": { + "pf_list_1_ipv6": [{ + "seqid": 100, + "network": "any", + "action": "permit" }] } } } } result = create_prefix_lists(tgen, input_dict_2) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Create ip prefix list input_dict_2 = { - 'r3': { - 'prefix_lists': { - 'ipv4': { - 'pf_list_2_ipv4': [{ - 'seqid': 10, - 'network': 'any', - 'action': 'permit' + "r3": { + "prefix_lists": { + "ipv4": { + "pf_list_2_ipv4": [{ + "seqid": 10, + "network": "any", + "action": "permit" }] }, - 'ipv6': { - 'pf_list_2_ipv6': [{ - 'seqid': 100, - 'network': 'any', - 'action': 'permit' + "ipv6": { + "pf_list_2_ipv6": [{ + "seqid": 100, + "network": "any", + "action": "permit" }] } } } } result = create_prefix_lists(tgen, input_dict_2) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) input_dict_3_addr_type ={} @@ -1626,7 +1632,7 @@ def test_multiple_match_statement_in_route_map_logical_ORed_p0(): "route_maps": { "rmap_match_pf_1_{}".format(addr_type): [{ "action": "permit", - 'seq_id': '5', + "seq_id": "5", "match": { addr_type: { "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -1641,7 +1647,7 @@ def test_multiple_match_statement_in_route_map_logical_ORed_p0(): } input_dict_3_addr_type[addr_type] = input_dict_3 result = create_route_maps(tgen, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Create route map @@ -1651,7 +1657,7 @@ def test_multiple_match_statement_in_route_map_logical_ORed_p0(): "route_maps": { "rmap_match_pf_1_{}".format(addr_type): [{ "action": "permit", - 'seq_id': '5', + "seq_id": "5", "match": { addr_type: { "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -1666,12 +1672,12 @@ def test_multiple_match_statement_in_route_map_logical_ORed_p0(): } input_dict_3_addr_type[addr_type] = input_dict_3 result = create_route_maps(tgen, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Configure neighbor for route map input_dict_6 = { - 'r3': { + "r3": { "bgp": { "address_family": { "ipv4": { @@ -1683,7 +1689,7 @@ def test_multiple_match_statement_in_route_map_logical_ORed_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv4", - "direction": 'in' + "direction": "in" }] } } @@ -1700,7 +1706,7 @@ def test_multiple_match_statement_in_route_map_logical_ORed_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv6", - "direction": 'in' + "direction": "in" }] } } @@ -1714,21 +1720,21 @@ def test_multiple_match_statement_in_route_map_logical_ORed_p0(): } result = create_router_bgp(tgen, topo, input_dict_6) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying RIB routes - dut = 'r3' - protocol = 'bgp' + dut = "r3" + protocol = "bgp" input_dict = topo["routers"] for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying BGP set attributes - dut = 'r3' + dut = "r3" routes = { "ipv4": ["10.0.30.1/32"], "ipv6": ["1::1/128"] @@ -1737,7 +1743,7 @@ def test_multiple_match_statement_in_route_map_logical_ORed_p0(): rmap_name = "rmap_match_pf_1_{}".format(addr_type) result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type], rmap_name, input_dict_3_addr_type[addr_type]) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying BGP set attributes @@ -1748,7 +1754,7 @@ def test_multiple_match_statement_in_route_map_logical_ORed_p0(): for addr_type in ADDR_TYPES: result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type], rmap_name, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) write_test_footer(tc_name) @@ -1757,17 +1763,17 @@ def test_multiple_match_statement_in_route_map_logical_ORed_p0(): # tgen.mininet_cli() -def test_multiple_match_statement_in_route_map_logical_ANDed(): +def test_multiple_match_statement_in_route_map_logical_ANDed_p1(): """ TC_44: - Test multiple match statements as part of a route-map's single + Test multiple match statements as part of a route-map"s single sequence number. (Logical AND of multiple match statements) """ tgen = get_topogen() global bgp_convergence if bgp_convergence is not True: - pytest.skip('skipped because of BGP Convergence failure') + pytest.skip("skipped because of BGP Convergence failure") # test case name tc_name = inspect.stack()[0][3] @@ -1790,13 +1796,13 @@ def test_multiple_match_statement_in_route_map_logical_ANDed(): } } result = create_route_maps(tgen, input_dict_5) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Configure neighbor for route map for addr_type in ADDR_TYPES: input_dict_6 = { - 'r1': { + "r1": { "bgp": { "address_family": { addr_type: { @@ -1808,7 +1814,7 @@ def test_multiple_match_statement_in_route_map_logical_ANDed(): "route_maps": [{ "name": "rm_r1_out_{}".format(addr_type), - "direction": 'out' + "direction": "out" }] } } @@ -1821,25 +1827,25 @@ def test_multiple_match_statement_in_route_map_logical_ANDed(): } } result = create_router_bgp(tgen, topo, input_dict_6) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Create ip prefix list input_dict_2 = { - 'r3': { - 'prefix_lists': { - 'ipv4': { - 'pf_list_1_ipv4': [{ - 'seqid': 10, - 'network': 'any', - 'action': 'permit' + "r3": { + "prefix_lists": { + "ipv4": { + "pf_list_1_ipv4": [{ + "seqid": 10, + "network": "any", + "action": "permit" }] }, - 'ipv6': { - 'pf_list_1_ipv6': [{ - 'seqid': 100, - 'network': 'any', - 'action': 'permit' + "ipv6": { + "pf_list_1_ipv6": [{ + "seqid": 100, + "network": "any", + "action": "permit" }] } } @@ -1847,7 +1853,7 @@ def test_multiple_match_statement_in_route_map_logical_ANDed(): } result = create_prefix_lists(tgen, input_dict_2) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) for addr_type in ADDR_TYPES: @@ -1866,9 +1872,14 @@ def test_multiple_match_statement_in_route_map_logical_ANDed(): } } result = create_bgp_community_lists(tgen, input_dict_1) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) + # Verify BGP large community is created + result = verify_create_community_list(tgen, input_dict_1) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result) + # Create route map for addr_type in ADDR_TYPES: input_dict_3 = { @@ -1876,7 +1887,7 @@ def test_multiple_match_statement_in_route_map_logical_ANDed(): "route_maps": { "rmap_match_pf_1_{}".format(addr_type): [{ "action": "permit", - 'seq_id': '5', + "seq_id": "5", "match": { addr_type: { "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -1890,7 +1901,7 @@ def test_multiple_match_statement_in_route_map_logical_ANDed(): } } result = create_route_maps(tgen, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) for addr_type in ADDR_TYPES: @@ -1900,7 +1911,7 @@ def test_multiple_match_statement_in_route_map_logical_ANDed(): "route_maps": { "rmap_match_pf_1_{}".format(addr_type): [{ "action": "permit", - 'seq_id': '5', + "seq_id": "5", "match": { addr_type : { "large_community_list": {"id": "rmap_lcomm_"+ @@ -1915,12 +1926,12 @@ def test_multiple_match_statement_in_route_map_logical_ANDed(): } } result = create_route_maps(tgen, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Configure neighbor for route map for addr_type in ADDR_TYPES: input_dict_4 = { - 'r3': { + "r3": { "bgp": { "address_family": { addr_type: { @@ -1932,7 +1943,7 @@ def test_multiple_match_statement_in_route_map_logical_ANDed(): "route_maps": [{ "name": "rmap_match_pf_1_{}".format(addr_type), - "direction": 'in' + "direction": "in" }] } } @@ -1945,20 +1956,20 @@ def test_multiple_match_statement_in_route_map_logical_ANDed(): } } result = create_router_bgp(tgen, topo, input_dict_4) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # sleep(10) # Verifying RIB routes - dut = 'r3' - protocol = 'bgp' + dut = "r3" + protocol = "bgp" input_dict = topo["routers"] for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying BGP set attributes - dut = 'r3' + dut = "r3" routes = { "ipv4": ["10.0.20.1/32", "10.0.20.2/32"], "ipv6": ["1::1/128", "1::2/128"] @@ -1967,7 +1978,7 @@ def test_multiple_match_statement_in_route_map_logical_ANDed(): rmap_name = "rmap_match_pf_1_{}".format(addr_type) result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type], rmap_name, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) write_test_footer(tc_name) @@ -1986,7 +1997,7 @@ def test_add_remove_rmap_to_specific_neighbor_p0(): global bgp_convergence if bgp_convergence is not True: - pytest.skip('skipped because of BGP Convergence failure') + pytest.skip("skipped because of BGP Convergence failure") # test case name tc_name = inspect.stack()[0][3] @@ -1995,27 +2006,27 @@ def test_add_remove_rmap_to_specific_neighbor_p0(): # Create ip prefix list input_dict_2 = { - 'r3': { - 'prefix_lists': { - 'ipv4': { - 'pf_list_1_ipv4': [{ - 'seqid': 10, - 'network': 'any', - 'action': 'deny' + "r3": { + "prefix_lists": { + "ipv4": { + "pf_list_1_ipv4": [{ + "seqid": 10, + "network": "any", + "action": "deny" }] }, - 'ipv6': { - 'pf_list_1_ipv6': [{ - 'seqid': 100, - 'network': 'any', - 'action': 'deny' + "ipv6": { + "pf_list_1_ipv6": [{ + "seqid": 100, + "network": "any", + "action": "deny" }] } } } } result = create_prefix_lists(tgen, input_dict_2) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Create route map @@ -2025,7 +2036,7 @@ def test_add_remove_rmap_to_specific_neighbor_p0(): "route_maps": { "rmap_match_pf_1_{}".format(addr_type): [{ "action": "permit", - 'seq_id': '5', + "seq_id": "5", "match": { addr_type: { "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -2039,12 +2050,12 @@ def test_add_remove_rmap_to_specific_neighbor_p0(): } } result = create_route_maps(tgen, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Configure neighbor for route map input_dict_4 = { - 'r3': { + "r3": { "bgp": { "address_family": { "ipv4": { @@ -2056,7 +2067,7 @@ def test_add_remove_rmap_to_specific_neighbor_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv4", - "direction": 'in' + "direction": "in" }] } } @@ -2073,7 +2084,7 @@ def test_add_remove_rmap_to_specific_neighbor_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv6", - "direction": 'in' + "direction": "in" }] } } @@ -2087,24 +2098,24 @@ def test_add_remove_rmap_to_specific_neighbor_p0(): } result = create_router_bgp(tgen, topo, input_dict_4) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying RIB routes - dut = 'r3' - protocol = 'bgp' + dut = "r3" + protocol = "bgp" input_dict = topo["routers"] for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, - protocol=protocol) - assert result is not True, 'Testcase {} : \n' - 'Expected Behavior: Routes are not present in RIB \n' - ' Error: {}'.format( + protocol=protocol, expected=False) + assert result is not True, "Testcase {} : Failed \n Error" + "Routes are still present: {}".format( tc_name, result) + logger.info("Expected behaviour: {}".format(result)) # Remove applied rmap from neighbor input_dict_4 = { - 'r3': { + "r3": { "bgp": { "address_family": { "ipv4": { @@ -2116,7 +2127,7 @@ def test_add_remove_rmap_to_specific_neighbor_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv4", - "direction": 'in', + "direction": "in", "delete": True }] } @@ -2134,7 +2145,7 @@ def test_add_remove_rmap_to_specific_neighbor_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv6", - "direction": 'in', + "direction": "in", "delete": True }] } @@ -2149,16 +2160,16 @@ def test_add_remove_rmap_to_specific_neighbor_p0(): } result = create_router_bgp(tgen, topo, input_dict_4) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying RIB routes - dut = 'r3' - protocol = 'bgp' + dut = "r3" + protocol = "bgp" input_dict = topo["routers"] for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) write_test_footer(tc_name) @@ -2177,7 +2188,7 @@ def test_clear_bgp_and_flap_interface_to_verify_rmap_properties_p0(): global bgp_convergence if bgp_convergence is not True: - pytest.skip('skipped because of BGP Convergence failure') + pytest.skip("skipped because of BGP Convergence failure") # test case name tc_name = inspect.stack()[0][3] @@ -2186,27 +2197,27 @@ def test_clear_bgp_and_flap_interface_to_verify_rmap_properties_p0(): # Create ip prefix list input_dict_2 = { - 'r3': { - 'prefix_lists': { - 'ipv4': { - 'pf_list_1_ipv4': [{ - 'seqid': 10, - 'network': 'any', - 'action': 'permit' + "r3": { + "prefix_lists": { + "ipv4": { + "pf_list_1_ipv4": [{ + "seqid": 10, + "network": "any", + "action": "permit" }] }, - 'ipv6': { - 'pf_list_1_ipv6': [{ - 'seqid': 100, - 'network': 'any', - 'action': 'permit' + "ipv6": { + "pf_list_1_ipv6": [{ + "seqid": 100, + "network": "any", + "action": "permit" }] } } } } result = create_prefix_lists(tgen, input_dict_2) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Create route map @@ -2216,7 +2227,7 @@ def test_clear_bgp_and_flap_interface_to_verify_rmap_properties_p0(): "route_maps": { "rmap_match_pf_1_{}".format(addr_type): [{ "action": "permit", - 'seq_id': '5', + "seq_id": "5", "match": { addr_type: { "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -2231,12 +2242,12 @@ def test_clear_bgp_and_flap_interface_to_verify_rmap_properties_p0(): } } result = create_route_maps(tgen, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Configure neighbor for route map input_dict_4 = { - 'r3': { + "r3": { "bgp": { "address_family": { "ipv4": { @@ -2248,7 +2259,7 @@ def test_clear_bgp_and_flap_interface_to_verify_rmap_properties_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv4", - "direction": 'in' + "direction": "in" }] } } @@ -2265,7 +2276,7 @@ def test_clear_bgp_and_flap_interface_to_verify_rmap_properties_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv6", - "direction": 'in' + "direction": "in" }] } } @@ -2279,20 +2290,20 @@ def test_clear_bgp_and_flap_interface_to_verify_rmap_properties_p0(): } result = create_router_bgp(tgen, topo, input_dict_4) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying RIB routes - dut = 'r3' - protocol = 'bgp' + dut = "r3" + protocol = "bgp" input_dict = topo["routers"] for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying BGP set attributes - dut = 'r3' + dut = "r3" routes = { "ipv4": ["10.0.20.1/32", "10.0.20.2/32"], "ipv6": ["1::1/128", "1::2/128"] @@ -2301,26 +2312,26 @@ def test_clear_bgp_and_flap_interface_to_verify_rmap_properties_p0(): rmap_name = "rmap_match_pf_1_{}".format(addr_type) result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type], rmap_name, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # clear bgp, so config changes would be reflected - dut = 'r3' + dut = "r3" result = clear_bgp_and_verify(tgen, topo, dut) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying RIB routes - dut = 'r3' - protocol = 'bgp' + dut = "r3" + protocol = "bgp" input_dict = topo["routers"] for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying BGP set attributes - dut = 'r3' + dut = "r3" routes = { "ipv4": ["10.0.20.1/32", "10.0.20.2/32"], "ipv6": ["1::1/128", "1::2/128"] @@ -2329,7 +2340,7 @@ def test_clear_bgp_and_flap_interface_to_verify_rmap_properties_p0(): rmap_name = "rmap_match_pf_1_{}".format(addr_type) result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type], rmap_name, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Flap interface to see if route-map properties are intact @@ -2348,19 +2359,19 @@ def test_clear_bgp_and_flap_interface_to_verify_rmap_properties_p0(): # Verify BGP convergence once interface is up result = verify_bgp_convergence(tgen, topo) assert result is True, ( - 'setup_module :Failed \n Error:' ' {}'.format(result)) + "setup_module :Failed \n Error:" " {}".format(result)) # Verifying RIB routes - dut = 'r3' - protocol = 'bgp' + dut = "r3" + protocol = "bgp" input_dict = topo["routers"] for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying BGP set attributes - dut = 'r3' + dut = "r3" routes = { "ipv4": ["10.0.20.1/32", "10.0.20.2/32"], "ipv6": ["1::1/128", "1::2/128"] @@ -2369,7 +2380,7 @@ def test_clear_bgp_and_flap_interface_to_verify_rmap_properties_p0(): rmap_name = "rmap_match_pf_1_{}".format(addr_type) result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type], rmap_name, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) write_test_footer(tc_name) @@ -2388,7 +2399,7 @@ def test_rmap_without_match_and_set_clause_p0(): global bgp_convergence if bgp_convergence is not True: - pytest.skip('skipped because of BGP Convergence failure') + pytest.skip("skipped because of BGP Convergence failure") # test case name tc_name = inspect.stack()[0][3] @@ -2402,22 +2413,22 @@ def test_rmap_without_match_and_set_clause_p0(): "route_maps": { "rmap_no_match_set_1_{}".format(addr_type): [{ "action": "permit", - 'seq_id': '5' + "seq_id": "5" }], "rmap_no_match_set_2_{}".format(addr_type): [{ "action": "deny", - 'seq_id': '5' + "seq_id": "5" }] } } } result = create_route_maps(tgen, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Configure neighbor for route map input_dict_4 = { - 'r3': { + "r3": { "bgp": { "address_family": { "ipv4": { @@ -2429,7 +2440,7 @@ def test_rmap_without_match_and_set_clause_p0(): "route_maps": [{ "name": "rmap_no_match_set_1_ipv4", - "direction": 'in' + "direction": "in" }] } } @@ -2440,7 +2451,7 @@ def test_rmap_without_match_and_set_clause_p0(): "route_maps": [{ "name": "rmap_no_match_set_2_ipv4", - "direction": 'out' + "direction": "out" }] } } @@ -2457,7 +2468,7 @@ def test_rmap_without_match_and_set_clause_p0(): "route_maps": [{ "name": "rmap_no_match_set_1_ipv6", - "direction": 'in' + "direction": "in" }] } } @@ -2468,7 +2479,7 @@ def test_rmap_without_match_and_set_clause_p0(): "route_maps": [{ "name": "rmap_no_match_set_2_ipv6", - "direction": 'out' + "direction": "out" }] } } @@ -2482,30 +2493,30 @@ def test_rmap_without_match_and_set_clause_p0(): } result = create_router_bgp(tgen, topo, input_dict_4) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying RIB routes - dut = 'r3' - protocol = 'bgp' + dut = "r3" + protocol = "bgp" input_dict = topo["routers"] for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying RIB routes - dut = 'r4' - protocol = 'bgp' + dut = "r4" + protocol = "bgp" for addr_type in ADDR_TYPES: - result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is not True, 'Testcase {} : Failed \n' - 'Expected behaviour: routes are not present \n ' - 'Error: {}'.format( + result = verify_rib(tgen, addr_type, dut, input_dict, + protocol=protocol, expected=False) + assert result is not True, "Testcase {} : Failed \n" + "routes are not present \n Error: {}".format( tc_name, result) + logger.info("Expected behaviour: {}".format(result)) write_test_footer(tc_name) - # Uncomment next line for debugging # tgen.mininet_cli() @@ -2520,7 +2531,7 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0(): global bgp_convergence if bgp_convergence is not True: - pytest.skip('skipped because of BGP Convergence failure') + pytest.skip("skipped because of BGP Convergence failure") # test case name tc_name = inspect.stack()[0][3] @@ -2529,27 +2540,27 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0(): # Create ip prefix list input_dict_2 = { - 'r3': { - 'prefix_lists': { - 'ipv4': { - 'pf_list_1_ipv4': [{ - 'seqid': 10, - 'network': 'any', - 'action': 'permit' + "r3": { + "prefix_lists": { + "ipv4": { + "pf_list_1_ipv4": [{ + "seqid": 10, + "network": "any", + "action": "permit" }] }, - 'ipv6': { - 'pf_list_1_ipv6': [{ - 'seqid': 100, - 'network': 'any', - 'action': 'permit' + "ipv6": { + "pf_list_1_ipv6": [{ + "seqid": 100, + "network": "any", + "action": "permit" }] } } } } result = create_prefix_lists(tgen, input_dict_2) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Create route map @@ -2597,12 +2608,12 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0(): } input_dict_3_addr_type[addr_type] = input_dict_3 result = create_route_maps(tgen, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Configure neighbor for route map input_dict_4 = { - 'r3': { + "r3": { "bgp": { "address_family": { "ipv4": { @@ -2614,7 +2625,7 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv4", - "direction": 'in' + "direction": "in" }] } } @@ -2625,7 +2636,7 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0(): "route_maps": [{ "name": "rmap_match_pf_2_ipv4", - "direction": 'out' + "direction": "out" }] } } @@ -2636,7 +2647,7 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0(): "route_maps": [{ "name": "rmap_match_pf_3_ipv4", - "direction": 'out' + "direction": "out" }] } } @@ -2653,7 +2664,7 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv6", - "direction": 'in' + "direction": "in" }] } } @@ -2664,7 +2675,7 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0(): "route_maps": [{ "name": "rmap_match_pf_2_ipv6", - "direction": 'out' + "direction": "out" }] } } @@ -2675,7 +2686,7 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0(): "route_maps": [{ "name": "rmap_match_pf_3_ipv6", - "direction": 'out' + "direction": "out" }] } } @@ -2689,21 +2700,21 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0(): } result = create_router_bgp(tgen, topo, input_dict_4) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying RIB routes - dut = 'r3' - protocol = 'bgp' + dut = "r3" + protocol = "bgp" input_dict = topo["routers"] for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying BGP set attributes - dut = 'r3' + dut = "r3" routes = { "ipv4": ["10.0.20.1/32", "10.0.20.2/32"], "ipv6": ["1::1/128", "1::2/128"] @@ -2713,20 +2724,20 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0(): rmap_name = "rmap_match_pf_1_{}".format(addr_type) result = verify_bgp_attributes(tgen, addr_type, dut, routes[ addr_type],rmap_name, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying RIB routes - dut = 'r4' - protocol = 'bgp' + dut = "r4" + protocol = "bgp" for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying BGP set attributes - dut = 'r4' + dut = "r4" routes = { "ipv4": ["10.0.20.1/32", "10.0.20.2/32"], "ipv6": ["1::1/128", "1::2/128"] @@ -2736,22 +2747,23 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0(): rmap_name = "rmap_match_pf_2_{}".format(addr_type) result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type], - rmap_name, input_dict_3_addr_type[addr_type]) - assert result is not True, 'Testcase {} : Failed \n' - 'Expected behaviour: Attributes are not set \n' - 'Error: {}'.format( + rmap_name, input_dict_3_addr_type[addr_type], + expected=False) + assert result is not True, "Testcase {} : Failed \n" + "Attributes are not set \n Error: {}".format( tc_name, result) + logger.info("Expected behaviour: {}".format(result)) # Verifying RIB routes - dut = 'r5' - protocol = 'bgp' + dut = "r5" + protocol = "bgp" for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying BGP set attributes - dut = 'r5' + dut = "r5" routes = { "ipv4": ["10.0.20.1/32", "10.0.20.2/32"], "ipv6": ["1::1/128", "1::2/128"] @@ -2761,12 +2773,11 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0(): for addr_type in ADDR_TYPES: rmap_name = "rmap_match_pf_3_{}".format(addr_type) result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type], - rmap_name, input_dict_3_addr_type[addr_type]) - assert result is not True, 'Testcase {} : Failed \n' - 'Expected behaviour: Attributes are not set \n' - 'Error: {}'.format( + rmap_name, input_dict_3_addr_type[addr_type], + expected=False) + assert result is not True, "Testcase {} : Failed \n" + "Attributes are not set \n Error: {}".format( tc_name, result) - logger.info("Expected behaviour: {}".format(result)) write_test_footer(tc_name) @@ -2778,14 +2789,14 @@ def test_set_localpref_weight_to_ebgp_and_med_to_ibgp_peers_p0(): def test_multiple_set_on_single_sequence_in_rmap_p0(): """ TC_43: - Test multiple set statements as part of a route-map's + Test multiple set statements as part of a route-map"s single sequence number. """ tgen = get_topogen() global bgp_convergence if bgp_convergence is not True: - pytest.skip('skipped because of BGP Convergence failure') + pytest.skip("skipped because of BGP Convergence failure") # test case name tc_name = inspect.stack()[0][3] @@ -2794,27 +2805,27 @@ def test_multiple_set_on_single_sequence_in_rmap_p0(): # Create ip prefix list input_dict_2 = { - 'r3': { - 'prefix_lists': { - 'ipv4': { - 'pf_list_1_ipv4': [{ - 'seqid': 10, - 'network': 'any', - 'action': 'permit' + "r3": { + "prefix_lists": { + "ipv4": { + "pf_list_1_ipv4": [{ + "seqid": 10, + "network": "any", + "action": "permit" }] }, - 'ipv6': { - 'pf_list_1_ipv6': [{ - 'seqid': 100, - 'network': 'any', - 'action': 'permit' + "ipv6": { + "pf_list_1_ipv6": [{ + "seqid": 100, + "network": "any", + "action": "permit" }] } } } } result = create_prefix_lists(tgen, input_dict_2) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Create route map @@ -2839,12 +2850,12 @@ def test_multiple_set_on_single_sequence_in_rmap_p0(): } } result = create_route_maps(tgen, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Configure neighbor for route map input_dict_4 = { - 'r3': { + "r3": { "bgp": { "address_family": { "ipv4": { @@ -2856,7 +2867,7 @@ def test_multiple_set_on_single_sequence_in_rmap_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv4", - "direction": 'in' + "direction": "in" }] } } @@ -2873,7 +2884,7 @@ def test_multiple_set_on_single_sequence_in_rmap_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv6", - "direction": 'in' + "direction": "in" }] } } @@ -2886,20 +2897,20 @@ def test_multiple_set_on_single_sequence_in_rmap_p0(): } } result = create_router_bgp(tgen, topo, input_dict_4) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying RIB routes - dut = 'r3' - protocol = 'bgp' + dut = "r3" + protocol = "bgp" input_dict = topo["routers"] for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying BGP set attributes - dut = 'r3' + dut = "r3" routes = { "ipv4": ["10.0.20.1/32", "10.0.20.2/32"], "ipv6": ["1::1/128", "1::2/128"] @@ -2910,7 +2921,7 @@ def test_multiple_set_on_single_sequence_in_rmap_p0(): rmap_name = "rmap_match_pf_1_{}".format(addr_type) result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type], rmap_name, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) write_test_footer(tc_name) @@ -2928,7 +2939,7 @@ def test_route_maps_with_continue_clause_p0(): global bgp_convergence if bgp_convergence is not True: - pytest.skip('skipped because of BGP Convergence failure') + pytest.skip("skipped because of BGP Convergence failure") # test case name tc_name = inspect.stack()[0][3] @@ -2937,27 +2948,27 @@ def test_route_maps_with_continue_clause_p0(): # Create ip prefix list input_dict_2 = { - 'r3': { - 'prefix_lists': { - 'ipv4': { - 'pf_list_1_ipv4': [{ - 'seqid': 10, - 'network': 'any', - 'action': 'permit' + "r3": { + "prefix_lists": { + "ipv4": { + "pf_list_1_ipv4": [{ + "seqid": 10, + "network": "any", + "action": "permit" }] }, - 'ipv6': { - 'pf_list_1_ipv6': [{ - 'seqid': 100, - 'network': 'any', - 'action': 'permit' + "ipv6": { + "pf_list_1_ipv6": [{ + "seqid": 100, + "network": "any", + "action": "permit" }] } } } } result = create_prefix_lists(tgen, input_dict_2) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Create route map @@ -2967,7 +2978,7 @@ def test_route_maps_with_continue_clause_p0(): "route_maps": { "rmap_match_pf_1_{}".format(addr_type): [{ "action": "permit", - 'seq_id': '10', + "seq_id": "10", "match": { addr_type: { "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -2980,7 +2991,7 @@ def test_route_maps_with_continue_clause_p0(): }, { "action": "permit", - 'seq_id': '20', + "seq_id": "20", "match": { addr_type: { "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -2992,7 +3003,7 @@ def test_route_maps_with_continue_clause_p0(): }, { "action": "permit", - 'seq_id': '30', + "seq_id": "30", "match": { addr_type: { "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -3007,12 +3018,12 @@ def test_route_maps_with_continue_clause_p0(): } } result = create_route_maps(tgen, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Configure neighbor for route map input_dict_4 = { - 'r3': { + "r3": { "bgp": { "address_family": { "ipv4": { @@ -3024,7 +3035,7 @@ def test_route_maps_with_continue_clause_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv4", - "direction": 'in' + "direction": "in" }] } } @@ -3041,7 +3052,7 @@ def test_route_maps_with_continue_clause_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv6", - "direction": 'in' + "direction": "in" }] } } @@ -3054,21 +3065,21 @@ def test_route_maps_with_continue_clause_p0(): } } result = create_router_bgp(tgen, topo, input_dict_4) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying RIB routes - dut = 'r3' - protocol = 'bgp' + dut = "r3" + protocol = "bgp" input_dict = topo["routers"] for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying BGP set attributes - dut = 'r3' + dut = "r3" rmap_name = "rmap_match_pf_1" routes = { "ipv4": ["10.0.20.1/32", "10.0.20.2/32"], @@ -3082,7 +3093,7 @@ def test_route_maps_with_continue_clause_p0(): rmap_name = "rmap_match_pf_1_{}".format(addr_type) result = verify_bgp_attributes(tgen, addr_type, dut, routes[ addr_type],rmap_name, input_dict_3, seq_id[addr_type]) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) write_test_footer(tc_name) @@ -3100,7 +3111,7 @@ def test_route_maps_with_goto_clause_p0(): global bgp_convergence if bgp_convergence is not True: - pytest.skip('skipped because of BGP Convergence failure') + pytest.skip("skipped because of BGP Convergence failure") # test case name tc_name = inspect.stack()[0][3] @@ -3109,27 +3120,27 @@ def test_route_maps_with_goto_clause_p0(): # Create ip prefix list input_dict_2 = { - 'r3': { - 'prefix_lists': { - 'ipv4': { - 'pf_list_1_ipv4': [{ - 'seqid': 10, - 'network': 'any', - 'action': 'permit' + "r3": { + "prefix_lists": { + "ipv4": { + "pf_list_1_ipv4": [{ + "seqid": 10, + "network": "any", + "action": "permit" }] }, - 'ipv6': { - 'pf_list_1_ipv6': [{ - 'seqid': 100, - 'network': 'any', - 'action': 'permit' + "ipv6": { + "pf_list_1_ipv6": [{ + "seqid": 100, + "network": "any", + "action": "permit" }] } } } } result = create_prefix_lists(tgen, input_dict_2) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Create route map @@ -3139,7 +3150,7 @@ def test_route_maps_with_goto_clause_p0(): "route_maps": { "rmap_match_pf_1_{}".format(addr_type): [{ "action": "permit", - 'seq_id': '10', + "seq_id": "10", "match": { addr_type: { "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -3149,7 +3160,7 @@ def test_route_maps_with_goto_clause_p0(): }, { "action": "permit", - 'seq_id': '20', + "seq_id": "20", "match": { addr_type: { "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -3161,7 +3172,7 @@ def test_route_maps_with_goto_clause_p0(): }, { "action": "permit", - 'seq_id': '30', + "seq_id": "30", "match": { addr_type: { "prefix_lists": "pf_list_1_{}".format(addr_type) @@ -3176,12 +3187,13 @@ def test_route_maps_with_goto_clause_p0(): } } result = create_route_maps(tgen, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + # tgen.mininet_cli() + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Configure neighbor for route map input_dict_4 = { - 'r3': { + "r3": { "bgp": { "address_family": { "ipv4": { @@ -3193,7 +3205,7 @@ def test_route_maps_with_goto_clause_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv4", - "direction": 'in' + "direction": "in" }] } } @@ -3210,7 +3222,7 @@ def test_route_maps_with_goto_clause_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv6", - "direction": 'in' + "direction": "in" }] } } @@ -3223,20 +3235,20 @@ def test_route_maps_with_goto_clause_p0(): } } result = create_router_bgp(tgen, topo, input_dict_4) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying RIB routes - dut = 'r3' - protocol = 'bgp' + dut = "r3" + protocol = "bgp" input_dict = topo["routers"] for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying BGP set attributes - dut = 'r3' + dut = "r3" rmap_name = "rmap_match_pf_1" routes = { "ipv4": ["10.0.20.1/32", "10.0.20.2/32"], @@ -3250,7 +3262,7 @@ def test_route_maps_with_goto_clause_p0(): rmap_name = "rmap_match_pf_1_{}".format(addr_type) result = verify_bgp_attributes(tgen, addr_type, dut, routes[ addr_type],rmap_name, input_dict_3, seq_id[addr_type]) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) write_test_footer(tc_name) @@ -3268,7 +3280,7 @@ def test_route_maps_with_call_clause_p0(): global bgp_convergence if bgp_convergence is not True: - pytest.skip('skipped because of BGP Convergence failure') + pytest.skip("skipped because of BGP Convergence failure") # test case name tc_name = inspect.stack()[0][3] @@ -3277,27 +3289,27 @@ def test_route_maps_with_call_clause_p0(): # Create ip prefix list input_dict_2 = { - 'r3': { - 'prefix_lists': { - 'ipv4': { - 'pf_list_1_ipv4': [{ - 'seqid': 10, - 'network': 'any', - 'action': 'permit' + "r3": { + "prefix_lists": { + "ipv4": { + "pf_list_1_ipv4": [{ + "seqid": 10, + "network": "any", + "action": "permit" }] }, - 'ipv6': { - 'pf_list_1_ipv6': [{ - 'seqid': 100, - 'network': 'any', - 'action': 'permit' + "ipv6": { + "pf_list_1_ipv6": [{ + "seqid": 100, + "network": "any", + "action": "permit" }] } } } } result = create_prefix_lists(tgen, input_dict_2) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Create route map @@ -3332,12 +3344,12 @@ def test_route_maps_with_call_clause_p0(): } } result = create_route_maps(tgen, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Configure neighbor for route map input_dict_4 = { - 'r3': { + "r3": { "bgp": { "address_family": { "ipv4": { @@ -3349,7 +3361,7 @@ def test_route_maps_with_call_clause_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv4", - "direction": 'in' + "direction": "in" }] } } @@ -3366,7 +3378,7 @@ def test_route_maps_with_call_clause_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv6", - "direction": 'in' + "direction": "in" }] } } @@ -3379,20 +3391,20 @@ def test_route_maps_with_call_clause_p0(): } } result = create_router_bgp(tgen, topo, input_dict_4) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying RIB routes - dut = 'r3' - protocol = 'bgp' + dut = "r3" + protocol = "bgp" input_dict = topo["routers"] for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying BGP set attributes - dut = 'r3' + dut = "r3" routes = { "ipv4": ["10.0.20.1/32", "10.0.20.2/32"], "ipv6": ["1::1/128", "1::2/128"] @@ -3402,7 +3414,7 @@ def test_route_maps_with_call_clause_p0(): rmap_name = "rmap_match_pf_1_{}".format(addr_type) result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type], rmap_name, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) rmap_name = "rmap_match_pf_2" @@ -3410,7 +3422,7 @@ def test_route_maps_with_call_clause_p0(): rmap_name = "rmap_match_pf_2_{}".format(addr_type) result = verify_bgp_attributes(tgen, addr_type, dut, routes[addr_type], rmap_name, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) write_test_footer(tc_name) @@ -3429,7 +3441,7 @@ def test_create_rmap_match_prefix_list_to_deny_in_and_outbound_prefixes_p0(): global bgp_convergence if bgp_convergence is not True: - pytest.skip('skipped because of BGP Convergence failure') + pytest.skip("skipped because of BGP Convergence failure") # test case name tc_name = inspect.stack()[0][3] @@ -3438,27 +3450,27 @@ def test_create_rmap_match_prefix_list_to_deny_in_and_outbound_prefixes_p0(): # Create ip prefix list input_dict_2 = { - 'r3': { - 'prefix_lists': { - 'ipv4': { - 'pf_list_1_ipv4': [{ - 'seqid': 10, - 'network': 'any', - 'action': 'permit' + "r3": { + "prefix_lists": { + "ipv4": { + "pf_list_1_ipv4": [{ + "seqid": 10, + "network": "any", + "action": "permit" }] }, - 'ipv6': { - 'pf_list_1_ipv6': [{ - 'seqid': 100, - 'network': 'any', - 'action': 'permit' + "ipv6": { + "pf_list_1_ipv6": [{ + "seqid": 100, + "network": "any", + "action": "permit" }] } } } } result = create_prefix_lists(tgen, input_dict_2) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Create route map @@ -3492,12 +3504,12 @@ def test_create_rmap_match_prefix_list_to_deny_in_and_outbound_prefixes_p0(): } } result = create_route_maps(tgen, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Configure neighbor for route map input_dict_4 = { - 'r3': { + "r3": { "bgp": { "address_family": { "ipv4": { @@ -3509,7 +3521,7 @@ def test_create_rmap_match_prefix_list_to_deny_in_and_outbound_prefixes_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv4", - "direction": 'in' + "direction": "in" }] } } @@ -3520,7 +3532,7 @@ def test_create_rmap_match_prefix_list_to_deny_in_and_outbound_prefixes_p0(): "route_maps": [{ "name": "rmap_match_pf_2_ipv6", - "direction": 'out' + "direction": "out" }] } } @@ -3537,7 +3549,7 @@ def test_create_rmap_match_prefix_list_to_deny_in_and_outbound_prefixes_p0(): "route_maps": [{ "name": "rmap_match_pf_1_ipv4", - "direction": 'in' + "direction": "in" }] } } @@ -3548,7 +3560,7 @@ def test_create_rmap_match_prefix_list_to_deny_in_and_outbound_prefixes_p0(): "route_maps": [{ "name": "rmap_match_pf_2_ipv6", - "direction": 'out' + "direction": "out" }] } } @@ -3561,31 +3573,31 @@ def test_create_rmap_match_prefix_list_to_deny_in_and_outbound_prefixes_p0(): } } result = create_router_bgp(tgen, topo, input_dict_4) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying RIB routes - dut = 'r3' - protocol = 'bgp' + dut = "r3" + protocol = "bgp" input_dict = topo["routers"] for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, - protocol=protocol) - assert result is not True, 'Testcase {} : Failed \n' - 'Expected behaviour: routes are not present \n ' - 'Error: {}'.format( - tc_name, result) + protocol=protocol, expected=False) + assert result is not True, "Testcase {} : Failed \n" + "routes are not present \n Error: {}".\ + format(tc_name, result) + logger.info("Expected behaviour: {}".format(result)) # Verifying RIB routes - dut = 'r4' - protocol = 'bgp' + dut = "r4" + protocol = "bgp" for addr_type in ADDR_TYPES: result = verify_rib(tgen, addr_type, dut, input_dict, - protocol=protocol) - assert result is not True, 'Testcase {} : Failed \n' - 'Expected behaviour: routes are not present \n ' - 'Error: {}'.format( - tc_name, result) + protocol=protocol, expected=False) + assert result is not True, "Testcase {} : Failed \n" + "routes are not present \n Error: {}".\ + format(tc_name, result) + logger.info("Expected behaviour: {}".format(result)) write_test_footer(tc_name) @@ -3603,7 +3615,7 @@ def test_create_rmap_to_match_tag_permit_inbound_prefixes_p0(): global bgp_convergence if bgp_convergence is not True: - pytest.skip('skipped because of BGP Convergence failure') + pytest.skip("skipped because of BGP Convergence failure") # test case name tc_name = inspect.stack()[0][3] @@ -3675,12 +3687,12 @@ def test_create_rmap_to_match_tag_permit_inbound_prefixes_p0(): } } result = create_route_maps(tgen, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Configure neighbor for route map input_dict_4 = { - 'r1': { + "r1": { "bgp": { "address_family": { "ipv4": { @@ -3692,7 +3704,7 @@ def test_create_rmap_to_match_tag_permit_inbound_prefixes_p0(): "route_maps": [{ "name": "rmap_match_tag_1_ipv4", - "direction": 'out' + "direction": "out" }] } } @@ -3709,7 +3721,7 @@ def test_create_rmap_to_match_tag_permit_inbound_prefixes_p0(): "route_maps": [{ "name": "rmap_match_tag_1_ipv6", - "direction": 'out' + "direction": "out" }] } } @@ -3722,12 +3734,12 @@ def test_create_rmap_to_match_tag_permit_inbound_prefixes_p0(): } } result = create_router_bgp(tgen, topo, input_dict_4) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying RIB routes - dut = 'r3' - protocol = 'bgp' + dut = "r3" + protocol = "bgp" for addr_type in ADDR_TYPES: input_dict = { @@ -3743,7 +3755,7 @@ def test_create_rmap_to_match_tag_permit_inbound_prefixes_p0(): } result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) write_test_footer(tc_name) @@ -3762,7 +3774,7 @@ def test_create_rmap_to_match_tag_deny_outbound_prefixes_p0(): global bgp_convergence if bgp_convergence is not True: - pytest.skip('skipped because of BGP Convergence failure') + pytest.skip("skipped because of BGP Convergence failure") # test case name tc_name = inspect.stack()[0][3] @@ -3834,12 +3846,12 @@ def test_create_rmap_to_match_tag_deny_outbound_prefixes_p0(): } } result = create_route_maps(tgen, input_dict_3) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Configure neighbor for route map input_dict_4 = { - 'r1': { + "r1": { "bgp": { "address_family": { "ipv4": { @@ -3851,7 +3863,7 @@ def test_create_rmap_to_match_tag_deny_outbound_prefixes_p0(): "route_maps": [{ "name": "rmap_match_tag_1_ipv4", - "direction": 'out' + "direction": "out" }] } } @@ -3868,7 +3880,7 @@ def test_create_rmap_to_match_tag_deny_outbound_prefixes_p0(): "route_maps": [{ "name": "rmap_match_tag_1_ipv6", - "direction": 'out' + "direction": "out" }] } } @@ -3881,12 +3893,12 @@ def test_create_rmap_to_match_tag_deny_outbound_prefixes_p0(): } } result = create_router_bgp(tgen, topo, input_dict_4) - assert result is True, 'Testcase {} : Failed \n Error: {}'.format( + assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) # Verifying RIB routes - dut = 'r3' - protocol = 'bgp' + dut = "r3" + protocol = "bgp" for addr_type in ADDR_TYPES: input_dict = { @@ -3901,16 +3913,17 @@ def test_create_rmap_to_match_tag_deny_outbound_prefixes_p0(): } } result = verify_rib(tgen, addr_type, dut, input_dict, - protocol=protocol) - assert result is not True, 'Testcase {} : Failed \n' - 'Expected behavior: routes are denied \n Error: {}'.format( + protocol=protocol, expected=False) + assert result is not True, "Testcase {} : Failed \n" + "routes are denied \n Error: {}".format( tc_name, result) + logger.info("Expected behaviour: {}".format(result)) write_test_footer(tc_name) # Uncomment next line for debugging # tgen.mininet_cli() -if __name__ == '__main__': +if __name__ == "__main__": args = ["-s"] + sys.argv[1:] sys.exit(pytest.main(args)) diff --git a/tests/topotests/lib/bgp.py b/tests/topotests/lib/bgp.py index a8354f4c7..f3c17be68 100644 --- a/tests/topotests/lib/bgp.py +++ b/tests/topotests/lib/bgp.py @@ -1293,16 +1293,13 @@ def verify_bgp_attributes(tgen, addr_type, dut, static_routes, rmap_name, for static_route in static_routes: cmd = "show bgp {} {} json".format(addr_type, static_route) show_bgp_json = run_frr_cmd(rnode, cmd, isjson=True) - print("show_bgp_json $$$$$", show_bgp_json) dict_to_test = [] tmp_list = [] for rmap_router in input_dict.keys(): for rmap, values in input_dict[rmap_router][ "route_maps"].items(): - print("rmap == rmap_name $$$$1", rmap, rmap_name) if rmap == rmap_name: - print("rmap == rmap_name $$$$", rmap, rmap_name) dict_to_test = values for rmap_dict in values: if seq_id is not None: @@ -1318,7 +1315,6 @@ def verify_bgp_attributes(tgen, addr_type, dut, static_routes, rmap_name, if tmp_list: dict_to_test = tmp_list - print("dict_to_test $$$$", dict_to_test) for rmap_dict in dict_to_test: if "set" in rmap_dict: for criteria in rmap_dict["set"].keys(): |