Skip to content

Commit

Permalink
Created test-cases to test the SAI API routing (create and remove)
Browse files Browse the repository at this point in the history
  • Loading branch information
amithgspn23 committed Jun 22, 2023
1 parent 3d62a6b commit ce534df
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from pprint import pprint

import pytest

# Constants
SWITCH_ID = 5

commands = [
{
"name": "route_entry_1",
"op": "create",
"type": "SAI_OBJECT_TYPE_ROUTE_ENTRY",
"key": {
"switch_id": "$SWITCH_ID",
"vr_id": "10",
"destination": "221.1.0.0/24"
},
"attributes": [
"SAI_ROUTE_ENTRY_ATTR_NEXT_HOP_ID",
"0"
]
},
{
"name": "route_entry_2",
"op": "create",
"type": "SAI_OBJECT_TYPE_ROUTE_ENTRY",
"key": {
"switch_id": "$SWITCH_ID",
"vr_id": "10",
"destination": "221.2.0.0/24",
},
"attributes": [
"SAI_ROUTE_ENTRY_ATTR_NEXT_HOP_ID",
"1"
]
}
]

class TestSaiVnetRoutingEntry:
def test_vnet_nhop_routing_create(self, dpu):
results = [*dpu.process_commands(commands)]
print('======= SAI commands RETURN values create =======')
pprint(results)
assert all(results), 'Create error'

def test_vnet_nhop_routing_remove(self, dpu):
results = [*dpu.process_commands(commands, cleanup=True)]
print("\n======= SAI commands RETURN values remove =======")
pprint(results)
assert all(
[result == 'SAI_STATUS_SUCCESS' for result in results]
), 'Remove error'
52 changes: 52 additions & 0 deletions test/test-cases/scale/saic/test_sai_api_vnet_nhop_route.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from pprint import pprint

import pytest

# Constants
SWITCH_ID = 5

commands = [
{
"name": "route_entry_1",
"op": "create",
"type": "SAI_OBJECT_TYPE_ROUTE_ENTRY",
"key": {
"switch_id": "$SWITCH_ID",
"vr_id": "10",
"destination": "221.1.0.0/24"
},
"attributes": [
"SAI_ROUTE_ENTRY_ATTR_NEXT_HOP_ID",
"0"
]
},
{
"name": "route_entry_2",
"op": "create",
"type": "SAI_OBJECT_TYPE_ROUTE_ENTRY",
"key": {
"switch_id": "$SWITCH_ID",
"vr_id": "10",
"destination": "221.2.0.0/24",
},
"attributes": [
"SAI_ROUTE_ENTRY_ATTR_NEXT_HOP_ID",
"1"
]
}
]

class TestSaiVnetRoutingEntry:
def test_vnet_nhop_routing_create(self, dpu):
results = [*dpu.process_commands(commands)]
print('======= SAI commands RETURN values create =======')
pprint(results)
assert all(results), 'Create error'

def test_vnet_nhop_routing_remove(self, dpu):
results = [*dpu.process_commands(commands, cleanup=True)]
print("\n======= SAI commands RETURN values remove =======")
pprint(results)
assert all(
[result == 'SAI_STATUS_SUCCESS' for result in results]
), 'Remove error'

0 comments on commit ce534df

Please sign in to comment.