summaryrefslogtreecommitdiff
path: root/tests/topotests/bgp-path-attributes-topo1/test_bgp_path_attributes.py
diff options
context:
space:
mode:
authorreformat <reformat@nobody.nobody>2020-04-03 14:05:24 +0300
committerDonatas Abraitis <donatas.abraitis@gmail.com>2020-04-03 19:41:28 +0300
commit787e762445d50ca5b52fafcf8dd6de08ab90916f (patch)
treeafaad3d41a83da180d5fc8bbc7b23d02da7c4dbd /tests/topotests/bgp-path-attributes-topo1/test_bgp_path_attributes.py
parentcd05906c41aaaf94e06fa9d14a7634bdffd99ed0 (diff)
tests: Run python formatter (black) for topotests
Mostly ' => ", whitespace changes. Using https://github.com/psf/black Signed-off-by: reformat <reformat@nobody.nobody>
Diffstat (limited to 'tests/topotests/bgp-path-attributes-topo1/test_bgp_path_attributes.py')
-rwxr-xr-xtests/topotests/bgp-path-attributes-topo1/test_bgp_path_attributes.py1120
1 files changed, 455 insertions, 665 deletions
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 1cd2c4417f..b0ff3ac437 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
@@ -72,18 +72,26 @@ from lib.topogen import Topogen, TopoRouter, get_topogen
# Required to instantiate the topology builder class.
from lib.common_config import (
- start_topology, write_test_header,
- write_test_footer, reset_config_on_routers,
- verify_rib, create_static_routes,
- create_prefix_lists, verify_prefix_lists,
- create_route_maps, check_address_types
+ start_topology,
+ write_test_header,
+ write_test_footer,
+ reset_config_on_routers,
+ verify_rib,
+ create_static_routes,
+ create_prefix_lists,
+ verify_prefix_lists,
+ 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, modify_as_number,
- verify_as_numbers
+ verify_bgp_convergence,
+ create_router_bgp,
+ clear_bgp_and_verify,
+ verify_best_path_as_per_bgp_attribute,
+ 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
@@ -147,8 +155,7 @@ def setup_module(mod):
# Checking BGP convergence
result = verify_bgp_convergence(tgen, topo)
- assert result is True, ("setup_module :Failed \n Error:"
- " {}".format(result))
+ assert result is True, "setup_module :Failed \n Error:" " {}".format(result)
logger.info("Running setup_module() done")
@@ -165,8 +172,7 @@ def teardown_module():
# Stop toplogy and Remove tmp files
tgen.stop_topology()
- logger.info("Testsuite end time: %s",
- time.asctime(time.localtime(time.time())))
+ logger.info("Testsuite end time: %s", time.asctime(time.localtime(time.time())))
logger.info("=" * 40)
@@ -176,6 +182,7 @@ def teardown_module():
##
#####################################################
+
def test_next_hop_attribute(request):
"""
Verifying route are not getting installed in, as next_hop is
@@ -204,44 +211,38 @@ def test_next_hop_attribute(request):
"ipv4": {
"unicast": {
"advertise_networks": [
- {
- "network": "200.50.2.0/32"
- },
- {
- "network": "200.60.2.0/32"
- }
+ {"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"
- }
+ {"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)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
# Verifying RIB routes
dut = "r1"
protocol = "bgp"
# 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: "\
+ 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 = {
@@ -251,25 +252,17 @@ def test_next_hop_attribute(request):
"ipv4": {
"unicast": {
"neighbor": {
- "r1": {
- "dest_link": {
- "r2": {"next_hop_self": True}
- }
- }
+ "r1": {"dest_link": {"r2": {"next_hop_self": True}}}
}
}
},
"ipv6": {
"unicast": {
"neighbor": {
- "r1": {
- "dest_link": {
- "r2": {"next_hop_self": True}
- }
- }
+ "r1": {"dest_link": {"r2": {"next_hop_self": True}}}
}
}
- }
+ },
}
}
},
@@ -279,42 +272,33 @@ def test_next_hop_attribute(request):
"ipv4": {
"unicast": {
"neighbor": {
- "r1": {
- "dest_link": {
- "r3": {"next_hop_self": True}
- }
- }
+ "r1": {"dest_link": {"r3": {"next_hop_self": True}}}
}
}
},
"ipv6": {
"unicast": {
"neighbor": {
- "r1": {
- "dest_link": {
- "r3": {"next_hop_self": True}
- }
- }
+ "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)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
# Verifying RIB routes
dut = "r1"
protocol = "bgp"
for addr_type in ADDR_TYPES:
- result = verify_rib(tgen, addr_type, dut, input_dict,
- protocol=protocol)
+ result = verify_rib(tgen, addr_type, dut, input_dict, protocol=protocol)
assert result is True, "Testcase {} : Failed \n Error: {}".format(
- tc_name, result)
+ tc_name, result
+ )
write_test_footer(tc_name)
@@ -343,27 +327,19 @@ def test_aspath_attribute(request):
"ipv4": {
"unicast": {
"advertise_networks": [
- {
- "network": "200.50.2.0/32"
- },
- {
- "network": "200.60.2.0/32"
- }
+ {"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"
- }
+ {"network": "200:50:2::/128"},
+ {"network": "200:60:2::/128"},
]
}
- }
+ },
}
}
},
@@ -373,25 +349,17 @@ def test_aspath_attribute(request):
"ipv4": {
"unicast": {
"neighbor": {
- "r1": {
- "dest_link": {
- "r2": {"next_hop_self": True}
- }
- }
+ "r1": {"dest_link": {"r2": {"next_hop_self": True}}}
}
}
},
"ipv6": {
"unicast": {
"neighbor": {
- "r1": {
- "dest_link": {
- "r2": {"next_hop_self": True}
- }
- }
+ "r1": {"dest_link": {"r2": {"next_hop_self": True}}}
}
}
- }
+ },
}
}
},
@@ -401,42 +369,34 @@ def test_aspath_attribute(request):
"ipv4": {
"unicast": {
"neighbor": {
- "r1": {
- "dest_link": {
- "r3": {"next_hop_self": True}
- }
- }
+ "r1": {"dest_link": {"r3": {"next_hop_self": True}}}
}
}
},
"ipv6": {
"unicast": {
"neighbor": {
- "r1": {
- "dest_link": {
- "r3": {"next_hop_self": True}
- }
- }
+ "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)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
# Verifying best path
dut = "r1"
attribute = "path"
for addr_type in ADDR_TYPES:
- result = verify_best_path_as_per_bgp_attribute(tgen, addr_type, dut,
- {"r7": input_dict["r7"]},
- attribute)
+ 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)
+ tc_name, result
+ )
# Modify AS-Path and verify best path is changed
# Create Prefix list
@@ -445,66 +405,52 @@ def test_aspath_attribute(request):
"r3": {
"prefix_lists": {
"ipv4": {
- "pf_ls_1_ipv4": [{
- "seqid": 10,
- "network": "200.0.0.0/8",
- "le": "32",
- "action": "permit"
- }]
+ "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"
- }]
- }
+ "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)
+ 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"
- }
+ "RMAP_AS_PATH": [
+ {
+ "action": "permit",
+ "match": {"ipv4": {"prefix_lists": "pf_ls_1_ipv4"}},
+ "set": {"path": {"as_num": "111 222", "as_action": "prepend"}},
},
- "set": {
- "path": {
- "as_num": "111 222",
- "as_action": "prepend"
- }
- }
- },
- {
- "action": "permit",
- "match": {
- "ipv6": {
- "prefix_lists": "pf_ls_1_ipv6"
- }
+ {
+ "action": "permit",
+ "match": {"ipv6": {"prefix_lists": "pf_ls_1_ipv6"}},
+ "set": {"path": {"as_num": "111 222", "as_action": "prepend"}},
},
- "set": {
- "path": {
- "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)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
# Configure neighbor for route map
input_dict_4 = {
@@ -518,8 +464,10 @@ def test_aspath_attribute(request):
"dest_link": {
"r3": {
"route_maps": [
- {"name": "RMAP_AS_PATH",
- "direction": "in"}
+ {
+ "name": "RMAP_AS_PATH",
+ "direction": "in",
+ }
]
}
}
@@ -534,32 +482,34 @@ def test_aspath_attribute(request):
"dest_link": {
"r3": {
"route_maps": [
- {"name": "RMAP_AS_PATH",
- "direction": "in"}
+ {
+ "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)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
# Verifying best path
dut = "r1"
attribute = "path"
for addr_type in ADDR_TYPES:
- result = verify_best_path_as_per_bgp_attribute(tgen, addr_type, dut,
- {"r7": input_dict["r7"]},
- attribute)
+ 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)
+ tc_name, result
+ )
write_test_footer(tc_name)
@@ -588,27 +538,19 @@ def test_localpref_attribute(request):
"ipv4": {
"unicast": {
"advertise_networks": [
- {
- "network": "200.50.2.0/32"
- },
- {
- "network": "200.60.2.0/32"
- }
+ {"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"
- }
+ {"network": "200:50:2::/128"},
+ {"network": "200:60:2::/128"},
]
}
- }
+ },
}
}
},
@@ -618,25 +560,17 @@ def test_localpref_attribute(request):
"ipv4": {
"unicast": {
"neighbor": {
- "r1": {
- "dest_link": {
- "r2": {"next_hop_self": True}
- }
- }
+ "r1": {"dest_link": {"r2": {"next_hop_self": True}}}
}
}
},
"ipv6": {
"unicast": {
"neighbor": {
- "r1": {
- "dest_link": {
- "r2": {"next_hop_self": True}
- }
- }
+ "r1": {"dest_link": {"r2": {"next_hop_self": True}}}
}
}
- }
+ },
}
}
},
@@ -646,95 +580,78 @@ def test_localpref_attribute(request):
"ipv4": {
"unicast": {
"neighbor": {
- "r1": {
- "dest_link": {
- "r3": {"next_hop_self": True}
- }
- }
+ "r1": {"dest_link": {"r3": {"next_hop_self": True}}}
}
}
},
"ipv6": {
"unicast": {
"neighbor": {
- "r1": {
- "dest_link": {
- "r3": {"next_hop_self": True}
- }
- }
+ "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)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
# Create Prefix list
input_dict_2 = {
"r2": {
"prefix_lists": {
"ipv4": {
- "pf_ls_1_ipv4": [{
- "seqid": 10,
- "network": "200.0.0.0/8",
- "le": "32",
- "action": "permit"
- }]
+ "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"
- }]
- }
+ "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)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
# Create route map
input_dict_3 = {
"r2": {
"route_maps": {
- "RMAP_LOCAL_PREF": [{
- "action": "permit",
- "seq_id": "10",
- "match": {
- "ipv4": {
- "prefix_lists": "pf_ls_1_ipv4"
- }
+ "RMAP_LOCAL_PREF": [
+ {
+ "action": "permit",
+ "seq_id": "10",
+ "match": {"ipv4": {"prefix_lists": "pf_ls_1_ipv4"}},
+ "set": {"locPrf": 1111},
},
- "set": {
- "locPrf": 1111
- }
- },
- {
- "action": "permit",
- "seq_id": "20",
- "match": {
- "ipv6": {
- "prefix_lists": "pf_ls_1_ipv6"
- }
+ {
+ "action": "permit",
+ "seq_id": "20",
+ "match": {"ipv6": {"prefix_lists": "pf_ls_1_ipv6"}},
+ "set": {"locPrf": 1111},
},
- "set": {
- "locPrf": 1111
- }
- }]
+ ]
}
}
}
result = create_route_maps(tgen, input_dict_3)
- assert result is True, "Testcase {} : Failed \n Error: {}".format(
- tc_name, result)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
# Configure neighbor for route map
input_dict_4 = {
@@ -748,8 +665,10 @@ def test_localpref_attribute(request):
"dest_link": {
"r2-link1": {
"route_maps": [
- {"name": "RMAP_LOCAL_PREF",
- "direction": "in"}
+ {
+ "name": "RMAP_LOCAL_PREF",
+ "direction": "in",
+ }
]
}
}
@@ -764,77 +683,69 @@ def test_localpref_attribute(request):
"dest_link": {
"r2-link1": {
"route_maps": [
- {"name": "RMAP_LOCAL_PREF",
- "direction": "in"}
+ {
+ "name": "RMAP_LOCAL_PREF",
+ "direction": "in",
+ }
]
}
}
}
}
}
- }
+ },
}
}
}
}
result = create_router_bgp(tgen, topo, input_dict_4)
- assert result is True, "Testcase {} : Failed \n Error: {}".format(
- tc_name, result)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
# Verifying best path
dut = "r1"
attribute = "locPrf"
for addr_type in ADDR_TYPES:
- result = verify_best_path_as_per_bgp_attribute(tgen, addr_type, dut,
- {"r7": input_dict["r7"]},
- attribute)
+ 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)
+ 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"
- }
+ "RMAP_LOCAL_PREF": [
+ {
+ "action": "permit",
+ "seq_id": "10",
+ "match": {"ipv4": {"prefix_lists": "pf_ls_1_ipv4"}},
+ "set": {"locPrf": 50},
},
- "set": {
- "locPrf": 50
- }
- },
- {
- "action": "permit",
- "seq_id": "20",
- "match": {
- "ipv6": {
- "prefix_lists": "pf_ls_1_ipv6"
- }
+ {
+ "action": "permit",
+ "seq_id": "20",
+ "match": {"ipv6": {"prefix_lists": "pf_ls_1_ipv6"}},
+ "set": {"locPrf": 50},
},
- "set": {
- "locPrf": 50
- }
- }]
+ ]
}
}
}
result = create_route_maps(tgen, input_dict_3)
- assert result is True, "Testcase {} : Failed \n Error: {}".format(
- tc_name, result)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
# Verifying best path
dut = "r1"
attribute = "locPrf"
for addr_type in ADDR_TYPES:
- result = verify_best_path_as_per_bgp_attribute(tgen, addr_type, dut,
- {"r7": input_dict["r7"]},
- attribute)
+ 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)
+ tc_name, result
+ )
write_test_footer(tc_name)
@@ -866,27 +777,19 @@ def test_weight_attribute(request):
"ipv4": {
"unicast": {
"advertise_networks": [
- {
- "network": "200.50.2.0/32"
- },
- {
- "network": "200.60.2.0/32"
- }
+ {"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"
- }
+ {"network": "200:50:2::/128"},
+ {"network": "200:60:2::/128"},
]
}
- }
+ },
}
}
},
@@ -896,25 +799,17 @@ def test_weight_attribute(request):
"ipv4": {
"unicast": {
"neighbor": {
- "r1": {
- "dest_link": {
- "r2": {"next_hop_self": True}
- }
- }
+ "r1": {"dest_link": {"r2": {"next_hop_self": True}}}
}
}
},
"ipv6": {
"unicast": {
"neighbor": {
- "r1": {
- "dest_link": {
- "r2": {"next_hop_self": True}
- }
- }
+ "r1": {"dest_link": {"r2": {"next_hop_self": True}}}
}
}
- }
+ },
}
}
},
@@ -924,94 +819,77 @@ def test_weight_attribute(request):
"ipv4": {
"unicast": {
"neighbor": {
- "r1": {
- "dest_link": {
- "r3": {"next_hop_self": True}
- }
- }
+ "r1": {"dest_link": {"r3": {"next_hop_self": True}}}
}
}
},
"ipv6": {
"unicast": {
"neighbor": {
- "r1": {
- "dest_link": {
- "r3": {"next_hop_self": True}
- }
- }
+ "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)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
# Create Prefix list
input_dict_2 = {
"r1": {
"prefix_lists": {
"ipv4": {
- "pf_ls_1_ipv4": [{
- "seqid": 10,
- "network": "200.0.0.0/8",
- "le": "32",
- "action": "permit"
- }]
+ "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"
- }]
- }
+ "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)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
# Create route map
input_dict_3 = {
"r1": {
"route_maps": {
- "RMAP_WEIGHT": [{
- "action": "permit",
- "seq_id": "5",
- "match": {
- "ipv4": {
- "prefix_lists": "pf_ls_1_ipv4"
- }
+ "RMAP_WEIGHT": [
+ {
+ "action": "permit",
+ "seq_id": "5",
+ "match": {"ipv4": {"prefix_lists": "pf_ls_1_ipv4"}},
+ "set": {"weight": 500},
},
- "set": {
- "weight": 500
- }
- },
- {
- "action": "permit",
- "seq_id": "10",
- "match": {
- "ipv6": {
- "prefix_lists": "pf_ls_1_ipv6"
- }
+ {
+ "action": "permit",
+ "seq_id": "10",
+ "match": {"ipv6": {"prefix_lists": "pf_ls_1_ipv6"}},
+ "set": {"weight": 500},
},
- "set": {
- "weight": 500
- }
- }]
+ ]
}
}
}
result = create_route_maps(tgen, input_dict_3)
- assert result is True, "Testcase {} : Failed \n Error: {}".format(
- tc_name, result)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
# Configure neighbor for route map
input_dict_4 = {
@@ -1025,8 +903,10 @@ def test_weight_attribute(request):
"dest_link": {
"r1": {
"route_maps": [
- {"name": "RMAP_WEIGHT",
- "direction": "in"}
+ {
+ "name": "RMAP_WEIGHT",
+ "direction": "in",
+ }
]
}
}
@@ -1041,77 +921,69 @@ def test_weight_attribute(request):
"dest_link": {
"r1": {
"route_maps": [
- {"name": "RMAP_WEIGHT",
- "direction": "in"}
+ {
+ "name": "RMAP_WEIGHT",
+ "direction": "in",
+ }
]
}
}
}
}
}
- }
+ },
}
}
}
}
result = create_router_bgp(tgen, topo, input_dict_4)
- assert result is True, "Testcase {} : Failed \n Error: {}".format(
- tc_name, result)
+ 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)
+ 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)
+ 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"
- }
+ "RMAP_WEIGHT": [
+ {
+ "action": "permit",
+ "seq_id": "5",
+ "match": {"ipv4": {"prefix_lists": "pf_ls_1_ipv4"}},
+ "set": {"weight": 1000},
},
- "set": {
- "weight": 1000
- }
- },
- {
- "action": "permit",
- "seq_id": "10",
- "match": {
- "ipv6": {
- "prefix_lists": "pf_ls_1_ipv6"
- }
+ {
+ "action": "permit",
+ "seq_id": "10",
+ "match": {"ipv6": {"prefix_lists": "pf_ls_1_ipv6"}},
+ "set": {"weight": 1000},
},
- "set": {
- "weight": 1000
- }
- }]
+ ]
}
}
}
result = create_route_maps(tgen, input_dict_3)
- assert result is True, "Testcase {} : Failed \n Error: {}".format(
- tc_name, result)
+ 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)
+ 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)
+ tc_name, result
+ )
write_test_footer(tc_name)
@@ -1143,27 +1015,19 @@ def test_origin_attribute(request):
"ipv4": {
"unicast": {
"advertise_networks": [
- {
- "network": "200.50.2.0/32"
- },
- {
- "network": "200.60.2.0/32"
- }
+ {"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"
- }
+ {"network": "200:50:2::/128"},
+ {"network": "200:60:2::/128"},
]
}
- }
+ },
}
}
},
@@ -1173,25 +1037,17 @@ def test_origin_attribute(request):
"ipv4": {
"unicast": {
"neighbor": {
- "r1": {
- "dest_link": {
- "r2": {"next_hop_self": True}
- }
- }
+ "r1": {"dest_link": {"r2": {"next_hop_self": True}}}
}
}
},
"ipv6": {
"unicast": {
"neighbor": {
- "r1": {
- "dest_link": {
- "r2": {"next_hop_self": True}
- }
- }
+ "r1": {"dest_link": {"r2": {"next_hop_self": True}}}
}
}
- }
+ },
}
}
},
@@ -1201,25 +1057,17 @@ def test_origin_attribute(request):
"ipv4": {
"unicast": {
"neighbor": {
- "r1": {
- "dest_link": {
- "r3": {"next_hop_self": True}
- }
- }
+ "r1": {"dest_link": {"r3": {"next_hop_self": True}}}
}
}
},
"ipv6": {
"unicast": {
"neighbor": {
- "r1": {
- "dest_link": {
- "r3": {"next_hop_self": True}
- }
- }
+ "r1": {"dest_link": {"r3": {"next_hop_self": True}}}
}
}
- }
+ },
}
}
},
@@ -1230,7 +1078,7 @@ def test_origin_attribute(request):
"unicast": {
"redistribute": [
{"redist_type": "static"},
- {"redist_type": "connected"}
+ {"redist_type": "connected"},
]
}
},
@@ -1238,54 +1086,41 @@ def test_origin_attribute(request):
"unicast": {
"redistribute": [
{"redist_type": "static"},
- {"redist_type": "connected"}
+ {"redist_type": "connected"},
]
}
- }
+ },
}
}
- }
+ },
}
result = create_router_bgp(tgen, topo, input_dict)
- assert result is True, "Testcase {} : Failed \n Error: {}".format(
- tc_name, result)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
# Api call to create static routes
input_dict_3 = {
"r5": {
"static_routes": [
- {
- "network": "200.50.2.0/32",
- "next_hop": "Null0"
- },
- {
- "network": "200.60.2.0/32",
- "next_hop": "Null0"
- },
- {
- "network": "200:50:2::/128",
- "next_hop": "Null0"
- },
- {
- "network": "200:60:2::/128",
- "next_hop": "Null0"
- }
+ {"network": "200.50.2.0/32", "next_hop": "Null0"},
+ {"network": "200.60.2.0/32", "next_hop": "Null0"},
+ {"network": "200:50:2::/128", "next_hop": "Null0"},
+ {"network": "200:60:2::/128", "next_hop": "Null0"},
]
}
}
result = create_static_routes(tgen, input_dict_3)
- assert result is True, "Testcase {} : Failed \n Error: {}".format(
- tc_name, result)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
# Verifying best path
dut = "r1"
attribute = "origin"
for addr_type in ADDR_TYPES:
- result = verify_best_path_as_per_bgp_attribute(tgen, addr_type, dut,
- {"r4": input_dict["r4"]},
- attribute)
+ 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)
+ tc_name, result
+ )
write_test_footer(tc_name)
@@ -1317,27 +1152,19 @@ def test_med_attribute(request):
"ipv4": {
"unicast": {
"advertise_networks": [
- {
- "network": "200.50.2.0/32"
- },
- {
- "network": "200.60.2.0/32"
- }
+ {"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"
- }
+ {"network": "200:50:2::/128"},
+ {"network": "200:60:2::/128"},
]
}
- }
+ },
}
}
},
@@ -1347,145 +1174,122 @@ def test_med_attribute(request):
"ipv4": {
"unicast": {
"advertise_networks": [
- {
- "network": "200.50.2.0/32"
- },
- {
- "network": "200.60.2.0/32"
- }
+ {"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"
- }
+ {"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)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
# Create Prefix list
input_dict_2 = {
"r2": {
"prefix_lists": {
"ipv4": {
- "pf_ls_r2_ipv4": [{
- "seqid": 10,
- "network": "200.0.0.0/8",
- "le": "32",
- "action": "permit"
- }]
+ "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"
- }]
- }
+ "pf_ls_r2_ipv6": [
+ {
+ "seqid": 20,
+ "network": "200::/8",
+ "le": "128",
+ "action": "permit",
+ }
+ ]
+ },
}
},
"r3": {
"prefix_lists": {
"ipv4": {
- "pf_ls_r3_ipv4": [{
- "seqid": 10,
- "network": "200.0.0.0/8",
- "le": "32",
- "action": "permit"
- }]
+ "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"
- }]
- }
+ "pf_ls_r3_ipv6": [
+ {
+ "seqid": 20,
+ "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)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
# Create route map
input_dict_3 = {
"r2": {
"route_maps": {
- "RMAP_MED_R2": [{
- "action": "permit",
- "seq_id": "10",
- "match": {
- "ipv4": {
- "prefix_lists": "pf_ls_r2_ipv4"
- }
+ "RMAP_MED_R2": [
+ {
+ "action": "permit",
+ "seq_id": "10",
+ "match": {"ipv4": {"prefix_lists": "pf_ls_r2_ipv4"}},
+ "set": {"metric": 100},
},
- "set": {
- "metric": 100
- }
- },
- {
- "action": "permit",
- "seq_id": "20",
- "match": {
- "ipv6": {
- "prefix_lists": "pf_ls_r2_ipv6"
- }
+ {
+ "action": "permit",
+ "seq_id": "20",
+ "match": {"ipv6": {"prefix_lists": "pf_ls_r2_ipv6"}},
+ "set": {"metric": 100},
},
- "set": {
- "metric": 100
- }
- }]
+ ]
}
},
"r3": {
"route_maps": {
- "RMAP_MED_R3": [{
- "action": "permit",
- "seq_id": "10",
- "match": {
- "ipv4": {
- "prefix_lists": "pf_ls_r3_ipv4"
- }
+ "RMAP_MED_R3": [
+ {
+ "action": "permit",
+ "seq_id": "10",
+ "match": {"ipv4": {"prefix_lists": "pf_ls_r3_ipv4"}},
+ "set": {"metric": 10},
},
- "set": {
- "metric": 10
- }
- },
- {
- "action": "permit",
- "seq_id": "20",
- "match": {
- "ipv6": {
- "prefix_lists": "pf_ls_r3_ipv6"
- }
+ {
+ "action": "permit",
+ "seq_id": "20",
+ "match": {"ipv6": {"prefix_lists": "pf_ls_r3_ipv6"}},
+ "set": {"metric": 10},
},
- "set": {
- "metric": 10
- }
- }]
+ ]
}
- }
+ },
}
result = create_route_maps(tgen, input_dict_3)
- assert result is True, "Testcase {} : Failed \n Error: {}".format(
- tc_name, result)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
# Configure neighbor for route map
input_dict_4 = {
@@ -1499,17 +1303,15 @@ def test_med_attribute(request):
"dest_link": {
"r2-link1": {
"route_maps": [
- {"name": "RMAP_MED_R2",
- "direction": "in"}
+ {
+ "name": "RMAP_MED_R2",
+ "direction": "in",
+ }
]
}
}
},
- "r1": {
- "dest_link": {
- "r2": {"next_hop_self": True}
- }
- }
+ "r1": {"dest_link": {"r2": {"next_hop_self": True}}},
}
}
},
@@ -1520,20 +1322,18 @@ def test_med_attribute(request):
"dest_link": {
"r2-link1": {
"route_maps": [
- {"name": "RMAP_MED_R2",
- "direction": "in"}
+ {
+ "name": "RMAP_MED_R2",
+ "direction": "in",
+ }
]
}
}
},
- "r1": {
- "dest_link": {
- "r2": {"next_hop_self": True}
- }
- }
+ "r1": {"dest_link": {"r2": {"next_hop_self": True}}},
}
}
- }
+ },
}
}
},
@@ -1543,107 +1343,95 @@ def test_med_attribute(request):
"ipv4": {
"unicast": {
"neighbor": {
- "r1": {
- "dest_link": {
- "r3": {"next_hop_self": True}
- }
- },
+ "r1": {"dest_link": {"r3": {"next_hop_self": True}}},
"r5": {
"dest_link": {
"r3": {
"route_maps": [
- {"name": "RMAP_MED_R3",
- "direction": "in"}
+ {
+ "name": "RMAP_MED_R3",
+ "direction": "in",
+ }
]
}
}
- }
+ },
}
}
},
"ipv6": {
"unicast": {
"neighbor": {
- "r1": {
- "dest_link": {
- "r3": {"next_hop_self": True}
- }
- },
+ "r1": {"dest_link": {"r3": {"next_hop_self": True}}},
"r5": {
"dest_link": {
"r3": {
"route_maps": [
- {"name": "RMAP_MED_R3",
- "direction": "in"}
+ {
+ "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)
+ 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 = "metric"
for addr_type in ADDR_TYPES:
- result = verify_best_path_as_per_bgp_attribute(tgen, addr_type, dut,
- input_dict, attribute)
+ 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)
+ 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"
- }
+ "RMAP_MED_R3": [
+ {
+ "action": "permit",
+ "seq_id": "10",
+ "match": {"ipv4": {"prefix_lists": "pf_ls_r3_ipv4"}},
+ "set": {"metric": 200},
},
- "set": {
- "metric": 200
- }
- },
- {
- "action": "permit",
- "seq_id": "20",
- "match": {
- "ipv6": {
- "prefix_lists": "pf_ls_r3_ipv6"
- }
+ {
+ "action": "permit",
+ "seq_id": "20",
+ "match": {"ipv6": {"prefix_lists": "pf_ls_r3_ipv6"}},
+ "set": {"metric": 200},
},
- "set": {
- "metric": 200
- }
- }]
+ ]
}
}
}
result = create_route_maps(tgen, input_dict_3)
- assert result is True, "Testcase {} : Failed \n Error: {}".format(
- tc_name, result)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
# Verifying best path
dut = "r1"
attribute = "metric"
for addr_type in ADDR_TYPES:
- result = verify_best_path_as_per_bgp_attribute(tgen, addr_type, dut,
- input_dict, attribute)
+ 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)
+ tc_name, result
+ )
write_test_footer(tc_name)
@@ -1674,29 +1462,28 @@ def test_admin_distance(request):
{
"network": "200.50.2.0/32",
"admin_distance": 80,
- "next_hop": "10.0.0.14"
+ "next_hop": "10.0.0.14",
},
{
"network": "200.50.2.0/32",
"admin_distance": 60,
- "next_hop": "10.0.0.18"
+ "next_hop": "10.0.0.18",
},
{
"network": "200:50:2::/128",
"admin_distance": 80,
- "next_hop": "fd00::1"
+ "next_hop": "fd00::1",
},
{
"network": "200:50:2::/128",
"admin_distance": 60,
- "next_hop": "fd00::1"
- }
+ "next_hop": "fd00::1",
+ },
]
}
}
result = create_static_routes(tgen, input_dict)
- assert result is True, "Testcase {} : Failed \n Error: {}".format(
- tc_name, result)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
# Api call to redistribute static routes
input_dict_2 = {
@@ -1707,7 +1494,7 @@ def test_admin_distance(request):
"unicast": {
"redistribute": [
{"redist_type": "static"},
- {"redist_type": "connected"}
+ {"redist_type": "connected"},
]
}
},
@@ -1715,60 +1502,63 @@ def test_admin_distance(request):
"unicast": {
"redistribute": [
{"redist_type": "static"},
- {"redist_type": "connected"}
+ {"redist_type": "connected"},
]
}
- }
+ },
}
}
}
}
result = create_router_bgp(tgen, input_dict_2)
- assert result is True, "Testcase {} : Failed \n Error: {}".format(
- tc_name, result)
+ assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
# Verifying best path
dut = "r1"
attribute = "admin_distance"
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"
- }]
+ "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)
+ 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)
+ tc_name, result
+ )
write_test_footer(tc_name)