diff --git a/tests/api/test_bridge.py b/tests/api/test_bridge.py deleted file mode 100644 index 2f6115b7..00000000 --- a/tests/api/test_bridge.py +++ /dev/null @@ -1,26 +0,0 @@ -from pprint import pprint - - -class TestSaiBridge: - # object with no parents - - def test_bridge_create(self, npu): - commands = [ - { - 'name': 'bridge_1', - 'op': 'create', - 'type': 'SAI_OBJECT_TYPE_BRIDGE', - 'attributes': ['SAI_BRIDGE_ATTR_TYPE', 'SAI_BRIDGE_TYPE_1Q'], - } - ] - - results = [*npu.process_commands(commands)] - print('======= SAI commands RETURN values create =======') - pprint(results) - - def test_bridge_remove(self, npu): - commands = [{'name': 'bridge_1', 'op': 'remove'}] - - results = [*npu.process_commands(commands)] - print('======= SAI commands RETURN values remove =======') - pprint(results) diff --git a/tests/api/test_dash_acl_group.py b/tests/api/test_dash_acl_group.py deleted file mode 100644 index 071c3c54..00000000 --- a/tests/api/test_dash_acl_group.py +++ /dev/null @@ -1,26 +0,0 @@ -from pprint import pprint - - -class TestSaiDashAclGroup: - # object with no attributes - - def test_dash_acl_group_create(self, npu): - commands = [ - { - 'name': 'dash_acl_group_1', - 'op': 'create', - 'type': 'SAI_OBJECT_TYPE_DASH_ACL_GROUP', - 'attributes': [], - } - ] - - results = [*npu.process_commands(commands)] - print('======= SAI commands RETURN values create =======') - pprint(results) - - def test_dash_acl_group_remove(self, npu): - commands = [{'name': 'dash_acl_group_1', 'op': 'remove'}] - - results = [*npu.process_commands(commands)] - print('======= SAI commands RETURN values remove =======') - pprint(results) diff --git a/tests/api/test_dtel.py b/tests/api/test_dtel.py index fdd5b268..309d5563 100644 --- a/tests/api/test_dtel.py +++ b/tests/api/test_dtel.py @@ -1,6 +1,16 @@ 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 @@ -18,6 +28,188 @@ def test_dtel_create(self, npu): 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'}] diff --git a/tests/api/test_eni.py b/tests/api/test_eni.py deleted file mode 100644 index e1748159..00000000 --- a/tests/api/test_eni.py +++ /dev/null @@ -1,26 +0,0 @@ -from pprint import pprint - - -class TestSaiEni: - # object with no attributes - - def test_eni_create(self, npu): - commands = [ - { - 'name': 'eni_1', - 'op': 'create', - 'type': 'SAI_OBJECT_TYPE_ENI', - 'attributes': [], - } - ] - - results = [*npu.process_commands(commands)] - print('======= SAI commands RETURN values create =======') - pprint(results) - - def test_eni_remove(self, npu): - commands = [{'name': 'eni_1', 'op': 'remove'}] - - results = [*npu.process_commands(commands)] - print('======= SAI commands RETURN values remove =======') - pprint(results) diff --git a/tests/api/test_udf.py b/tests/api/test_udf.py index bc66c284..b89c0bc9 100644 --- a/tests/api/test_udf.py +++ b/tests/api/test_udf.py @@ -37,6 +37,42 @@ def test_udf_create(self, npu): print('======= SAI commands RETURN values create =======') pprint(results) + @pytest.mark.dependency(name="test_sai_udf_attr_base_set") + def test_sai_udf_attr_base_set(self, npu): + + commands = [ + { + "name": "udf_1", + "op": "set", + "attributes": ["SAI_UDF_ATTR_BASE", 'SAI_UDF_BASE_L2'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + pprint(results) + + + + @pytest.mark.dependency(depends=["test_sai_udf_attr_base_set"]) + def test_sai_udf_attr_base_get(self, npu): + + commands = [ + { + "name": "udf_1", + "op": "get", + "attributes": ["SAI_UDF_ATTR_BASE"] + } + ] + 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_UDF_BASE_L2', 'Get error, expected SAI_UDF_BASE_L2 but got %s' % r_value + + def test_udf_remove(self, npu): commands = [ {'name': 'udf_1', 'op': 'remove'},