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
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.
# 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
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,
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)
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")
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]
# 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",
}]
}
}
}
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
"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
],
"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
}
}
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": {
"route_maps": [{
"name":
"rmap_match_pf_1_ipv4",
- "direction": 'in'
+ "direction": "in"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_2_ipv4",
- "direction": 'out'
+ "direction": "out"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_1_ipv6",
- "direction": 'in'
+ "direction": "in"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_2_ipv6",
- "direction": 'out'
+ "direction": "out"
}]
}
}
}
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"]
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"]
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)
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]
# 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
"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)
}],
"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)
}
}
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": {
"route_maps": [{
"name":
"rmap_match_pf_1_ipv4",
- "direction": 'in'
+ "direction": "in"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_2_ipv4",
- "direction": 'out'
+ "direction": "out"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_1_ipv6",
- "direction": 'in'
+ "direction": "in"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_2_ipv6",
- "direction": 'out'
+ "direction": "out"
}]
}
}
}
}
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"]
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"]
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
"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)
}],
"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)
}
}
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"]
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"]
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)
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]
}
}
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)
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]
# 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
"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)
}],
"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)
}
}
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": {
"route_maps": [{
"name":
"rmap_match_pf_1_ipv4",
- "direction": 'in'
+ "direction": "in"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_2_ipv4",
- "direction": 'out'
+ "direction": "out"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_1_ipv6",
- "direction": 'in'
+ "direction": "in"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_2_ipv6",
- "direction": 'out'
+ "direction": "out"
}]
}
}
}
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"]
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"]
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)
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
"""
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]
# 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
"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)
}],
"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)
}
}
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": {
"route_maps": [{
"name":
"rmap_match_pf_1_ipv4",
- "direction": 'in'
+ "direction": "in"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_2_ipv4",
- "direction": 'out'
+ "direction": "out"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_1_ipv6",
- "direction": 'in'
+ "direction": "in"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_2_ipv6",
- "direction": 'out'
+ "direction": "out"
}]
}
}
}
}
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"]
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"]
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)
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]
}
}
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": {
"r1": {
"route_maps": [{
"name": "rm_r1_out_ipv4",
- "direction": 'out'
+ "direction": "out"
}]
}
}
"r1": {
"route_maps": [{
"name": "rm_r1_out_ipv6",
- "direction": 'out'
+ "direction": "out"
}]
}
}
}
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:
}
}
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 = {
}
}
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": {
"r3": {
"route_maps": [{
"name": "rm_r3_in_ipv4",
- "direction": 'in'
+ "direction": "in"
}]
}
}
"r3": {
"route_maps": [{
"name": "rm_r3_in_ipv6",
- "direction": 'in'
+ "direction": "in"
}]
}
}
}
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)
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]
# 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"}
]
}
}
}
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"}
]
}
}
}
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 ={}
"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)
}
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
"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)
}
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": {
"route_maps": [{
"name":
"rmap_match_pf_1_ipv4",
- "direction": 'in'
+ "direction": "in"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_1_ipv6",
- "direction": 'in'
+ "direction": "in"
}]
}
}
}
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"]
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
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)
# 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]
}
}
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: {
"route_maps": [{
"name":
"rm_r1_out_{}".format(addr_type),
- "direction": 'out'
+ "direction": "out"
}]
}
}
}
}
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"
}]
}
}
}
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:
}
}
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 = {
"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)
}
}
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:
"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_"+
}
}
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: {
"route_maps": [{
"name":
"rmap_match_pf_1_{}".format(addr_type),
- "direction": 'in'
+ "direction": "in"
}]
}
}
}
}
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"]
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)
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]
# 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
"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)
}
}
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": {
"route_maps": [{
"name":
"rmap_match_pf_1_ipv4",
- "direction": 'in'
+ "direction": "in"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_1_ipv6",
- "direction": 'in'
+ "direction": "in"
}]
}
}
}
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": {
"route_maps": [{
"name":
"rmap_match_pf_1_ipv4",
- "direction": 'in',
+ "direction": "in",
"delete": True
}]
}
"route_maps": [{
"name":
"rmap_match_pf_1_ipv6",
- "direction": 'in',
+ "direction": "in",
"delete": True
}]
}
}
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)
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]
# 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
"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)
}
}
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": {
"route_maps": [{
"name":
"rmap_match_pf_1_ipv4",
- "direction": 'in'
+ "direction": "in"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_1_ipv6",
- "direction": 'in'
+ "direction": "in"
}]
}
}
}
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"]
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"]
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
# 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"]
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)
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]
"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": {
"route_maps": [{
"name":
"rmap_no_match_set_1_ipv4",
- "direction": 'in'
+ "direction": "in"
}]
}
}
"route_maps": [{
"name":
"rmap_no_match_set_2_ipv4",
- "direction": 'out'
+ "direction": "out"
}]
}
}
"route_maps": [{
"name":
"rmap_no_match_set_1_ipv6",
- "direction": 'in'
+ "direction": "in"
}]
}
}
"route_maps": [{
"name":
"rmap_no_match_set_2_ipv6",
- "direction": 'out'
+ "direction": "out"
}]
}
}
}
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()
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]
# 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
}
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": {
"route_maps": [{
"name":
"rmap_match_pf_1_ipv4",
- "direction": 'in'
+ "direction": "in"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_2_ipv4",
- "direction": 'out'
+ "direction": "out"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_3_ipv4",
- "direction": 'out'
+ "direction": "out"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_1_ipv6",
- "direction": 'in'
+ "direction": "in"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_2_ipv6",
- "direction": 'out'
+ "direction": "out"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_3_ipv6",
- "direction": 'out'
+ "direction": "out"
}]
}
}
}
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"]
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"]
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"]
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)
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]
# 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
}
}
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": {
"route_maps": [{
"name":
"rmap_match_pf_1_ipv4",
- "direction": 'in'
+ "direction": "in"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_1_ipv6",
- "direction": 'in'
+ "direction": "in"
}]
}
}
}
}
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"]
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)
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]
# 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
"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)
},
{
"action": "permit",
- 'seq_id': '20',
+ "seq_id": "20",
"match": {
addr_type: {
"prefix_lists": "pf_list_1_{}".format(addr_type)
},
{
"action": "permit",
- 'seq_id': '30',
+ "seq_id": "30",
"match": {
addr_type: {
"prefix_lists": "pf_list_1_{}".format(addr_type)
}
}
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": {
"route_maps": [{
"name":
"rmap_match_pf_1_ipv4",
- "direction": 'in'
+ "direction": "in"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_1_ipv6",
- "direction": 'in'
+ "direction": "in"
}]
}
}
}
}
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"],
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)
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]
# 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
"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)
},
{
"action": "permit",
- 'seq_id': '20',
+ "seq_id": "20",
"match": {
addr_type: {
"prefix_lists": "pf_list_1_{}".format(addr_type)
},
{
"action": "permit",
- 'seq_id': '30',
+ "seq_id": "30",
"match": {
addr_type: {
"prefix_lists": "pf_list_1_{}".format(addr_type)
}
}
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": {
"route_maps": [{
"name":
"rmap_match_pf_1_ipv4",
- "direction": 'in'
+ "direction": "in"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_1_ipv6",
- "direction": 'in'
+ "direction": "in"
}]
}
}
}
}
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"],
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)
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]
# 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
}
}
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": {
"route_maps": [{
"name":
"rmap_match_pf_1_ipv4",
- "direction": 'in'
+ "direction": "in"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_1_ipv6",
- "direction": 'in'
+ "direction": "in"
}]
}
}
}
}
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"]
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"
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)
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]
# 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
}
}
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": {
"route_maps": [{
"name":
"rmap_match_pf_1_ipv4",
- "direction": 'in'
+ "direction": "in"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_2_ipv6",
- "direction": 'out'
+ "direction": "out"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_1_ipv4",
- "direction": 'in'
+ "direction": "in"
}]
}
}
"route_maps": [{
"name":
"rmap_match_pf_2_ipv6",
- "direction": 'out'
+ "direction": "out"
}]
}
}
}
}
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)
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]
}
}
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": {
"route_maps": [{
"name":
"rmap_match_tag_1_ipv4",
- "direction": 'out'
+ "direction": "out"
}]
}
}
"route_maps": [{
"name":
"rmap_match_tag_1_ipv6",
- "direction": 'out'
+ "direction": "out"
}]
}
}
}
}
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 = {
}
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)
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]
}
}
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": {
"route_maps": [{
"name":
"rmap_match_tag_1_ipv4",
- "direction": 'out'
+ "direction": "out"
}]
}
}
"route_maps": [{
"name":
"rmap_match_tag_1_ipv6",
- "direction": 'out'
+ "direction": "out"
}]
}
}
}
}
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 = {
}
}
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))