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 Get, Set on the Api Attributes #228

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
39 changes: 31 additions & 8 deletions tests/api/test_acl_counter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
from pprint import pprint

import pytest


@pytest.fixture(scope="module", autouse=True)
def discovery(npu):
npu.objects_discovery()


@pytest.fixture(scope="module", autouse=True)
def skip_all(testbed_instance):
testbed = testbed_instance
if testbed is not None and len(testbed.npu) != 1:
pytest.skip("invalid for {} testbed".format(testbed.name))


@pytest.mark.npu
class TestSaiAclCounter:
# object with parent SAI_OBJECT_TYPE_ACL_TABLE

Expand All @@ -19,23 +34,31 @@ def test_acl_counter_create(self, npu):
'attributes': ['SAI_ACL_COUNTER_ATTR_TABLE_ID', '$acl_table_1'],
},
]

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

def test_acl_counter_remove(self, npu):
@pytest.mark.dependency(name='test_sai_acl_counter_attr_label_set')
def test_sai_acl_counter_attr_label_set(self, npu):
commands = [
{
'name': 'acl_counter_1',
'op': 'remove',
},
{
'name': 'acl_table_1',
'op': 'remove',
},
'op': 'set',
'attributes': ['SAI_ACL_COUNTER_ATTR_LABEL', '""'],
}
]
npu.objects_discovery()
results = [*npu.process_commands(commands)]
print('======= SAI commands RETURN values get =======')
pprint(results)

def test_acl_counter_remove(self, npu):
commands = [
{'name': 'acl_counter_1', 'op': 'remove'},
{'name': 'acl_table_1', 'op': 'remove'},
]
npu.objects_discovery()
results = [*npu.process_commands(commands)]
print('======= SAI commands RETURN values remove =======')
pprint(results)
75 changes: 73 additions & 2 deletions tests/api/test_hostif_trap_group.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
from pprint import pprint

import pytest


@pytest.fixture(scope="module", autouse=True)
def discovery(npu):
npu.objects_discovery()


@pytest.fixture(scope="module", autouse=True)
def skip_all(testbed_instance):
testbed = testbed_instance
if testbed is not None and len(testbed.npu) != 1:
pytest.skip("invalid for {} testbed".format(testbed.name))


class TestSaiHostifTrapGroup:
# object with no attributes
Expand All @@ -18,13 +32,70 @@ def test_hostif_trap_group_create(self, npu):
print('======= SAI commands RETURN values create =======')
pprint(results)

def test_hostif_trap_group_remove(self, npu):
@pytest.mark.dependency(name='test_sai_hostif_trap_group_attr_admin_state_set')
def test_sai_hostif_trap_group_attr_admin_state_set(self, npu):
commands = [
{
'name': 'hostif_trap_group_1',
'op': 'set',
'attributes': ['SAI_HOSTIF_TRAP_GROUP_ATTR_ADMIN_STATE', 'true'],
}
]
results = [*npu.process_commands(commands)]
print('======= SAI commands RETURN values get =======')
pprint(results)

@pytest.mark.dependency(depends=['test_sai_hostif_trap_group_attr_admin_state_set'])
def test_sai_hostif_trap_group_attr_admin_state_get(self, npu):
commands = [
{
'name': 'hostif_trap_group_1',
'op': 'get',
'attributes': ['SAI_HOSTIF_TRAP_GROUP_ATTR_ADMIN_STATE'],
}
]
results = [*npu.process_commands(commands)]
print('======= SAI commands RETURN values get =======')
for command in results:
for attribute in command:
pprint(attribute.raw())
r_value = results[0][0].value()
print(r_value)
assert r_value == 'true', 'Get error, expected true but got %s' % r_value

@pytest.mark.dependency(name='test_sai_hostif_trap_group_attr_queue_set')
def test_sai_hostif_trap_group_attr_queue_set(self, npu):
commands = [
{
'name': 'hostif_trap_group_1',
'op': 'set',
'attributes': ['SAI_HOSTIF_TRAP_GROUP_ATTR_QUEUE', '0'],
}
]
results = [*npu.process_commands(commands)]
print('======= SAI commands RETURN values get =======')
pprint(results)

@pytest.mark.dependency(depends=['test_sai_hostif_trap_group_attr_queue_set'])
def test_sai_hostif_trap_group_attr_queue_get(self, npu):
commands = [
{
'name': 'hostif_trap_group_1',
'op': 'remove',
'op': 'get',
'attributes': ['SAI_HOSTIF_TRAP_GROUP_ATTR_QUEUE'],
}
]
results = [*npu.process_commands(commands)]
print('======= SAI commands RETURN values get =======')
for command in results:
for attribute in command:
pprint(attribute.raw())
r_value = results[0][0].value()
print(r_value)
assert r_value == '0', 'Get error, expected 0 but got %s' % r_value

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

results = [*npu.process_commands(commands)]
print('======= SAI commands RETURN values remove =======')
Expand Down
65 changes: 53 additions & 12 deletions tests/api/test_next_hop_group.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,75 @@

from pprint import pprint

import pytest


@pytest.fixture(scope="module", autouse=True)
def discovery(npu):
npu.objects_discovery()


@pytest.fixture(scope="module", autouse=True)
def skip_all(testbed_instance):
testbed = testbed_instance
if testbed is not None and len(testbed.npu) != 1:
pytest.skip("invalid for {} testbed".format(testbed.name))


@pytest.mark.npu
class TestSaiNextHopGroup:
# object with no parents

def test_next_hop_group_create(self, npu):

commands = [{'name': 'next_hop_group_1', 'op': 'create', 'type': 'SAI_OBJECT_TYPE_NEXT_HOP_GROUP', 'attributes': ['SAI_NEXT_HOP_GROUP_ATTR_TYPE', 'SAI_NEXT_HOP_GROUP_TYPE_DYNAMIC_UNORDERED_ECMP']}]

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


@pytest.mark.dependency(name="test_sai_next_hop_group_attr_set_switchover_set")
def test_sai_next_hop_group_attr_set_switchover_set(self, npu):

commands = [
{
'name': 'next_hop_group_1',
'op': 'create',
'type': 'SAI_OBJECT_TYPE_NEXT_HOP_GROUP',
'attributes': [
'SAI_NEXT_HOP_GROUP_ATTR_TYPE',
'SAI_NEXT_HOP_GROUP_TYPE_DYNAMIC_UNORDERED_ECMP',
],
"name": "next_hop_group_1",
"op": "set",
"attributes": ["SAI_NEXT_HOP_GROUP_ATTR_SET_SWITCHOVER", 'false']
}
]

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

def test_next_hop_group_remove(self, npu):


@pytest.mark.dependency(depends=["test_sai_next_hop_group_attr_set_switchover_set"])
def test_sai_next_hop_group_attr_set_switchover_get(self, npu):

commands = [
{
'name': 'next_hop_group_1',
'op': 'remove',
"name": "next_hop_group_1",
"op": "get",
"attributes": ["SAI_NEXT_HOP_GROUP_ATTR_SET_SWITCHOVER"]
}
]
results = [*npu.process_commands(commands)]
print("======= SAI commands RETURN values get =======")
for command in results:
for attribute in command:
pprint(attribute.raw())
r_value = results[0][0].value()
print(r_value)
assert r_value == 'false', 'Get error, expected false but got %s' % r_value


def test_next_hop_group_remove(self, npu):

commands = [{'name': 'next_hop_group_1', 'op': 'remove'}]

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

Loading
Loading