-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding API test cases for a bunch of SAI objects (#187)
Signed-off-by: selldinesh <[email protected]>
- Loading branch information
1 parent
2d357dc
commit 9ca9f7d
Showing
18 changed files
with
760 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from pprint import pprint | ||
|
||
|
||
class TestSaiArs: | ||
# object with no attributes | ||
|
||
def test_ars_create(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'ars_1', | ||
'op': 'create', | ||
'type': 'SAI_OBJECT_TYPE_ARS', | ||
'attributes': [], | ||
} | ||
] | ||
|
||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values create =======') | ||
pprint(results) | ||
|
||
def test_ars_remove(self, npu): | ||
commands = [{'name': 'ars_1', 'op': 'remove'}] | ||
|
||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values remove =======') | ||
pprint(results) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from pprint import pprint | ||
|
||
|
||
class TestSaiArsProfile: | ||
# object with no attributes | ||
|
||
def test_ars_profile_create(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'ars_profile_1', | ||
'op': 'create', | ||
'type': 'SAI_OBJECT_TYPE_ARS_PROFILE', | ||
'attributes': [], | ||
} | ||
] | ||
|
||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values create =======') | ||
pprint(results) | ||
|
||
def test_ars_profile_remove(self, npu): | ||
commands = [{'name': 'ars_profile_1', 'op': 'remove'}] | ||
|
||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values remove =======') | ||
pprint(results) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from pprint import pprint | ||
|
||
|
||
class TestSaiCounter: | ||
# object with no attributes | ||
|
||
def test_counter_create(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'counter_1', | ||
'op': 'create', | ||
'type': 'SAI_OBJECT_TYPE_COUNTER', | ||
'attributes': [], | ||
} | ||
] | ||
|
||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values create =======') | ||
pprint(results) | ||
|
||
def test_counter_remove(self, npu): | ||
commands = [{'name': 'counter_1', 'op': 'remove'}] | ||
|
||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values remove =======') | ||
pprint(results) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,218 @@ | ||
from pprint import pprint | ||
|
||
import pytest | ||
|
||
|
||
@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 TestSaiDtel: | ||
# object with no attributes | ||
|
||
def test_dtel_create(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'dtel_1', | ||
'op': 'create', | ||
'type': 'SAI_OBJECT_TYPE_DTEL', | ||
'attributes': [], | ||
} | ||
] | ||
|
||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values create =======') | ||
pprint(results) | ||
|
||
@pytest.mark.dependency(name='test_sai_dtel_attr_postcard_enable_set') | ||
def test_sai_dtel_attr_postcard_enable_set(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'dtel_1', | ||
'op': 'set', | ||
'attributes': ['SAI_DTEL_ATTR_POSTCARD_ENABLE', 'false'], | ||
} | ||
] | ||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values set =======') | ||
pprint(results) | ||
|
||
@pytest.mark.dependency(depends=['test_sai_dtel_attr_postcard_enable_set']) | ||
def test_sai_dtel_attr_postcard_enable_get(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'dtel_1', | ||
'op': 'get', | ||
'attributes': ['SAI_DTEL_ATTR_POSTCARD_ENABLE'], | ||
} | ||
] | ||
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 | ||
|
||
@pytest.mark.dependency(name='test_sai_dtel_attr_drop_report_enable_set') | ||
def test_sai_dtel_attr_drop_report_enable_set(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'dtel_1', | ||
'op': 'set', | ||
'attributes': ['SAI_DTEL_ATTR_DROP_REPORT_ENABLE', 'false'], | ||
} | ||
] | ||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values set =======') | ||
pprint(results) | ||
|
||
@pytest.mark.dependency(depends=['test_sai_dtel_attr_drop_report_enable_set']) | ||
def test_sai_dtel_attr_drop_report_enable_get(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'dtel_1', | ||
'op': 'get', | ||
'attributes': ['SAI_DTEL_ATTR_DROP_REPORT_ENABLE'], | ||
} | ||
] | ||
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 | ||
|
||
@pytest.mark.dependency(name='test_sai_dtel_attr_queue_report_enable_set') | ||
def test_sai_dtel_attr_queue_report_enable_set(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'dtel_1', | ||
'op': 'set', | ||
'attributes': ['SAI_DTEL_ATTR_QUEUE_REPORT_ENABLE', 'false'], | ||
} | ||
] | ||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values set =======') | ||
pprint(results) | ||
|
||
@pytest.mark.dependency(depends=['test_sai_dtel_attr_queue_report_enable_set']) | ||
def test_sai_dtel_attr_queue_report_enable_get(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'dtel_1', | ||
'op': 'get', | ||
'attributes': ['SAI_DTEL_ATTR_QUEUE_REPORT_ENABLE'], | ||
} | ||
] | ||
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 | ||
|
||
@pytest.mark.dependency(name='test_sai_dtel_attr_switch_id_set') | ||
def test_sai_dtel_attr_switch_id_set(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'dtel_1', | ||
'op': 'set', | ||
'attributes': ['SAI_DTEL_ATTR_SWITCH_ID', '0'], | ||
} | ||
] | ||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values set =======') | ||
pprint(results) | ||
|
||
@pytest.mark.dependency(depends=['test_sai_dtel_attr_switch_id_set']) | ||
def test_sai_dtel_attr_switch_id_get(self, npu): | ||
commands = [ | ||
{'name': 'dtel_1', 'op': 'get', 'attributes': ['SAI_DTEL_ATTR_SWITCH_ID']} | ||
] | ||
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_dtel_attr_flow_state_clear_cycle_set') | ||
def test_sai_dtel_attr_flow_state_clear_cycle_set(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'dtel_1', | ||
'op': 'set', | ||
'attributes': ['SAI_DTEL_ATTR_FLOW_STATE_CLEAR_CYCLE', '0'], | ||
} | ||
] | ||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values set =======') | ||
pprint(results) | ||
|
||
@pytest.mark.dependency(depends=['test_sai_dtel_attr_flow_state_clear_cycle_set']) | ||
def test_sai_dtel_attr_flow_state_clear_cycle_get(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'dtel_1', | ||
'op': 'get', | ||
'attributes': ['SAI_DTEL_ATTR_FLOW_STATE_CLEAR_CYCLE'], | ||
} | ||
] | ||
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_dtel_attr_latency_sensitivity_set') | ||
def test_sai_dtel_attr_latency_sensitivity_set(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'dtel_1', | ||
'op': 'set', | ||
'attributes': ['SAI_DTEL_ATTR_LATENCY_SENSITIVITY', '0'], | ||
} | ||
] | ||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values set =======') | ||
pprint(results) | ||
|
||
@pytest.mark.dependency(depends=['test_sai_dtel_attr_latency_sensitivity_set']) | ||
def test_sai_dtel_attr_latency_sensitivity_get(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'dtel_1', | ||
'op': 'get', | ||
'attributes': ['SAI_DTEL_ATTR_LATENCY_SENSITIVITY'], | ||
} | ||
] | ||
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_dtel_remove(self, npu): | ||
commands = [{'name': 'dtel_1', 'op': 'remove'}] | ||
|
||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values remove =======') | ||
pprint(results) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from pprint import pprint | ||
|
||
|
||
class TestSaiDtelEvent: | ||
# object with no parents | ||
|
||
def test_dtel_event_create(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'dtel_event_1', | ||
'op': 'create', | ||
'type': 'SAI_OBJECT_TYPE_DTEL_EVENT', | ||
'attributes': [ | ||
'SAI_DTEL_EVENT_ATTR_TYPE', | ||
'SAI_DTEL_EVENT_TYPE_FLOW_STATE', | ||
], | ||
} | ||
] | ||
|
||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values create =======') | ||
pprint(results) | ||
|
||
def test_dtel_event_remove(self, npu): | ||
commands = [{'name': 'dtel_event_1', 'op': 'remove'}] | ||
|
||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values remove =======') | ||
pprint(results) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from pprint import pprint | ||
|
||
|
||
class TestSaiDtelIntSession: | ||
# object with no attributes | ||
|
||
def test_dtel_int_session_create(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'dtel_int_session_1', | ||
'op': 'create', | ||
'type': 'SAI_OBJECT_TYPE_DTEL_INT_SESSION', | ||
'attributes': [], | ||
} | ||
] | ||
|
||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values create =======') | ||
pprint(results) | ||
|
||
def test_dtel_int_session_remove(self, npu): | ||
commands = [{'name': 'dtel_int_session_1', 'op': 'remove'}] | ||
|
||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values remove =======') | ||
pprint(results) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from pprint import pprint | ||
|
||
|
||
class TestSaiDtelReportSession: | ||
# object with no attributes | ||
|
||
def test_dtel_report_session_create(self, npu): | ||
commands = [ | ||
{ | ||
'name': 'dtel_report_session_1', | ||
'op': 'create', | ||
'type': 'SAI_OBJECT_TYPE_DTEL_REPORT_SESSION', | ||
'attributes': [], | ||
} | ||
] | ||
|
||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values create =======') | ||
pprint(results) | ||
|
||
def test_dtel_report_session_remove(self, npu): | ||
commands = [{'name': 'dtel_report_session_1', 'op': 'remove'}] | ||
|
||
results = [*npu.process_commands(commands)] | ||
print('======= SAI commands RETURN values remove =======') | ||
pprint(results) |
Oops, something went wrong.