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

Adding underlay BGP testcase #304

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 162 additions & 0 deletions test/test-cases/functional/saic/config_underlay_bgp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
[
{
"name": "vip_entry",
"op": "create",
"type": "SAI_OBJECT_TYPE_VIP_ENTRY",
"key": {
"switch_id": "$SWITCH_ID",
"vip": "221.0.0.2"
},
"attributes": [
"SAI_VIP_ENTRY_ATTR_ACTION",
"SAI_VIP_ENTRY_ACTION_ACCEPT"
]
},
{
"name": "direction_lookup_entry",
"op": "create",
"type": "SAI_OBJECT_TYPE_DIRECTION_LOOKUP_ENTRY",
"key": {
"switch_id": "$SWITCH_ID",
"vni": "11"
},
"attributes": [
"SAI_DIRECTION_LOOKUP_ENTRY_ATTR_ACTION",
"SAI_DIRECTION_LOOKUP_ENTRY_ACTION_SET_OUTBOUND_DIRECTION"
]
},
{
"name": "acl_in_1",
"op": "create",
"type": "SAI_OBJECT_TYPE_DASH_ACL_GROUP",
"attributes": [
"SAI_DASH_ACL_GROUP_ATTR_IP_ADDR_FAMILY",
"SAI_IP_ADDR_FAMILY_IPV4"
]
},
{
"name": "acl_out_1",
"op": "create",
"type": "SAI_OBJECT_TYPE_DASH_ACL_GROUP",
"attributes": [
"SAI_DASH_ACL_GROUP_ATTR_IP_ADDR_FAMILY",
"SAI_IP_ADDR_FAMILY_IPV4"
]
},
{
"name": "vnet_1",
"op": "create",
"type": "SAI_OBJECT_TYPE_VNET",
"attributes": [
"SAI_VNET_ATTR_VNI",
"11"
]
},
{
"name": "eni_id",
"op": "create",
"type": "SAI_OBJECT_TYPE_ENI",
"attributes": [
"SAI_ENI_ATTR_CPS",
"10000",
"SAI_ENI_ATTR_PPS",
"100000",
"SAI_ENI_ATTR_FLOWS",
"100000",
"SAI_ENI_ATTR_ADMIN_STATE",
"True",
"SAI_ENI_ATTR_VM_UNDERLAY_DIP",
"221.0.1.11",
"SAI_ENI_ATTR_VM_VNI",
"11",
"SAI_ENI_ATTR_VNET_ID",
"$vnet_1",
"SAI_ENI_ATTR_INBOUND_V4_STAGE1_DASH_ACL_GROUP_ID",
"$acl_in_1",
"SAI_ENI_ATTR_INBOUND_V4_STAGE2_DASH_ACL_GROUP_ID",
"$acl_in_1",
"SAI_ENI_ATTR_INBOUND_V4_STAGE3_DASH_ACL_GROUP_ID",
"$acl_in_1",
"SAI_ENI_ATTR_INBOUND_V4_STAGE4_DASH_ACL_GROUP_ID",
"$acl_in_1",
"SAI_ENI_ATTR_INBOUND_V4_STAGE5_DASH_ACL_GROUP_ID",
"$acl_in_1",
"SAI_ENI_ATTR_INBOUND_V6_STAGE1_DASH_ACL_GROUP_ID",
"$acl_out_1",
"SAI_ENI_ATTR_INBOUND_V6_STAGE2_DASH_ACL_GROUP_ID",
"$acl_out_1",
"SAI_ENI_ATTR_INBOUND_V6_STAGE3_DASH_ACL_GROUP_ID",
"$acl_out_1",
"SAI_ENI_ATTR_INBOUND_V6_STAGE4_DASH_ACL_GROUP_ID",
"$acl_out_1",
"SAI_ENI_ATTR_INBOUND_V6_STAGE5_DASH_ACL_GROUP_ID",
"$acl_out_1",
"SAI_ENI_ATTR_OUTBOUND_V4_STAGE1_DASH_ACL_GROUP_ID",
"0",
"SAI_ENI_ATTR_OUTBOUND_V4_STAGE2_DASH_ACL_GROUP_ID",
"0",
"SAI_ENI_ATTR_OUTBOUND_V4_STAGE3_DASH_ACL_GROUP_ID",
"0",
"SAI_ENI_ATTR_OUTBOUND_V4_STAGE4_DASH_ACL_GROUP_ID",
"0",
"SAI_ENI_ATTR_OUTBOUND_V4_STAGE5_DASH_ACL_GROUP_ID",
"0",
"SAI_ENI_ATTR_OUTBOUND_V6_STAGE1_DASH_ACL_GROUP_ID",
"0",
"SAI_ENI_ATTR_OUTBOUND_V6_STAGE2_DASH_ACL_GROUP_ID",
"0",
"SAI_ENI_ATTR_OUTBOUND_V6_STAGE3_DASH_ACL_GROUP_ID",
"0",
"SAI_ENI_ATTR_OUTBOUND_V6_STAGE4_DASH_ACL_GROUP_ID",
"0",
"SAI_ENI_ATTR_OUTBOUND_V6_STAGE5_DASH_ACL_GROUP_ID",
"0"
]
},
{
"name": "eni_ether_address_map_entry",
"op": "create",
"type": "SAI_OBJECT_TYPE_ENI_ETHER_ADDRESS_MAP_ENTRY",
"key": {
"switch_id": "$SWITCH_ID",
"address": "00:1A:C5:00:00:01"
},
"attributes": [
"SAI_ENI_ETHER_ADDRESS_MAP_ENTRY_ATTR_ENI_ID",
"$eni_id"
]
},
{
"name": "inbound_routing_entry",
"op": "create",
"type": "SAI_OBJECT_TYPE_INBOUND_ROUTING_ENTRY",
"key": {
"switch_id": "$SWITCH_ID",
"eni_id": "$eni_id",
"vni": "101",
"sip": "221.0.1.101",
"sip_mask": "255.255.255.0",
"priority": 0
},
"attributes": [
"SAI_INBOUND_ROUTING_ENTRY_ATTR_ACTION",
"SAI_INBOUND_ROUTING_ENTRY_ACTION_VXLAN_DECAP_PA_VALIDATE",
"SAI_INBOUND_ROUTING_ENTRY_ATTR_SRC_VNET_ID",
"$vnet_1"
]
},
{
"name": "pa_validation_entry",
"op": "create",
"type": "SAI_OBJECT_TYPE_PA_VALIDATION_ENTRY",
"key": {
"switch_id": "$SWITCH_ID",
"sip": "221.0.1.101",
"vnet_id": "$vnet_1"
},
"attributes": [
"SAI_PA_VALIDATION_ENTRY_ATTR_ACTION",
"SAI_PA_VALIDATION_ENTRY_ACTION_PERMIT"
]
}
]
11 changes: 11 additions & 0 deletions test/test-cases/functional/saic/doc_underlay_bgp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Functional Test Cases
Tests to verify essential functionality using low-rate traffic (SAI PTF).

## Contents

| Folder/File | Description |
| --- | --- |
| [`test_underlay_bgp.py`](test_underlay_bgp.py) | Verifies underlay BGP Established with ixia-c. We need licenced ixia-c version for verifying protocols.
Please follow the link below for license access
1. https://github.com/open-traffic-generator/otg-examples/blob/main/KENG.md

120 changes: 120 additions & 0 deletions test/test-cases/functional/saic/test_underlay_bgp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import json
from pathlib import Path
from pprint import pprint
import time
import pytest
from test-cases.utils.snappi_utils import *

current_file_dir = Path(__file__).parent

"""
This covers following scenario :

Test Underlay BGP Established between BMv2 and ixia-c

Topology Used :

-------- ------- --------
| | | | | |
| | | | | |
| IXIA-C |--------| BMv2 |--------| IXIA-C |
| | | | | |
| | | | | |
-------- ------- --------

"""

###############################################################
# Declaring Global variables
###############################################################

SPEED = "SPEED_100_GBPS"
BGP_TYPE = "ebgp"
NUMBER_OF_ROUTES = 10

###############################################################
# Start of the testcase
###############################################################
def test_underlay_bgp(confgen, dpu, dataplane):

# declare result
result = True

# STEP1 : Configure DPU
with (current_file_dir / 'config_underlay_bgp.json').open(mode='r') as config_file:
setup_commands = json.load(config_file)
result = [*dpu.process_commands(setup_commands)]
print("\n======= SAI commands RETURN values =======")
pprint(result)

# STEP2 : Configure TGEN
# configure L1 properties on configured ports
dataplane.config_l1_properties(SPEED)

## Tx side
dataplane.configuration.devices.device(name='Topology 1')
dataplane.configuration.devices.device(name='Topology 2')
eth = dataplane.configuration.devices[0].ethernets.add()
eth.port_name = dataplane.configuration.ports[0].name
eth.name = 'Ethernet 1'
eth.mac = "00:00:00:00:00:01"
ipv4 = eth.ipv4_addresses.add()
ipv4.name = 'IPv4 1'
ipv4.address = '220.0.1.2'
ipv4.gateway = '220.0.1.1'
ipv4.prefix = 24
bgpv4 = dataplane.configuration.devices[0].bgp
bgpv4.router_id = '220.0.1.1'
bgpv4_int = bgpv4.ipv4_interfaces.add()
bgpv4_int.ipv4_name = ipv4.name
bgpv4_peer = bgpv4_int.peers.add()
bgpv4_peer.name = 'BGP 1'
bgpv4_peer.as_type = BGP_TYPE
bgpv4_peer.peer_address = '220.0.1.1'
bgpv4_peer.as_number = 65001
route_range = bgpv4_peer.v4_routes.add(name="Network_Group1")
route_range.addresses.add(address='221.0.1.1', prefix=32, count=NUMBER_OF_ROUTES)

## Rx side
eth = dataplane.configuration.devices[1].ethernets.add()
eth.port_name = dataplane.configuration.ports[1].name
eth.name = 'Ethernet 2'
eth.mac = "00:00:00:00:00:02"
ipv4 = eth.ipv4_addresses.add()
ipv4.name = 'IPv4 2'
ipv4.address = '220.0.2.2'
ipv4.gateway = '220.0.2.1'
ipv4.prefix = 24
bgpv4 = dataplane.configuration.devices[1].bgp
bgpv4.router_id = '220.0.1.1'
bgpv4_int = bgpv4.ipv4_interfaces.add()
bgpv4_int.ipv4_name = ipv4.name
bgpv4_peer = bgpv4_int.peers.add()
bgpv4_peer.name = 'BGP 2'
bgpv4_peer.as_type = BGP_TYPE
bgpv4_peer.peer_address = '220.0.2.1'
bgpv4_peer.as_number = 65002
route_range = bgpv4_peer.v4_routes.add(name="Network_Group2")
route_range.addresses.add(address='221.0.2.1', prefix=32, count=NUMBER_OF_ROUTES)
dataplane.set_config()

# STEP3 : Verify BGP Neighbours Established
dataplane.start_protocols()
result = check_bgp_neighborship_established(dataplane)

# STEP4 : Cleanup DPU
dataplane.tearDown()
cleanup_commands = []
for val in setup_commands:
new_dict = {'name' : val['name'] ,'op': 'remove'}
cleanup_commands.append(new_dict)

result = [*dpu.process_commands(cleanup_commands)]
print("\n======= SAI commands RETURN values =======")
pprint(result)

# STEP5 : Print Result of the test
print("Final Result : {}".format(result))

assert result == False, "Test underlay bgp FAILED!!"