-
Notifications
You must be signed in to change notification settings - Fork 708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[test plan] 4-byte AS Translation #8973
Changes from 21 commits
e8fb9e1
7d37d5a
1597709
70bea76
d7182bc
cd5f77d
025d4f2
44449fb
e15ea86
8d81027
e5d2305
6149cb3
52dcf3f
954e1f4
fbbf6c9
5bf1157
a34389c
925b27b
5ded63d
71da2ba
145fef7
1cbc1cf
ba54ccf
6d3aea6
abb7a18
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
- [Overview](#overview) | ||
- [Scope](#scope) | ||
- [Testbed](#testbed) | ||
- [Setup configuration](#setup-configuration) | ||
- [Test cases](#test-cases) | ||
|
||
# Test name | ||
|
||
BGP Session Flaps | ||
|
||
## Overview | ||
|
||
The goal of this test is to verify that the CPU and memory do not spike during cycles of BGP sessions flapping. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this really meant to be a test for session flap and memory check? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @prsunny You are correct that this was a mistake. I have updated it to the proper overview. |
||
|
||
### Scope | ||
|
||
The test is targeting a running SONIC system with fully functioning configuration. The purpose of the test is to test for 4-Byte AS translation. | ||
|
||
### Related DUT CLI commands | ||
|
||
| Command | Comment | | ||
| ------- | ------- | | ||
|Configuration commands| | ||
| N/A | | | ||
|Show commands| | ||
| show ip bgp summary | Dispaly current memory statistics, can be done with ipv6 too | | ||
|
||
### Related DUT configuration files | ||
|
||
N/A | ||
|
||
### Related SAI APIs | ||
|
||
N/A | ||
|
||
## Test structure | ||
### Setup configuration | ||
|
||
This test requires BGP neighbors to be configured and established. | ||
|
||
### Configuration scripts | ||
|
||
N/A | ||
|
||
## Test cases | ||
### Test case #1 - 4-byte AS Translation | ||
|
||
#### Test objective | ||
|
||
Have a single neighbor configured with 4-byte ASN. | ||
Step 1: Configure DUT and neighbor with 4-Byte ASN | ||
Step 2: Verify 4-byte BGP session between DUT and neighbor is established | ||
Step 3: Verify BGP is established for 4-byte neighbor and down for 2-byte neighbors | ||
Step 3: Configure DUT to use 2-byte local-ASN for 2-byte neighbors | ||
Step 4: Verify BGP is now established for 4-byte neighbor AND 2-byte neighbors | ||
Step 5: Verify 2-byte neighbors receive routes from upstream 4-byte routers |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Value router_id (\d+.\d+.\d+.\d+) | ||
|
||
Start | ||
^BGP router identifier\s+${router_id} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,284 @@ | ||
''' | ||
|
||
The test case will verify that the DUT supports 4-byte AS Number translation. | ||
|
||
Step 1: Configure DUT and neighbor with 4-Byte ASN | ||
Step 2: Verify 4-byte BGP session between DUT and neighbor is established | ||
Step 3: Verify BGP is established for 4-byte neighbor and down for 2-byte neighbors | ||
Step 3: Configure DUT to use 2-byte local-ASN for 2-byte neighbors | ||
Step 4: Verify BGP is now established for 4-byte neighbor AND 2-byte neighbors | ||
Step 5: Verify 2-byte neighbors receive routes from upstream 4-byte routers | ||
|
||
|
||
''' | ||
import logging | ||
|
||
import pytest | ||
import time | ||
import textfsm | ||
from tests.common.config_reload import config_reload | ||
|
||
logger = logging.getLogger(__name__) | ||
dut_4byte_asn = 400003 | ||
neighbor_4byte_asn = 400001 | ||
bgp_sleep = 60 | ||
bgp_id_textfsm = "./bgp/templates/bgp_id.template" | ||
|
||
pytestmark = [ | ||
pytest.mark.topology('t2') | ||
] | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def setup(tbinfo, nbrhosts, duthosts, enum_frontend_dut_hostname, enum_rand_one_frontend_asic_index, request): | ||
# verify neighbors are type sonic | ||
if request.config.getoption("neighbor_type") != "sonic": | ||
pytest.skip("Neighbor type must be sonic") | ||
duthost = duthosts[enum_frontend_dut_hostname] | ||
asic_index = enum_rand_one_frontend_asic_index | ||
namespace = duthost.get_namespace_from_asic_id(asic_index) | ||
dut_asn = tbinfo['topo']['properties']['configuration_properties']['common']['dut_asn'] | ||
tor1 = duthost.shell("show lldp table")['stdout'].split("\n")[3].split()[1] | ||
tor2 = duthost.shell("show lldp table")['stdout'].split("\n")[5].split()[1] | ||
|
||
tor_neighbors = dict() | ||
skip_hosts = duthost.get_asic_namespace_list() | ||
bgp_facts = duthost.bgp_facts(instance_id=asic_index)['ansible_facts'] | ||
neigh_asn = dict() | ||
|
||
# verify sessions are established and gather neighbor information | ||
for k, v in bgp_facts['bgp_neighbors'].items(): | ||
if v['description'].lower() not in skip_hosts: | ||
if v['description'] == tor1: | ||
if v['ip_version'] == 4: | ||
neigh_ip_v4 = k | ||
peer_group_v4 = v['peer group'] | ||
elif v['ip_version'] == 6: | ||
neigh_ip_v6 = k | ||
peer_group_v6 = v['peer group'] | ||
if v['description'] == tor2: | ||
if v['ip_version'] == 4: | ||
neigh2_ip_v4 = k | ||
elif v['ip_version'] == 6: | ||
neigh2_ip_v6 = k | ||
assert v['state'] == 'established' | ||
neigh_asn[v['description']] = v['remote AS'] | ||
tor_neighbors[v['description']] = nbrhosts[v['description']]["host"] | ||
|
||
dut_ip_v4 = tbinfo['topo']['properties']['configuration'][tor1]['bgp']['peers'][dut_asn][0] | ||
dut_ip_v6 = tbinfo['topo']['properties']['configuration'][tor1]['bgp']['peers'][dut_asn][1] | ||
|
||
dut_ip_bgp_sum = duthost.shell('show ip bgp summary')['stdout'] | ||
neigh_ip_bgp_sum = nbrhosts[tor1]["host"].shell('show ip bgp summary')['stdout'] | ||
neigh2_ip_bgp_sum = nbrhosts[tor1]["host"].shell('show ip bgp summary')['stdout'] | ||
with open(bgp_id_textfsm) as template: | ||
fsm = textfsm.TextFSM(template) | ||
dut_bgp_id = fsm.ParseText(dut_ip_bgp_sum)[0][0] | ||
neigh_bgp_id = fsm.ParseText(neigh_ip_bgp_sum)[1][0] | ||
neigh2_bgp_id = fsm.ParseText(neigh2_ip_bgp_sum)[1][0] | ||
|
||
dut_ipv4_network = duthost.shell("show run bgp | grep 'ip prefix-list'")['stdout'].split()[6] | ||
dut_ipv6_network = duthost.shell("show run bgp | grep 'ipv6 prefix-list'")['stdout'].split()[6] | ||
neigh_ipv4_network = nbrhosts[tor1]["host"].shell("show run bgp | grep 'ip prefix-list'")['stdout'].split()[6] | ||
neigh_ipv6_network = nbrhosts[tor1]["host"].shell("show run bgp | grep 'ipv6 prefix-list'")['stdout'].split()[6] | ||
|
||
setup_info = { | ||
'duthost': duthost, | ||
'neighhost': tor_neighbors[tor1], | ||
'neigh2host': tor_neighbors[tor2], | ||
'tor1': tor1, | ||
'tor2': tor2, | ||
'dut_asn': dut_asn, | ||
'neigh_asn': neigh_asn[tor1], | ||
'neigh2_asn': neigh_asn[tor2], | ||
'asn_dict': neigh_asn, | ||
'neighbors': tor_neighbors, | ||
'namespace': namespace, | ||
'dut_ip_v4': dut_ip_v4, | ||
'dut_ip_v6': dut_ip_v6, | ||
'neigh_ip_v4': neigh_ip_v4, | ||
'neigh_ip_v6': neigh_ip_v6, | ||
'neigh2_ip_v4': neigh2_ip_v4, | ||
'neigh2_ip_v6': neigh2_ip_v6, | ||
'peer_group_v4': peer_group_v4, | ||
'peer_group_v6': peer_group_v6, | ||
'asic_index': asic_index, | ||
'dut_bgp_id': dut_bgp_id, | ||
'neigh_bgp_id': neigh_bgp_id, | ||
'neigh2_bgp_id': neigh2_bgp_id, | ||
'dut_ipv4_network': dut_ipv4_network, | ||
'dut_ipv6_network': dut_ipv6_network, | ||
'neigh_ipv4_network': neigh_ipv4_network, | ||
'neigh_ipv6_network': neigh_ipv6_network | ||
} | ||
|
||
logger.info("DUT BGP Config: {}".format(duthost.shell("show run bgp", module_ignore_errors=True)['stdout'])) | ||
logger.info("Neighbor BGP Config: {}".format(nbrhosts[tor1]["host"].shell("show run bgp")['stdout'])) | ||
logger.info('Setup_info: {}'.format(setup_info)) | ||
|
||
yield setup_info | ||
|
||
# restore config to original state | ||
config_reload(duthost) | ||
config_reload(tor_neighbors[tor1], is_dut=False) | ||
|
||
# verify sessions are established | ||
bgp_facts = duthost.bgp_facts(instance_id=asic_index)['ansible_facts'] | ||
for k, v in bgp_facts['bgp_neighbors'].items(): | ||
if v['description'].lower() not in skip_hosts: | ||
logger.debug(v['description']) | ||
assert v['state'] == 'established' | ||
|
||
|
||
def test_4_byte_asn_translation(setup): | ||
cmd = 'vtysh -n {} \ | ||
-c "config" \ | ||
-c "no router bgp {}" \ | ||
-c "router bgp {}" \ | ||
-c "bgp router-id {}" \ | ||
-c "bgp log-neighbor-changes" \ | ||
-c "no bgp ebgp-requires-policy" \ | ||
-c "no bgp default ipv4-unicast" \ | ||
-c "bgp bestpath as-path multipath-relax" \ | ||
-c "neighbor {} peer-group" \ | ||
-c "neighbor {} peer-group" \ | ||
-c "neighbor {} remote-as {}" \ | ||
-c "neighbor {} peer-group {}" \ | ||
-c "neighbor {} description {}" \ | ||
-c "neighbor {} timers 3 10" \ | ||
-c "neighbor {} timers connect 10" \ | ||
-c "neighbor {} remote-as {}" \ | ||
-c "neighbor {} peer-group {}" \ | ||
-c "neighbor {} description {}" \ | ||
-c "neighbor {} timers 3 10" \ | ||
-c "neighbor {} timers connect 10" \ | ||
-c "neighbor {} remote-as {}" \ | ||
-c "neighbor {} peer-group {}" \ | ||
-c "neighbor {} description {}" \ | ||
-c "neighbor {} timers 3 10" \ | ||
-c "neighbor {} timers connect 10" \ | ||
-c "neighbor {} remote-as {}" \ | ||
-c "neighbor {} peer-group {}" \ | ||
-c "neighbor {} description {}" \ | ||
-c "neighbor {} timers 3 10" \ | ||
-c "neighbor {} timers connect 10" \ | ||
-c "address-family ipv4 unicast" \ | ||
-c "network {}" \ | ||
-c "neighbor {} soft-reconfiguration inbound" \ | ||
-c "neighbor {} route-map FROM_BGP_PEER_V4 in" \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. route-map define is missing in the file, what exactly the route-map contain, similar other route map in the files as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kishorekunal01 This is a pre-configured route map that is part of the T2 BGP configuration. I did add a comment specifying this at the start of the command block. |
||
-c "neighbor {} route-map TO_BGP_PEER_V4 out" \ | ||
-c "neighbor {} activate" \ | ||
-c "neighbor {} activate" \ | ||
-c "maximum-paths 64" \ | ||
-c "exit-address-family" \ | ||
-c "address-family ipv6 unicast" \ | ||
-c "network {}" \ | ||
-c "neighbor {} soft-reconfiguration inbound" \ | ||
-c "neighbor {} route-map FROM_BGP_PEER_V6 in" \ | ||
-c "neighbor {} route-map TO_BGP_PEER_V6 out" \ | ||
-c "neighbor {} activate" \ | ||
-c "neighbor {} activate" \ | ||
-c "maximum-paths 64" \ | ||
-c "exit-address-family" \ | ||
'.format(setup['namespace'], setup['dut_asn'], dut_4byte_asn, setup['dut_bgp_id'], | ||
setup['peer_group_v4'], setup['peer_group_v6'], setup['neigh_ip_v4'], neighbor_4byte_asn, | ||
setup['neigh_ip_v4'], setup['peer_group_v4'], setup['neigh_ip_v4'], setup['tor1'], setup['neigh_ip_v4'], | ||
setup['neigh_ip_v4'], setup['neigh_ip_v6'], neighbor_4byte_asn, setup['neigh_ip_v6'], | ||
setup['peer_group_v6'], setup['neigh_ip_v6'], setup['tor1'], setup['neigh_ip_v6'], setup['neigh_ip_v6'], | ||
setup['neigh2_ip_v4'], setup['neigh2_asn'], setup['neigh2_ip_v4'], setup['peer_group_v4'], | ||
setup['neigh2_ip_v4'], setup['tor2'], setup['neigh2_ip_v4'], setup['neigh2_ip_v4'], setup['neigh2_ip_v6'], | ||
setup['neigh2_asn'], setup['neigh2_ip_v6'], setup['peer_group_v6'], setup['neigh2_ip_v6'], setup['tor2'], | ||
setup['neigh2_ip_v6'], setup['neigh2_ip_v6'], setup['dut_ipv4_network'], setup['peer_group_v4'], | ||
setup['peer_group_v4'], setup['peer_group_v4'], setup['neigh_ip_v4'], setup['neigh2_ip_v4'], | ||
setup['dut_ipv6_network'], setup['peer_group_v6'], setup['peer_group_v6'], setup['peer_group_v6'], | ||
setup['neigh_ip_v6'], setup['neigh2_ip_v6']) | ||
logger.debug(setup['duthost'].shell(cmd, module_ignore_errors=True)) | ||
|
||
cmd = 'vtysh \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I added cli options for the neighbor. |
||
-c "config" \ | ||
-c "no router bgp {}" \ | ||
-c "router bgp {}" \ | ||
-c "bgp router-id {}" \ | ||
-c "bgp log-neighbor-changes" \ | ||
-c "no bgp ebgp-requires-policy" \ | ||
-c "no bgp default ipv4-unicast" \ | ||
-c "bgp bestpath as-path multipath-relax" \ | ||
-c "neighbor {} peer-group" \ | ||
-c "neighbor {} peer-group" \ | ||
-c "neighbor {} remote-as {}" \ | ||
-c "neighbor {} peer-group {}" \ | ||
-c "neighbor {} description {}" \ | ||
-c "neighbor {} timers 3 10" \ | ||
-c "neighbor {} timers connect 10" \ | ||
-c "neighbor {} remote-as {}" \ | ||
-c "neighbor {} peer-group {}" \ | ||
-c "neighbor {} description {}" \ | ||
-c "neighbor {} timers 3 10" \ | ||
-c "neighbor {} timers connect 10" \ | ||
-c "address-family ipv4 unicast" \ | ||
-c "network {}" \ | ||
-c "neighbor {} soft-reconfiguration inbound" \ | ||
-c "neighbor {} route-map FROM_BGP_PEER_V4 in" \ | ||
-c "neighbor {} route-map TO_BGP_PEER_V4 out" \ | ||
-c "neighbor {} activate" \ | ||
-c "maximum-paths 64" \ | ||
-c "exit-address-family" \ | ||
-c "address-family ipv6 unicast" \ | ||
-c "network {}" \ | ||
-c "neighbor {} soft-reconfiguration inbound" \ | ||
-c "neighbor {} route-map FROM_BGP_PEER_V6 in" \ | ||
-c "neighbor {} route-map TO_BGP_PEER_V6 out" \ | ||
-c "neighbor {} activate" \ | ||
-c "maximum-paths 64" \ | ||
-c "exit-address-family" \ | ||
'.format(setup['neigh_asn'], neighbor_4byte_asn, setup['neigh_bgp_id'], | ||
setup['peer_group_v4'], setup['peer_group_v6'], setup['dut_ip_v4'], dut_4byte_asn, setup['dut_ip_v4'], | ||
setup['peer_group_v4'], setup['dut_ip_v4'], 'DUT', setup['dut_ip_v4'], setup['dut_ip_v4'], | ||
setup['dut_ip_v6'], dut_4byte_asn, setup['dut_ip_v6'], setup['peer_group_v6'], setup['dut_ip_v6'], 'DUT', | ||
setup['dut_ip_v6'], setup['dut_ip_v6'], setup['neigh_ipv4_network'], setup['peer_group_v4'], | ||
setup['peer_group_v4'], setup['peer_group_v4'], setup['dut_ip_v4'], setup['neigh_ipv6_network'], | ||
setup['peer_group_v6'], setup['peer_group_v6'], setup['peer_group_v6'], setup['dut_ip_v6']) | ||
|
||
logger.debug(setup['neighhost'].shell(cmd, module_ignore_errors=True)) | ||
|
||
logger.info("DUT BGP Config: {}".format(setup['duthost'].shell("show run bgp")['stdout'])) | ||
logger.info("Neighbor BGP Config: {}".format(setup['neighhost'].shell("show run bgp")['stdout'])) | ||
|
||
time.sleep(bgp_sleep) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you elaborate on what the previous cmd is doing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The previous command configures a 4-byte ASN on the neighbor device. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean how did you decide bgp_sleep? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is the standard amount of time we wait for our tests to allow BGP to converge. Then after running the test case if there is an issue it is extended. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM if this sleep time of 120 works well on T2 |
||
|
||
# verify session to 4-byte neighbor is established and 2-byte neighbor is down | ||
bgp_facts = setup['duthost'].bgp_facts(instance_id=setup['asic_index'])['ansible_facts'] | ||
for k, v in bgp_facts['bgp_neighbors'].items(): | ||
if v['description'].lower() == setup['tor1']: | ||
logger.debug(v['description']) | ||
assert v['state'] == 'established' | ||
elif v['description'].lower() == setup['tor2']: | ||
logger.debug(v['description']) | ||
assert v['state'] != 'established' | ||
|
||
# Configure DUT to use 2-byte local-ASN for 2-byte neighbors | ||
cmd = 'vtysh -n {} \ | ||
-c "config" \ | ||
-c "router bgp {}" \ | ||
-c "neighbor {} local-as {}" \ | ||
-c "neighbor {} local-as {}" \ | ||
'.format(setup['namespace'], dut_4byte_asn, setup['peer_group_v4'], setup['dut_asn'], setup['peer_group_v6'], | ||
setup['dut_asn']) | ||
logger.debug(setup['duthost'].shell(cmd, module_ignore_errors=True)) | ||
cmd = 'vtysh -n {} -c "clear bgp *"'.format(setup['namespace']) | ||
logger.debug(setup['duthost'].shell(cmd, module_ignore_errors=True)) | ||
|
||
time.sleep(bgp_sleep) | ||
|
||
# verify session to 4-byte and 2-byte neighbor is established | ||
bgp_facts = setup['duthost'].bgp_facts(instance_id=setup['asic_index'])['ansible_facts'] | ||
for k, v in bgp_facts['bgp_neighbors'].items(): | ||
if v['description'].lower() == setup['tor1']: | ||
logger.debug(v['description']) | ||
assert v['state'] == 'established' | ||
elif v['description'].lower() == setup['tor2']: | ||
logger.debug(v['description']) | ||
assert v['state'] == 'established' | ||
|
||
cmd = 'vtysh -c "show bgp ipv4 all neighbors {}" received-routes'.format(setup['neigh_ipv4_network']) | ||
logger.debug(setup['neigh2host'].shell(cmd, module_ignore_errors=True)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like the test name and overview is not aligned with test description. Can you check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@prsunny You are correct that this was a mistake. I have updated it to the proper name.