Skip to content
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

Add basic MPLS testcases #3483

Merged
merged 38 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ff9cbc5
Adding mpls tests
May 14, 2021
81b3f65
Added comments
SijiJ May 14, 2021
756fa1f
Delete route_del_routes.json
SijiJ May 14, 2021
ea00aca
Modify comment
May 14, 2021
276cabc
Merge branch 'Azure:master' into master
SijiJ May 14, 2021
832786e
Add MPLS testplan
May 17, 2021
d802deb
Merge remote-tracking branch 'refs/remotes/origin/master'
May 17, 2021
eb64bcf
Update label_push_routes.json
SijiJ Jun 16, 2021
6422fb7
Update label_pop_routes.json
SijiJ Jun 16, 2021
f194a66
Update label_swap_routes.json
SijiJ Jun 16, 2021
2a95aa2
Update MPLS-test-plan.md
SijiJ Jun 16, 2021
a60bef6
Update label_pop_routes.json
SijiJ Jun 29, 2021
924499e
Update label_push_routes.json
SijiJ Jun 29, 2021
83fb57b
Update label_swap_routes.json
SijiJ Jun 29, 2021
c81f50a
Update MPLS-test-plan.md
SijiJ Jun 29, 2021
44193f0
Create label_pop_routes.j2
SijiJ Jan 20, 2022
91e61ac
Create label_push_routes.j2
SijiJ Jan 20, 2022
df0a2c8
Create label_swap_routes.j2
SijiJ Jan 20, 2022
9f4a84a
Delete label_del_routes.json
SijiJ Jan 20, 2022
022183c
Delete label_pop_routes.json
SijiJ Jan 20, 2022
6e95baf
Delete label_push_routes.json
SijiJ Jan 20, 2022
60af68a
Delete label_swap_routes.json
SijiJ Jan 20, 2022
a0c45a4
Create label_del_routes.j2
SijiJ Jan 20, 2022
89cad03
Update test_mpls.py
SijiJ Jan 20, 2022
6922d24
Update test_mpls.py
SijiJ Jan 20, 2022
d244442
Update test_mpls.py
SijiJ Jan 20, 2022
f379098
Update MPLS-test-plan.md
SijiJ Jan 25, 2022
df4e546
Update MPLS-test-plan.md
SijiJ Jan 25, 2022
bcae2fc
Update test_mpls.py
SijiJ Jan 25, 2022
424eafc
Update MPLS-test-plan.md
SijiJ Feb 9, 2022
be0ed88
Create conftest.py
SijiJ Mar 16, 2022
23a8e47
Update test_mpls.py
SijiJ Mar 16, 2022
981b237
Update test_mpls.py
SijiJ Mar 16, 2022
a101ed0
Update test_mpls.py
SijiJ Mar 16, 2022
c95f546
Update test_mpls.py
SijiJ Mar 17, 2022
e901926
Update conftest.py
SijiJ Mar 17, 2022
2b71479
Update test_mpls.py
SijiJ Apr 27, 2022
d6a4cf8
Update test_mpls.py
SijiJ May 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
177 changes: 177 additions & 0 deletions docs/testplan/MPLS-test-plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
- [Overview](#overview)
* [Scope](#scope)
* [Testbed](#testbed)
- [Setup configuration](#setup-configuration)
+ [Setup of DUT switch](#setup-of-dut-switch)
- [Test cases](#test-cases)
* [Test case \#1 - POP Label](#test-case-1---pop-label)
+ [Test objective](#test-objective)
+ [Test steps](#test-steps)
* [Test case \#2 - SWAP Label for single label](#test-case-2---swap-label-for-single-label)
+ [Test objective](#test-objective-1)
+ [Test steps](#test-steps-1)
* [Test case \#3 - PUSH Label](#test-case-3---push-label)
+ [Test objective](#test-objective-2)
+ [Test steps](#test-steps-2)
SijiJ marked this conversation as resolved.
Show resolved Hide resolved
* [Test case \#4 - SWAP Label for multiple label stack](#test-case-4---swap-label-for-multiple-label-stack)
+ [Test objective](#test-objective-3)
+ [Test steps](#test-steps-3)

## Overview
This is Test Plan to test MPLS feature on SONiC. The test enables MPLS on interfaces, configures static LSPs and assumes all basic configurations including BGP routes are already preconfigured.

### Scope
The test is targeting a running SONiC system with basic functioning configuration.
Purpose of the test is to verify MPLS on a SONiC system bringing up the ingress, transit or egress static LSP and forwarding the traffic correctly.

### Testbed
T1

## Setup configuration
MPLS will be enabled/disabled on interface command:
```
config interface mpls <add|remove> <interface>
```
MPLS configuration will be set on DUT dynamically.

#### Setup of DUT switch
During testrun, Ansible will copy JSON file containing configuration for MPLS to DUT and push to SONiC APPL DB via swssconfig.

JSON Sample:

label_pop_routes.j2

```
[
{
"LABEL_ROUTE_TABLE:1000001": {
SijiJ marked this conversation as resolved.
Show resolved Hide resolved
"nexthop": "{{ nexthop }}",
"ifname": "{{ port }}",
"mpls_pop": "1",
"weight": "1"
},
"OP": "SET"
},
{
"LABEL_ROUTE_TABLE:1000003": {
"nexthop": "{{ nexthop }}",
"ifname": "{{ port }}",
"mpls_pop": "1",
"weight": "1"
},
"OP": "SET"
}
]
```

label_push_routes.j2

```
[
{
"ROUTE_TABLE:192.168.0.1": {
"nexthop": "{{ nexthop }}",
"ifname": "{{ port }}",
"mpls_nh": "push1000001",
"weight": "1"
},
"OP": "SET"
}
]
```
label_swap_routes.j2

```
[
{
"LABEL_ROUTE_TABLE:1000001": {
"nexthop": "{{ nexthop }}",
"ifname": "{{ port }}",
"mpls_nh": "swap1000002",
"mpls_pop": "1"
"weight": "1"
},
"OP": "SET"
},
{
"LABEL_ROUTE_TABLE:1000003": {
"nexthop": "{{ nexthop }}",
"ifname": "{{ port }}",
"mpls_nh": "swap1000004",
"mpls_pop": "1",
"weight": "1"
},
"OP": "SET"
}
]
```
label_del_routes.j2

```
[
{
"LABEL_ROUTE_TABLE:1000001": {
},
"OP": "DEL"
},
{
"LABEL_ROUTE_TABLE:1000003": {
},
"OP": "DEL"
},
{
"ROUTE_TABLE:192.168.0.1": {
},
"OP": "DEL"
}
]
```
## Test cases

Each testcase configures static LSP, sends traffic, captures on receving port and verifies appropriate LABEL action is applied on packet.

### Test case \#1 - POP Label

#### Test objective

Verify that the MPLS label is removed on the received packet.

#### Test steps
- Enable MPLS on interfaces and configure pop label.
- Send MPLS packet.
- Capture the packet and verify that it is IP packet with MPLS removed.

### Test case \#2 - SWAP Label for single label

#### Test objective

Verify that the MPLS label is swapped on the received packet.

#### Test steps
- Enable MPLS on interfaces and configure swap label for MPLS packet.
- Send MPLS packet.
- Capture the packet and verify that it is MPLS packet with label swapped as per configuration.

### Test case \#3 - PUSH Label

#### Test objective

Verify that the MPLS label is pushed on the received packet.

#### Test steps
- Enable MPLS on interfaces and configure push label for MPLS packet.
- Send IP packet.
- Capture the packet and verify that it is MPLS packet with label added as per configuration.


### Test case \#4 - SWAP Label for multiple label stack

#### Test objective

Verify that the MPLS top label is swapped on the received packet.

#### Test steps
- Enable MPLS on interfaces and configure swap label for MPLS packet.
- Send MPLS packet.
- Capture the packet and verify that it is MPLS packet with label swapped as per configuration for the top label.

17 changes: 17 additions & 0 deletions tests/mpls/configs/label_del_routes.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"LABEL_ROUTE_TABLE:1000001": {
},
"OP": "DEL"
},
{
"LABEL_ROUTE_TABLE:1000003": {
},
"OP": "DEL"
},
{
"ROUTE_TABLE:192.168.0.1": {
},
"OP": "DEL"
}
]
SijiJ marked this conversation as resolved.
Show resolved Hide resolved
20 changes: 20 additions & 0 deletions tests/mpls/configs/label_pop_routes.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"LABEL_ROUTE_TABLE:1000001": {
"nexthop": "{{ dst_peer_addr }}",
"ifname": "{{ dst_port }}",
"mpls_pop": "1",
"weight": "1"
},
"OP": "SET"
},
{
"LABEL_ROUTE_TABLE:1000003": {
"nexthop": "{{ src_peer_addr }}",
"ifname": "{{ src_port }}",
"mpls_pop": "1",
"weight": "1"
},
"OP": "SET"
}
]
11 changes: 11 additions & 0 deletions tests/mpls/configs/label_push_routes.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"ROUTE_TABLE:192.168.0.1": {
"nexthop": "{{ dst_peer_addr }}",
"ifname": "{{ dst_port }}",
"mpls_nh": "push1000001",
"weight": "1"
},
"OP": "SET"
}
]
22 changes: 22 additions & 0 deletions tests/mpls/configs/label_swap_routes.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
{
"LABEL_ROUTE_TABLE:1000001": {
"nexthop": "{{ dst_peer_addr }}",
"ifname": "{{ dst_port }}",
"mpls_nh": "swap1000002",
"mpls_pop": "1",
"weight": "1"
},
"OP": "SET"
},
{
"LABEL_ROUTE_TABLE:1000003": {
"nexthop": "{{ src_peer_addr }}",
"ifname": "{{ src_port }}",
"mpls_nh": "swap1000004",
"mpls_pop": "1",
"weight": "1"
},
"OP": "SET"
}
]
121 changes: 121 additions & 0 deletions tests/mpls/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import logging
import pytest
import pprint

logger = logging.getLogger(__name__)

DUT_TMP_DIR='/tmp'

LABEL_POP_ROUTES='label_pop_routes'
LABEL_PUSH_ROUTES='label_push_routes'
LABEL_SWAP_ROUTES='label_swap_routes'
LABEL_DEL_ROUTES='label_del_routes'

@pytest.fixture(scope='module')
def setup(duthost, tbinfo, ptfadapter):
"""
setup fixture gathers all test required information from DUT facts and tbinfo
:param duthost: DUT host object
:param tbinfo: fixture provides information about testbed
:return: dictionary with all test required information
"""
if tbinfo['topo']['name'] not in ('t1'):
pytest.skip('Unsupported topology')

# gather ansible facts
mg_facts=duthost.minigraph_facts(host=duthost.hostname)['ansible_facts']
host_facts=duthost.setup()['ansible_facts']

tor_ports_ids={}
tor_ports=[]
spine_ports_ids={}
spine_ports=[]
tor_addr={}
tor_peer_addr={}
spine_addr={}
spine_peer_addr={}
tor_mac={}
spine_mac={}

all_ifs=[]

ip_ifaces=duthost.get_active_ip_interfaces(tbinfo, asic_index="all")

for k,v in ip_ifaces[0].items():
all_ifs.append(k)
logger.info(ip_ifaces[0][k])
if 'T0' in v['bgp_neighbor']:
tor_ports.append(k)
tor_addr[k]=v['ipv4']
tor_peer_addr[k]=v['peer_ipv4']
elif 'T2' in v['bgp_neighbor']:
spine_ports.append(k)
spine_addr[k]=v['ipv4']
spine_peer_addr[k]=v['peer_ipv4']

logger.info('tor_ports: {}'.format(tor_ports))
logger.info('spine_ports: {}'.format(spine_ports))
logger.info('tor_addr: {}'.format(tor_addr))

for dut_port in tor_ports:
port_id=mg_facts['minigraph_port_indices'][dut_port]
tor_ports_ids[dut_port]=port_id
ansible_port='ansible_'+dut_port
tor_mac[dut_port]=host_facts[ansible_port]['macaddress']

for dut_port in spine_ports:
port_id=mg_facts['minigraph_port_indices'][dut_port]
spine_ports_ids[dut_port]=port_id
ansible_port='ansible_'+dut_port
spine_mac[dut_port]=host_facts[ansible_port]['macaddress']

logger.info('spine_mac: {}'.format(spine_mac))
logger.info('spine_ports_ids: {}'.format(spine_ports_ids))

src_port=random.choice(spine_ports)
dst_port=random.choice(tor_ports)

dst_pid=tor_ports_ids[dst_port]
src_pid=spine_ports_ids[src_port]

dst_mac=tor_mac[dst_port]
src_mac=spine_mac[src_port]

dst_addr=tor_addr[dst_port]
src_addr=spine_addr[src_port]

dst_peer_addr=tor_peer_addr[dst_port]
src_peer_addr=spine_peer_addr[src_port]

setup_information={
'duthost': duthost,
'dut_tmp_dir': DUT_TMP_DIR,
'dst_ip_spine_blocked': '192.168.144.1',
'src_port': src_port,
'dst_port': dst_port,
'src_addr': src_addr,
'src_peer_addr': src_peer_addr,
'dst_addr': dst_addr,
'dst_peer_addr': dst_peer_addr,
'src_pid': src_pid,
'dst_pid': dst_pid,
'src_mac': src_mac,
'dst_mac': dst_mac,
}

logger.info('setup variables {}'.format(pprint.pformat(setup)))

# FIXME: There seems to be some issue with the initial setup of the ptfadapter, causing some of the
# TestBasicMPLS tests to fail because the forwarded packets are not being collected. This is an
# attempt to mitigate that issue while we continue to investigate the root cause.
#
# Ref: GitHub Issue #2032
logger.info("setting up the ptfadapter")
ptfadapter.reinit()

yield setup_information

duthost.command('rm -rf {}'.format(os.path.join(DUT_TMP_DIR, LABEL_POP_ROUTES, '.json')))
duthost.command('rm -rf {}'.format(os.path.join(DUT_TMP_DIR, LABEL_SWAP_ROUTES, '.json')))
duthost.command('rm -rf {}'.format(os.path.join(DUT_TMP_DIR, LABEL_PUSH_ROUTES, '.json')))
duthost.command('rm -rf {}'.format(os.path.join(DUT_TMP_DIR, LABEL_DEL_ROUTES, '.json')))