diff options
author | Kuldeep Kashyap <kashyapk@vmware.com> | 2019-10-20 20:38:53 +0200 |
---|---|---|
committer | Kuldeep Kashyap <kuldeepkas@gmail.com> | 2019-10-21 06:18:20 +0200 |
commit | 4a252f72058597827c5ed983664ba0ae67d80c7a (patch) | |
tree | 51f3d57a751cdfae619e49931a14ce71a3a943e0 /tests | |
parent | tests: Enhance BGP Path attribute APIs (diff) | |
download | frr-4a252f72058597827c5ed983664ba0ae67d80c7a.tar.xz frr-4a252f72058597827c5ed983664ba0ae67d80c7a.zip |
tests: Enhance BGP Path attribute test cases
1. Added steps to modify BGP path attributes and verify
best path is changed
Signed-off-by: Kuldeep Kashyap <kashyapkas@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/topotests/bgp-path-attributes-topo1/bgp_path_attributes.json | 143 | ||||
-rwxr-xr-x | tests/topotests/bgp-path-attributes-topo1/test_bgp_path_attributes.py | 841 |
2 files changed, 914 insertions, 70 deletions
diff --git a/tests/topotests/bgp-path-attributes-topo1/bgp_path_attributes.json b/tests/topotests/bgp-path-attributes-topo1/bgp_path_attributes.json index 15b7ec13b..de2bffa33 100644 --- a/tests/topotests/bgp-path-attributes-topo1/bgp_path_attributes.json +++ b/tests/topotests/bgp-path-attributes-topo1/bgp_path_attributes.json @@ -12,6 +12,17 @@ "r2":{"ipv4":"auto", "ipv6":"auto"}, "r3":{"ipv4":"auto", "ipv6":"auto"} }, + "route_maps": { + "rmap_global": [{ + "action": "permit", + "set": { + "ipv6": { + "nexthop": "prefer-global" + } + } + } + ] + }, "bgp":{ "local_as":"555", "address_family": { @@ -20,8 +31,34 @@ "neighbor": { "r2": { "dest_link": { + "r1": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + } + } + }, + "r3": { + "dest_link": { "r1": {} } + } + } + } + }, + "ipv6": { + "unicast": { + "neighbor": { + "r2": { + "dest_link": { + "r1": { + "route_maps": [{ + "name": "rmap_global", + "direction": "in" + }] + } + } }, "r3": { "dest_link": { @@ -65,6 +102,27 @@ } } } + }, + "ipv6": { + "unicast": { + "neighbor": { + "r1": { + "dest_link": { + "r2": {} + } + }, + "r3": { + "dest_link": { + "r2": {} + } + }, + "r4": { + "dest_link": { + "r2-link1": {} + } + } + } + } } } } @@ -99,6 +157,27 @@ } } } + }, + "ipv6": { + "unicast": { + "neighbor": { + "r1": { + "dest_link": { + "r3": {} + } + }, + "r2": { + "dest_link": { + "r3": {} + } + }, + "r5": { + "dest_link": { + "r3": {} + } + } + } + } } } } @@ -128,6 +207,22 @@ } } } + }, + "ipv6": { + "unicast": { + "neighbor": { + "r2": { + "dest_link": { + "r4-link1": {} + } + }, + "r6": { + "dest_link": { + "r4": {} + } + } + } + } } } } @@ -156,6 +251,22 @@ } } } + }, + "ipv6": { + "unicast": { + "neighbor": { + "r3": { + "dest_link": { + "r5": {} + } + }, + "r7": { + "dest_link": { + "r5": {} + } + } + } + } } } } @@ -184,6 +295,22 @@ } } } + }, + "ipv6": { + "unicast": { + "neighbor": { + "r4": { + "dest_link": { + "r6": {} + } + }, + "r7": { + "dest_link": { + "r6": {} + } + } + } + } } } } @@ -212,6 +339,22 @@ } } } + }, + "ipv6": { + "unicast": { + "neighbor": { + "r5": { + "dest_link": { + "r7": {} + } + }, + "r6": { + "dest_link": { + "r7": {} + } + } + } + } } } } diff --git a/tests/topotests/bgp-path-attributes-topo1/test_bgp_path_attributes.py b/tests/topotests/bgp-path-attributes-topo1/test_bgp_path_attributes.py index 9f92b4b29..3b2d9c25d 100755 --- a/tests/topotests/bgp-path-attributes-topo1/test_bgp_path_attributes.py +++ b/tests/topotests/bgp-path-attributes-topo1/test_bgp_path_attributes.py @@ -76,13 +76,14 @@ from lib.common_config import ( write_test_footer, reset_config_on_routers, verify_rib, create_static_routes, create_prefix_lists, verify_prefix_lists, - create_route_maps + create_route_maps, check_address_types ) from lib.topolog import logger from lib.bgp import ( verify_bgp_convergence, create_router_bgp, clear_bgp_and_verify, verify_best_path_as_per_bgp_attribute, - verify_best_path_as_per_admin_distance + verify_best_path_as_per_admin_distance, modify_as_number, + verify_as_numbers ) from lib.topojson import build_topo_from_json, build_config_from_json @@ -95,6 +96,8 @@ try: except IOError: assert False, "Could not read file {}".format(jsonFile) +# Address read from env variables +ADDR_TYPES = check_address_types() #### class CreateTopo(Topo): @@ -119,6 +122,8 @@ def setup_module(mod): * `mod`: module name """ + global ADDR_TYPES + testsuite_run_time = time.asctime(time.localtime(time.time())) logger.info("Testsuite start time: %s", testsuite_run_time) logger.info("=" * 40) @@ -170,6 +175,7 @@ def teardown_module(): ## Testcases ## ##################################################### + def test_next_hop_attribute(request): """ Verifying route are not getting installed in, as next_hop is @@ -193,7 +199,7 @@ def test_next_hop_attribute(request): # Api call to advertise networks input_dict = { "r7": { - "bgp":{ + "bgp": { "address_family": { "ipv4": { "unicast": { @@ -206,6 +212,18 @@ def test_next_hop_attribute(request): } ] } + }, + "ipv6": { + "unicast": { + "advertise_networks": [ + { + "network": "200:50:2::/128" + }, + { + "network": "200:60:2::/128" + } + ] + } } } } @@ -218,9 +236,12 @@ def test_next_hop_attribute(request): # Verifying RIB routes dut = "r1" protocol = "bgp" - result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol, expected=False) - assert result is not True, "Testcase {} : Failed \n Error: Routes still" \ - " present in RIB".format(tc_name) + # Verification should fail as nexthop-self is not enabled + for addr_type in ADDR_TYPES: + result = verify_rib(tgen, addr_type, dut, input_dict, + protocol=protocol, expected=False) + assert result is not True, "Testcase {} : Failed \n Error: "\ + "{} routes are not present in RIB".format(addr_type, tc_name) # Configure next-hop-self to bgp neighbor input_dict_1 = { @@ -237,6 +258,17 @@ def test_next_hop_attribute(request): } } } + }, + "ipv6": { + "unicast": { + "neighbor": { + "r1": { + "dest_link": { + "r2": {"next_hop_self": True} + } + } + } + } } } } @@ -254,11 +286,23 @@ def test_next_hop_attribute(request): } } } + }, + "ipv6": { + "unicast": { + "neighbor": { + "r1": { + "dest_link": { + "r3": {"next_hop_self": True} + } + } + } + } } } } } } + result = create_router_bgp(tgen, topo, input_dict_1) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) @@ -266,9 +310,11 @@ def test_next_hop_attribute(request): # Verifying RIB routes dut = "r1" protocol = "bgp" - result = verify_rib(tgen, "ipv4", dut, input_dict, protocol=protocol) - assert result is True, "Testcase {} : Failed \n Error: {}".format( - tc_name, result) + 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( + tc_name, result) write_test_footer(tc_name) @@ -305,6 +351,18 @@ def test_aspath_attribute(request): } ] } + }, + "ipv6": { + "unicast": { + "advertise_networks": [ + { + "network": "200:50:2::/128" + }, + { + "network": "200:60:2::/128" + } + ] + } } } } @@ -322,6 +380,17 @@ def test_aspath_attribute(request): } } } + }, + "ipv6": { + "unicast": { + "neighbor": { + "r1": { + "dest_link": { + "r2": {"next_hop_self": True} + } + } + } + } } } } @@ -339,6 +408,17 @@ def test_aspath_attribute(request): } } } + }, + "ipv6": { + "unicast": { + "neighbor": { + "r1": { + "dest_link": { + "r3": {"next_hop_self": True} + } + } + } + } } } } @@ -351,11 +431,136 @@ def test_aspath_attribute(request): # Verifying best path dut = "r1" attribute = "aspath" - result = verify_best_path_as_per_bgp_attribute(tgen, "ipv4", dut, - input_dict, attribute) + for addr_type in ADDR_TYPES: + result = verify_best_path_as_per_bgp_attribute(tgen, addr_type, dut, + {"r7": input_dict["r7"]}, + attribute) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result) + + # Modify AS-Path and verify best path is changed + # Create Prefix list + + input_dict_2 = { + "r3": { + "prefix_lists": { + "ipv4": { + "pf_ls_1_ipv4": [{ + "seqid": 10, + "network": "200.0.0.0/8", + "le": "32", + "action": "permit" + }] + }, + "ipv6": { + "pf_ls_1_ipv6": [{ + "seqid": 10, + "network": "200::/8", + "le": "128", + "action": "permit" + }] + } + } + } + } + result = create_prefix_lists(tgen, input_dict_2) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result) + + # Create route map + input_dict_3 = { + "r3": { + "route_maps": { + "RMAP_AS_PATH": [{ + "action": "permit", + "match": { + "ipv4": { + "prefix_lists": "pf_ls_1_ipv4" + } + }, + "set": { + "aspath": { + "as_num": "111 222", + "as_action": "prepend" + } + } + }, + { + "action": "permit", + "match": { + "ipv6": { + "prefix_lists": "pf_ls_1_ipv6" + } + }, + "set": { + "aspath": { + "as_num": "111 222", + "as_action": "prepend" + } + } + }] + } + } + } + result = create_route_maps(tgen, input_dict_3) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result) + + # Configure neighbor for route map + input_dict_4 = { + "r3": { + "bgp": { + "address_family": { + "ipv4": { + "unicast": { + "neighbor": { + "r5": { + "dest_link": { + "r3": { + "route_maps": [ + {"name": "RMAP_AS_PATH", + "direction": "in"} + ] + } + } + } + } + } + }, + "ipv6": { + "unicast": { + "neighbor": { + "r5": { + "dest_link": { + "r3": { + "route_maps": [ + {"name": "RMAP_AS_PATH", + "direction": "in"} + ] + } + } + } + } + } + } + } + } + } + } + result = create_router_bgp(tgen, topo, input_dict_4) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) + # Verifying best path + dut = "r1" + attribute = "aspath" + for addr_type in ADDR_TYPES: + result = verify_best_path_as_per_bgp_attribute(tgen, addr_type, dut, + {"r7": input_dict["r7"]}, + attribute) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result) + write_test_footer(tc_name) @@ -391,6 +596,18 @@ def test_localpref_attribute(request): } ] } + }, + "ipv6": { + "unicast": { + "advertise_networks": [ + { + "network": "200:50:2::/128" + }, + { + "network": "200:60:2::/128" + } + ] + } } } } @@ -408,6 +625,17 @@ def test_localpref_attribute(request): } } } + }, + "ipv6": { + "unicast": { + "neighbor": { + "r1": { + "dest_link": { + "r2": {"next_hop_self": True} + } + } + } + } } } } @@ -425,11 +653,23 @@ def test_localpref_attribute(request): } } } + }, + "ipv6": { + "unicast": { + "neighbor": { + "r1": { + "dest_link": { + "r3": {"next_hop_self": True} + } + } + } + } } } } } } + result = create_router_bgp(tgen, topo, input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) @@ -439,12 +679,20 @@ def test_localpref_attribute(request): "r2": { "prefix_lists": { "ipv4": { - "pf_ls_1": [{ + "pf_ls_1_ipv4": [{ "seqid": 10, "network": "200.0.0.0/8", "le": "32", "action": "permit" }] + }, + "ipv6": { + "pf_ls_1_ipv6": [{ + "seqid": 10, + "network": "200::/8", + "le": "128", + "action": "permit" + }] } } } @@ -459,13 +707,26 @@ def test_localpref_attribute(request): "route_maps": { "RMAP_LOCAL_PREF": [{ "action": "permit", + "seq_id": "10", "match": { "ipv4": { - "prefix_lists": "pf_ls_1" + "prefix_lists": "pf_ls_1_ipv4" + } + }, + "set": { + "localpref": 1111 + } + }, + { + "action": "permit", + "seq_id": "20", + "match": { + "ipv6": { + "prefix_lists": "pf_ls_1_ipv6" } }, "set": { - "localpref": 1000 + "localpref": 1111 } }] } @@ -483,9 +744,25 @@ def test_localpref_attribute(request): "ipv4": { "unicast": { "neighbor": { - "r1": { + "r4": { + "dest_link": { + "r2-link1": { + "route_maps": [ + {"name": "RMAP_LOCAL_PREF", + "direction": "in"} + ] + } + } + } + } + } + }, + "ipv6": { + "unicast": { + "neighbor": { + "r4": { "dest_link": { - "r2": { + "r2-link1": { "route_maps": [ {"name": "RMAP_LOCAL_PREF", "direction": "in"} @@ -500,7 +777,6 @@ def test_localpref_attribute(request): } } } - result = create_router_bgp(tgen, topo, input_dict_4) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) @@ -508,16 +784,66 @@ def test_localpref_attribute(request): # Verifying best path dut = "r1" attribute = "localpref" - result = verify_best_path_as_per_bgp_attribute(tgen, "ipv4", dut, - input_dict, attribute) + for addr_type in ADDR_TYPES: + result = verify_best_path_as_per_bgp_attribute(tgen, addr_type, dut, + {"r7": input_dict["r7"]}, + attribute) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result) + + # Modify route map + input_dict_3 = { + "r2": { + "route_maps": { + "RMAP_LOCAL_PREF": [{ + "action": "permit", + "seq_id": "10", + "match": { + "ipv4": { + "prefix_lists": "pf_ls_1_ipv4" + } + }, + "set": { + "localpref": 50 + } + }, + { + "action": "permit", + "seq_id": "20", + "match": { + "ipv6": { + "prefix_lists": "pf_ls_1_ipv6" + } + }, + "set": { + "localpref": 50 + } + }] + } + } + } + result = create_route_maps(tgen, input_dict_3) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) + # Verifying best path + dut = "r1" + attribute = "localpref" + for addr_type in ADDR_TYPES: + result = verify_best_path_as_per_bgp_attribute(tgen, addr_type, dut, + {"r7": input_dict["r7"]}, + attribute) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result) + write_test_footer(tc_name) def test_weight_attribute(request): - " Verifying WEIGHT attribute functionality" + """ + Test configure/modify weight attribute and + verify best path is installed as per highest weight + """ tgen = get_topogen() @@ -548,6 +874,18 @@ def test_weight_attribute(request): } ] } + }, + "ipv6": { + "unicast": { + "advertise_networks": [ + { + "network": "200:50:2::/128" + }, + { + "network": "200:60:2::/128" + } + ] + } } } } @@ -565,6 +903,17 @@ def test_weight_attribute(request): } } } + }, + "ipv6": { + "unicast": { + "neighbor": { + "r1": { + "dest_link": { + "r2": {"next_hop_self": True} + } + } + } + } } } } @@ -582,6 +931,17 @@ def test_weight_attribute(request): } } } + }, + "ipv6": { + "unicast": { + "neighbor": { + "r1": { + "dest_link": { + "r3": {"next_hop_self": True} + } + } + } + } } } } @@ -596,12 +956,20 @@ def test_weight_attribute(request): "r1": { "prefix_lists": { "ipv4": { - "pf_ls_1": [{ + "pf_ls_1_ipv4": [{ "seqid": 10, "network": "200.0.0.0/8", "le": "32", "action": "permit" }] + }, + "ipv6": { + "pf_ls_1_ipv6": [{ + "seqid": 10, + "network": "200::/8", + "le": "128", + "action": "permit" + }] } } } @@ -616,9 +984,22 @@ def test_weight_attribute(request): "route_maps": { "RMAP_WEIGHT": [{ "action": "permit", + "seq_id": "5", "match": { "ipv4": { - "prefix_lists": "pf_ls_1" + "prefix_lists": "pf_ls_1_ipv4" + } + }, + "set": { + "weight": 500 + } + }, + { + "action": "permit", + "seq_id": "10", + "match": { + "ipv6": { + "prefix_lists": "pf_ls_1_ipv6" } }, "set": { @@ -652,6 +1033,22 @@ def test_weight_attribute(request): } } } + }, + "ipv6": { + "unicast": { + "neighbor": { + "r2": { + "dest_link": { + "r1": { + "route_maps": [ + {"name": "RMAP_WEIGHT", + "direction": "in"} + ] + } + } + } + } + } } } } @@ -664,16 +1061,66 @@ def test_weight_attribute(request): # Verifying best path dut = "r1" attribute = "weight" - result = verify_best_path_as_per_bgp_attribute(tgen, "ipv4", dut, - input_dict, attribute) + for addr_type in ADDR_TYPES: + result = verify_best_path_as_per_bgp_attribute(tgen, addr_type, dut, + {"r7": input_dict["r7"]}, + attribute) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result) + + # Modify route map + input_dict_3 = { + "r1": { + "route_maps": { + "RMAP_WEIGHT": [{ + "action": "permit", + "seq_id": "5", + "match": { + "ipv4": { + "prefix_lists": "pf_ls_1_ipv4" + } + }, + "set": { + "weight": 1000 + } + }, + { + "action": "permit", + "seq_id": "10", + "match": { + "ipv6": { + "prefix_lists": "pf_ls_1_ipv6" + } + }, + "set": { + "weight": 1000 + } + }] + } + } + } + result = create_route_maps(tgen, input_dict_3) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) + # Verifying best path + dut = "r1" + attribute = "weight" + for addr_type in ADDR_TYPES: + result = verify_best_path_as_per_bgp_attribute(tgen, addr_type, dut, + {"r7": input_dict["r7"]}, + attribute) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result) + write_test_footer(tc_name) def test_origin_attribute(request): - " Verifying ORIGIN attribute functionality" + """ + Test origin attribute and verify best path is + installed as per IGP>EGP>INCOMPLETE rule + """ tgen = get_topogen() @@ -704,6 +1151,18 @@ def test_origin_attribute(request): } ] } + }, + "ipv6": { + "unicast": { + "advertise_networks": [ + { + "network": "200:50:2::/128" + }, + { + "network": "200:60:2::/128" + } + ] + } } } } @@ -721,6 +1180,17 @@ def test_origin_attribute(request): } } } + }, + "ipv6": { + "unicast": { + "neighbor": { + "r1": { + "dest_link": { + "r2": {"next_hop_self": True} + } + } + } + } } } } @@ -738,6 +1208,17 @@ def test_origin_attribute(request): } } } + }, + "ipv6": { + "unicast": { + "neighbor": { + "r1": { + "dest_link": { + "r3": {"next_hop_self": True} + } + } + } + } } } } @@ -752,6 +1233,14 @@ def test_origin_attribute(request): {"redist_type": "connected"} ] } + }, + "ipv6": { + "unicast": { + "redistribute": [ + {"redist_type": "static"}, + {"redist_type": "connected"} + ] + } } } } @@ -767,11 +1256,19 @@ def test_origin_attribute(request): "static_routes": [ { "network": "200.50.2.0/32", - "next_hop": "10.0.0.26" + "next_hop": "Null0" }, { "network": "200.60.2.0/32", - "next_hop": "10.0.0.26" + "next_hop": "Null0" + }, + { + "network": "200:50:2::/128", + "next_hop": "Null0" + }, + { + "network": "200:60:2::/128", + "next_hop": "Null0" } ] } @@ -780,23 +1277,24 @@ def test_origin_attribute(request): assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) - # Api call to redistribute static routes - - # Configure next-hop-self to bgp neighbor - # Verifying best path dut = "r1" attribute = "origin" - result = verify_best_path_as_per_bgp_attribute(tgen, "ipv4", dut, - input_dict, attribute) - assert result is True, "Testcase {} : Failed \n Error: {}".format( - tc_name, result) + for addr_type in ADDR_TYPES: + result = verify_best_path_as_per_bgp_attribute(tgen, addr_type, dut, + {"r4": input_dict["r4"]}, + attribute) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result) write_test_footer(tc_name) def test_med_attribute(request): - " Verifying MED attribute functionality" + """ + Test configure/modify MED attribute and verify best path + is installed as per lowest med value + """ tgen = get_topogen() @@ -814,7 +1312,7 @@ def test_med_attribute(request): # Api call to advertise networks input_dict = { "r4": { - "bgp":{ + "bgp": { "address_family": { "ipv4": { "unicast": { @@ -827,49 +1325,102 @@ def test_med_attribute(request): } ] } + }, + "ipv6": { + "unicast": { + "advertise_networks": [ + { + "network": "200:50:2::/128" + }, + { + "network": "200:60:2::/128" + } + ] + } + } + } + } + }, + "r5": { + "bgp": { + "address_family": { + "ipv4": { + "unicast": { + "advertise_networks": [ + { + "network": "200.50.2.0/32" + }, + { + "network": "200.60.2.0/32" + } + ] + } + }, + "ipv6": { + "unicast": { + "advertise_networks": [ + { + "network": "200:50:2::/128" + }, + { + "network": "200:60:2::/128" + } + ] + } } } } } } + result = create_router_bgp(tgen, topo, input_dict) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) - # Api call to advertise networks - - - # Configure next-hop-self to bgp neighbor - - # Create Prefix list - input_dict_3 = { + input_dict_2 = { "r2": { "prefix_lists": { "ipv4": { - "pf_ls_r2": [{ + "pf_ls_r2_ipv4": [{ "seqid": 10, "network": "200.0.0.0/8", "le": "32", "action": "permit" }] + }, + "ipv6": { + "pf_ls_r2_ipv6": [{ + "seqid": 20, + "network": "200::/8", + "le": "128", + "action": "permit" + }] } } }, "r3": { "prefix_lists": { "ipv4": { - "pf_ls_r3": [{ + "pf_ls_r3_ipv4": [{ "seqid": 10, "network": "200.0.0.0/8", "le": "32", "action": "permit" }] + }, + "ipv6": { + "pf_ls_r3_ipv6": [{ + "seqid": 20, + "network": "200::/8", + "le": "128", + "action": "permit" + }] } } } } - result = create_prefix_lists(tgen, input_dict_3) + result = create_prefix_lists(tgen, input_dict_2) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) @@ -879,9 +1430,22 @@ def test_med_attribute(request): "route_maps": { "RMAP_MED_R2": [{ "action": "permit", + "seq_id": "10", "match": { "ipv4": { - "prefix_lists": "pf_ls_r2" + "prefix_lists": "pf_ls_r2_ipv4" + } + }, + "set": { + "med": 100 + } + }, + { + "action": "permit", + "seq_id": "20", + "match": { + "ipv6": { + "prefix_lists": "pf_ls_r2_ipv6" } }, "set": { @@ -894,9 +1458,22 @@ def test_med_attribute(request): "route_maps": { "RMAP_MED_R3": [{ "action": "permit", + "seq_id": "10", "match": { "ipv4": { - "prefix_lists": "pf_ls_r3" + "prefix_lists": "pf_ls_r3_ipv4" + } + }, + "set": { + "med": 10 + } + }, + { + "action": "permit", + "seq_id": "20", + "match": { + "ipv6": { + "prefix_lists": "pf_ls_r3_ipv6" } }, "set": { @@ -912,28 +1489,31 @@ def test_med_attribute(request): # Configure neighbor for route map input_dict_4 = { - "r5": { + "r2": { "bgp": { "address_family": { "ipv4": { "unicast": { - "advertise_networks": [ - { - "network": "200.50.2.0/32" + "neighbor": { + "r4": { + "dest_link": { + "r2-link1": { + "route_maps": [ + {"name": "RMAP_MED_R2", + "direction": "in"} + ] + } + } }, - { - "network": "200.60.2.0/32" + "r1": { + "dest_link": { + "r2": {"next_hop_self": True} + } } - ] + } } - } - } - } - }, - "r2": { - "bgp": { - "address_family": { - "ipv4": { + }, + "ipv6": { "unicast": { "neighbor": { "r4": { @@ -980,11 +1560,33 @@ def test_med_attribute(request): } } } + }, + "ipv6": { + "unicast": { + "neighbor": { + "r1": { + "dest_link": { + "r3": {"next_hop_self": True} + } + }, + "r5": { + "dest_link": { + "r3": { + "route_maps": [ + {"name": "RMAP_MED_R3", + "direction": "in"} + ] + } + } + } + } + } } } } } } + result = create_router_bgp(tgen, topo, input_dict_4) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) @@ -992,12 +1594,58 @@ def test_med_attribute(request): # Verifying best path dut = "r1" attribute = "med" - result = verify_best_path_as_per_bgp_attribute(tgen, "ipv4", dut, + for addr_type in ADDR_TYPES: + result = verify_best_path_as_per_bgp_attribute(tgen, addr_type, dut, input_dict, attribute) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result) + + # Modify route-map to set med value + input_dict_3 = { + "r3": { + "route_maps": { + "RMAP_MED_R3": [{ + "action": "permit", + "seq_id": "10", + "match": { + "ipv4": { + "prefix_lists": "pf_ls_r3_ipv4" + } + }, + "set": { + "med": 200 + } + }, + { + "action": "permit", + "seq_id": "20", + "match": { + "ipv6": { + "prefix_lists": "pf_ls_r3_ipv6" + } + }, + "set": { + "med": 200 + } + }] + } + } + } + + result = create_route_maps(tgen, input_dict_3) assert result is True, "Testcase {} : Failed \n Error: {}".format( tc_name, result) - logger.info("Testcase %s :Passed \n", tc_name) + # Verifying best path + dut = "r1" + attribute = "med" + for addr_type in ADDR_TYPES: + result = verify_best_path_as_per_bgp_attribute(tgen, addr_type, dut, + input_dict, attribute) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result) + + write_test_footer(tc_name) # Uncomment next line for debugging # tgen.mininet_cli() @@ -1032,6 +1680,16 @@ def test_admin_distance(request): "network": "200.50.2.0/32", "admin_distance": 60, "next_hop": "10.0.0.18" + }, + { + "network": "200:50:2::/128", + "admin_distance": 80, + "next_hop": "fd00::1" + }, + { + "network": "200:50:2::/128", + "admin_distance": 60, + "next_hop": "fd00::1" } ] } @@ -1052,6 +1710,14 @@ def test_admin_distance(request): {"redist_type": "connected"} ] } + }, + "ipv6": { + "unicast": { + "redistribute": [ + {"redist_type": "static"}, + {"redist_type": "connected"} + ] + } } } } @@ -1064,10 +1730,45 @@ def test_admin_distance(request): # Verifying best path dut = "r1" attribute = "admin_distance" - result = verify_best_path_as_per_admin_distance(tgen, "ipv4", dut, - input_dict, attribute) - assert result is True, "Testcase {} : Failed \n Error: {}".format( - tc_name, result) + + input_dict = { + "ipv4": { + "r2": { + "static_routes": [{ + "network": "200.50.2.0/32", + "admin_distance": 80, + "next_hop": "10.0.0.14" + }, + { + "network": "200.50.2.0/32", + "admin_distance": 60, + "next_hop": "10.0.0.18" + } + ] + } + }, + "ipv6": { + "r2": { + "static_routes": [{ + "network": "200:50:2::/128", + "admin_distance": 80, + "next_hop": "fd00::1" + }, + { + "network": "200:50:2::/128", + "admin_distance": 60, + "next_hop": "fd00::1" + }] + } + } + } + + for addr_type in ADDR_TYPES: + result = verify_best_path_as_per_admin_distance(tgen, addr_type, dut, + input_dict[addr_type], + attribute) + assert result is True, "Testcase {} : Failed \n Error: {}".format( + tc_name, result) write_test_footer(tc_name) |