Skip to content
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
52 changes: 52 additions & 0 deletions tests/api/test_acl_entry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from pprint import pprint

import pytest


class TestSaiAclEntry:
# object with parent SAI_OBJECT_TYPE_ACL_TABLE

@pytest.mark.dependency(scope='session')
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)
assert all(results), 'Create error'

def test_acl_entry_remove(self, npu):
commands = [
{
'name': 'acl_entry_1',
'op': 'remove',
'type': 'SAI_OBJECT_TYPE_ACL_ENTRY',
'attributes': ['SAI_ACL_ENTRY_ATTR_TABLE_ID', '$acl_table_1'],
},
{
'name': 'acl_table_1',
'op': 'remove',
'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 remove =======')
pprint(results)
assert all(
[result == 'SAI_STATUS_SUCCESS' for result in results]
), 'Remove error'
50 changes: 50 additions & 0 deletions tests/api/test_acl_range.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from pprint import pprint

import pytest


class TestSaiAclRange:
# object with no parents

@pytest.mark.dependency(scope='session')
def test_acl_range_create(self, npu):
commands = [
{
'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)
assert all(results), 'Create error'

def test_acl_range_remove(self, npu):
commands = [
{
'name': 'acl_range_1',
'op': 'remove',
'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 remove =======')
pprint(results)
assert all(
[result == 'SAI_STATUS_SUCCESS' for result in results]
), 'Remove error'
84 changes: 84 additions & 0 deletions tests/api/test_acl_table_group_member.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
from pprint import pprint

import pytest


class TestSaiAclTableGroupMember:
# object with parent SAI_OBJECT_TYPE_ACL_TABLE_GROUP SAI_OBJECT_TYPE_ACL_TABLE

@pytest.mark.dependency(scope='session')
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)
assert all(results), 'Create error'

def test_acl_table_group_member_remove(self, npu):
commands = [
{
'name': 'acl_table_group_member_1',
'op': 'remove',
'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',
],
},
{
'name': 'acl_table_1',
'op': 'remove',
'type': 'SAI_OBJECT_TYPE_ACL_TABLE',
'attributes': ['SAI_ACL_TABLE_ATTR_ACL_STAGE', 'SAI_ACL_STAGE_INGRESS'],
},
{
'name': 'acl_table_group_1',
'op': 'remove',
'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 remove =======')
pprint(results)
assert all(
[result == 'SAI_STATUS_SUCCESS' for result in results]
), 'Remove error'