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 Test Cases for Create, Remove api Objects #94

Merged
61 changes: 61 additions & 0 deletions .github/workflows/sc-docker-standalone-bldr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: sc-docker-standalone-bldr
selldinesh marked this conversation as resolved.
Show resolved Hide resolved

on:
pull_request:
types: [ opened, synchronize, reopened ]
branches: [ "**" ]
paths:
- '.github/workflows/sc-docker-standalone-bldr.yml'
- 'dockerfiles/Dockerfile'
- 'npu/broadcom/BCM56850/saivs/Dockerfile'
- 'npu/broadcom/BCM56850/saivs/Dockerfile.saithrift'
- 'common/**'
- 'cli/**'
- 'scripts/**'
- 'configs/**'
- 'tests/**'
- 'setup.py'
- 'build.sh'
- 'run.sh'
- 'exec.sh'
- '.dockerignore'

jobs:
build-sc-stadalone-thrift:
name: Build SAI Challenger standalone image
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Update submodules
run: git submodule update --init
- name: Build standalone docker image
run: ./build.sh -i standalone
- name: Start SAI-C in standalone mode
run: ./run.sh -i standalone
- name: Wait for SAI-C services to come up
run: sleep 10s
- name: Run tests
run: ./exec.sh --no-tty pytest --testbed=saivs_standalone -v test_l2_basic.py -v test_vrf.py -v test_dc_t1.py
- name: Run sairedis tests
run: ./exec.sh --no-tty pytest --testbed=saivs_standalone -v -k "test_sairec"
- name: Run unit tests
run: ./exec.sh --no-tty pytest --testbed=saivs_standalone -v -k \
"test_acl_ut or test_bridge_ut or (test_switch_ut and not sai_map_list_t) or test_vrf_ut or test_port_ut.py"
- name: Run data-driven tests
run: ./exec.sh --no-tty pytest --testbed=saivs_standalone -v test_l2_basic_dd.py
- name: Build standalone docker image with SAI thrift
run: ./build.sh -i standalone -s thrift
- name: Start SAI-C in standalone mode with SAI thrift
run: ./run.sh -i standalone -s thrift
- name: Wait for SAI-C services to come up
run: sleep 10s
- name: Run thrift tests
run: ./exec.sh --no-tty -s thrift pytest --testbed=saivs_thrift_standalone -v test_l2_basic.py -v test_vrf.py -v test_dc_t1.py
- name: Run thift data-driven tests
run: ./exec.sh --no-tty -s thrift pytest --testbed=saivs_thrift_standalone -v test_l2_basic_dd.py
- name: Run thrift unit tests
run: ./exec.sh --no-tty -s thrift pytest --testbed=saivs_thrift_standalone -v ut/test_vrf_ut.py ut/test_bridge_ut.py ut/test_acl_ut.py
- name: Run thrift sairedis tests
run: ./exec.sh --no-tty -s thrift pytest --testbed=saivs_thrift_standalone -v -k "test_sairec"
- name: Run API tests
run: ./exec.sh --no-tty pytest --testbed=saivs_standalone -v -k "api/test"
selldinesh marked this conversation as resolved.
Show resolved Hide resolved
41 changes: 41 additions & 0 deletions tests/api/test_acl_counter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from pprint import pprint


class TestSaiAclCounter:
# object with parent SAI_OBJECT_TYPE_ACL_TABLE

def test_acl_counter_create(self, npu):
commands = [
{
'name': 'acl_table_1',
'op': 'create',
'type': 'SAI_OBJECT_TYPE_ACL_TABLE',
'attributes': ['SAI_ACL_TABLE_ATTR_ACL_STAGE', 'SAI_ACL_STAGE_INGRESS'],
},
{
'name': 'acl_counter_1',
'op': 'create',
'type': 'SAI_OBJECT_TYPE_ACL_COUNTER',
'attributes': ['SAI_ACL_COUNTER_ATTR_TABLE_ID', '$acl_table_1'],
},
]

results = [*npu.process_commands(commands)]
print('======= SAI commands RETURN values create =======')
pprint(results)

def test_acl_counter_remove(self, npu):
commands = [
{
'name': 'acl_counter_1',
'op': 'remove',
},
{
'name': 'acl_table_1',
'op': 'remove',
},
]

results = [*npu.process_commands(commands)]
print('======= SAI commands RETURN values remove =======')
pprint(results)
41 changes: 41 additions & 0 deletions tests/api/test_acl_entry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from pprint import pprint


class TestSaiAclEntry:
# object with parent SAI_OBJECT_TYPE_ACL_TABLE

def test_acl_entry_create(self, npu):
commands = [
{
'name': 'acl_table_1',
'op': 'create',
'type': 'SAI_OBJECT_TYPE_ACL_TABLE',
'attributes': ['SAI_ACL_TABLE_ATTR_ACL_STAGE', 'SAI_ACL_STAGE_INGRESS'],
},
{
'name': 'acl_entry_1',
'op': 'create',
'type': 'SAI_OBJECT_TYPE_ACL_ENTRY',
'attributes': ['SAI_ACL_ENTRY_ATTR_TABLE_ID', '$acl_table_1'],
},
]

results = [*npu.process_commands(commands)]
print('======= SAI commands RETURN values create =======')
pprint(results)

def test_acl_entry_remove(self, npu):
commands = [
{
'name': 'acl_entry_1',
'op': 'remove',
},
{
'name': 'acl_table_1',
'op': 'remove',
},
]

results = [*npu.process_commands(commands)]
print('======= SAI commands RETURN values remove =======')
pprint(results)
36 changes: 36 additions & 0 deletions tests/api/test_acl_range.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from pprint import pprint


class TestSaiAclRange:
# object with no parents

def test_acl_range_create(self, npu):
commands = [
selldinesh marked this conversation as resolved.
Show resolved Hide resolved
{
'name': 'acl_range_1',
'op': 'create',
'type': 'SAI_OBJECT_TYPE_ACL_RANGE',
'attributes': [
'SAI_ACL_RANGE_ATTR_TYPE',
'SAI_ACL_RANGE_TYPE_L4_SRC_PORT_RANGE',
'SAI_ACL_RANGE_ATTR_LIMIT',
'10,20',
],
}
]

results = [*npu.process_commands(commands)]
print('======= SAI commands RETURN values create =======')
pprint(results)

def test_acl_range_remove(self, npu):
commands = [
{
'name': 'acl_range_1',
'op': 'remove',
}
]

results = [*npu.process_commands(commands)]
print('======= SAI commands RETURN values remove =======')
pprint(results)
31 changes: 31 additions & 0 deletions tests/api/test_acl_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from pprint import pprint


class TestSaiAclTable:
# object with no parents

def test_acl_table_create(self, npu):
commands = [
{
'name': 'acl_table_1',
'op': 'create',
'type': 'SAI_OBJECT_TYPE_ACL_TABLE',
'attributes': ['SAI_ACL_TABLE_ATTR_ACL_STAGE', 'SAI_ACL_STAGE_INGRESS'],
}
]

results = [*npu.process_commands(commands)]
print('======= SAI commands RETURN values create =======')
pprint(results)

def test_acl_table_remove(self, npu):
commands = [
{
'name': 'acl_table_1',
'op': 'remove',
}
]

results = [*npu.process_commands(commands)]
print('======= SAI commands RETURN values remove =======')
pprint(results)
34 changes: 34 additions & 0 deletions tests/api/test_acl_table_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from pprint import pprint


class TestSaiAclTableGroup:
# object with no parents

def test_acl_table_group_create(self, npu):
commands = [
{
'name': 'acl_table_group_1',
'op': 'create',
'type': 'SAI_OBJECT_TYPE_ACL_TABLE_GROUP',
'attributes': [
'SAI_ACL_TABLE_GROUP_ATTR_ACL_STAGE',
'SAI_ACL_STAGE_INGRESS',
],
}
]

results = [*npu.process_commands(commands)]
print('======= SAI commands RETURN values create =======')
pprint(results)

def test_acl_table_group_remove(self, npu):
commands = [
{
'name': 'acl_table_group_1',
'op': 'remove',
}
]

results = [*npu.process_commands(commands)]
print('======= SAI commands RETURN values remove =======')
pprint(results)
61 changes: 61 additions & 0 deletions tests/api/test_acl_table_group_member.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from pprint import pprint


class TestSaiAclTableGroupMember:
# object with parent SAI_OBJECT_TYPE_ACL_TABLE_GROUP SAI_OBJECT_TYPE_ACL_TABLE

def test_acl_table_group_member_create(self, npu):
commands = [
{
'name': 'acl_table_group_1',
'op': 'create',
'type': 'SAI_OBJECT_TYPE_ACL_TABLE_GROUP',
'attributes': [
'SAI_ACL_TABLE_GROUP_ATTR_ACL_STAGE',
'SAI_ACL_STAGE_INGRESS',
],
},
{
'name': 'acl_table_1',
'op': 'create',
'type': 'SAI_OBJECT_TYPE_ACL_TABLE',
'attributes': ['SAI_ACL_TABLE_ATTR_ACL_STAGE', 'SAI_ACL_STAGE_INGRESS'],
},
{
'name': 'acl_table_group_member_1',
'op': 'create',
'type': 'SAI_OBJECT_TYPE_ACL_TABLE_GROUP_MEMBER',
'attributes': [
'SAI_ACL_TABLE_GROUP_MEMBER_ATTR_ACL_TABLE_GROUP_ID',
'$acl_table_group_1',
'SAI_ACL_TABLE_GROUP_MEMBER_ATTR_ACL_TABLE_ID',
'$acl_table_1',
'SAI_ACL_TABLE_GROUP_MEMBER_ATTR_PRIORITY',
'10',
],
},
]

results = [*npu.process_commands(commands)]
print('======= SAI commands RETURN values create =======')
pprint(results)

def test_acl_table_group_member_remove(self, npu):
commands = [
{
'name': 'acl_table_group_member_1',
'op': 'remove',
},
{
'name': 'acl_table_1',
'op': 'remove',
},
{
'name': 'acl_table_group_1',
'op': 'remove',
},
]

results = [*npu.process_commands(commands)]
print('======= SAI commands RETURN values remove =======')
pprint(results)
36 changes: 36 additions & 0 deletions tests/api/test_buffer_pool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from pprint import pprint


class TestSaiBufferPool:
# object with no parents

def test_buffer_pool_create(self, npu):
commands = [
{
'name': 'buffer_pool_1',
'op': 'create',
'type': 'SAI_OBJECT_TYPE_BUFFER_POOL',
'attributes': [
'SAI_BUFFER_POOL_ATTR_TYPE',
'SAI_BUFFER_POOL_TYPE_INGRESS',
'SAI_BUFFER_POOL_ATTR_SIZE',
'10',
],
}
]

results = [*npu.process_commands(commands)]
print('======= SAI commands RETURN values create =======')
pprint(results)

def test_buffer_pool_remove(self, npu):
commands = [
{
'name': 'buffer_pool_1',
'op': 'remove',
}
]

results = [*npu.process_commands(commands)]
print('======= SAI commands RETURN values remove =======')
pprint(results)
34 changes: 34 additions & 0 deletions tests/api/test_debug_counter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from pprint import pprint


class TestSaiDebugCounter:
# object with no parents

def test_debug_counter_create(self, npu):
commands = [
{
'name': 'debug_counter_1',
'op': 'create',
'type': 'SAI_OBJECT_TYPE_DEBUG_COUNTER',
'attributes': [
'SAI_DEBUG_COUNTER_ATTR_TYPE',
'SAI_DEBUG_COUNTER_TYPE_PORT_IN_DROP_REASONS',
],
}
]

results = [*npu.process_commands(commands)]
print('======= SAI commands RETURN values create =======')
pprint(results)

def test_debug_counter_remove(self, npu):
commands = [
{
'name': 'debug_counter_1',
'op': 'remove',
}
]

results = [*npu.process_commands(commands)]
print('======= SAI commands RETURN values remove =======')
pprint(results)
Loading