Skip to content

Commit

Permalink
adding passed cases for get set (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
selldinesh authored Sep 11, 2023
1 parent 40e09a6 commit 0a9be86
Show file tree
Hide file tree
Showing 6 changed files with 1,233 additions and 36 deletions.
44 changes: 22 additions & 22 deletions tests/api/test_acl_counter.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@

from pprint import pprint

import pytest


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'],
},
]

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):

@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',
},
"name": "acl_counter_1",
"op": "set",
"attributes": ["SAI_ACL_COUNTER_ATTR_LABEL", '""']
}
]
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'}]

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

7 changes: 1 addition & 6 deletions tests/api/test_acl_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@ def test_acl_range_create(self, npu):
pprint(results)

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

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

import pytest


class TestSaiHostifTrapGroup:
# object with no attributes
Expand All @@ -18,13 +20,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
218 changes: 216 additions & 2 deletions tests/api/test_policer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from pprint import pprint

import pytest


class TestSaiPolicer:
# object with no parents
Expand All @@ -23,13 +25,225 @@ def test_policer_create(self, npu):
print('======= SAI commands RETURN values create =======')
pprint(results)

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

@pytest.mark.dependency(depends=['test_sai_policer_attr_cbs_set'])
def test_sai_policer_attr_cbs_get(self, npu):
commands = [
{'name': 'policer_1', 'op': 'get', 'attributes': ['SAI_POLICER_ATTR_CBS']}
]
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

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

@pytest.mark.dependency(depends=['test_sai_policer_attr_cir_set'])
def test_sai_policer_attr_cir_get(self, npu):
commands = [
{'name': 'policer_1', 'op': 'get', 'attributes': ['SAI_POLICER_ATTR_CIR']}
]
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

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

@pytest.mark.dependency(depends=['test_sai_policer_attr_pbs_set'])
def test_sai_policer_attr_pbs_get(self, npu):
commands = [
{'name': 'policer_1', 'op': 'get', 'attributes': ['SAI_POLICER_ATTR_PBS']}
]
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

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

@pytest.mark.dependency(depends=['test_sai_policer_attr_pir_set'])
def test_sai_policer_attr_pir_get(self, npu):
commands = [
{'name': 'policer_1', 'op': 'get', 'attributes': ['SAI_POLICER_ATTR_PIR']}
]
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

@pytest.mark.dependency(name='test_sai_policer_attr_green_packet_action_set')
def test_sai_policer_attr_green_packet_action_set(self, npu):
commands = [
{
'name': 'policer_1',
'op': 'remove',
'op': 'set',
'attributes': [
'SAI_POLICER_ATTR_GREEN_PACKET_ACTION',
'SAI_PACKET_ACTION_FORWARD',
],
}
]
results = [*npu.process_commands(commands)]
print('======= SAI commands RETURN values get =======')
pprint(results)

@pytest.mark.dependency(depends=['test_sai_policer_attr_green_packet_action_set'])
def test_sai_policer_attr_green_packet_action_get(self, npu):
commands = [
{
'name': 'policer_1',
'op': 'get',
'attributes': ['SAI_POLICER_ATTR_GREEN_PACKET_ACTION'],
}
]
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 == 'SAI_PACKET_ACTION_FORWARD', (
'Get error, expected SAI_PACKET_ACTION_FORWARD but got %s' % r_value
)

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

@pytest.mark.dependency(depends=['test_sai_policer_attr_yellow_packet_action_set'])
def test_sai_policer_attr_yellow_packet_action_get(self, npu):
commands = [
{
'name': 'policer_1',
'op': 'get',
'attributes': ['SAI_POLICER_ATTR_YELLOW_PACKET_ACTION'],
}
]
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 == 'SAI_PACKET_ACTION_FORWARD', (
'Get error, expected SAI_PACKET_ACTION_FORWARD but got %s' % r_value
)

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

@pytest.mark.dependency(depends=['test_sai_policer_attr_red_packet_action_set'])
def test_sai_policer_attr_red_packet_action_get(self, npu):
commands = [
{
'name': 'policer_1',
'op': 'get',
'attributes': ['SAI_POLICER_ATTR_RED_PACKET_ACTION'],
}
]
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 == 'SAI_PACKET_ACTION_FORWARD', (
'Get error, expected SAI_PACKET_ACTION_FORWARD but got %s' % r_value
)


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

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

0 comments on commit 0a9be86

Please sign in to comment.