diff --git a/tests/api/test_acl_counter.py b/tests/api/test_acl_counter.py index fb65afe3..3e343fb5 100644 --- a/tests/api/test_acl_counter.py +++ b/tests/api/test_acl_counter.py @@ -1,6 +1,14 @@ from pprint import pprint +@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 diff --git a/tests/api/test_acl_entry.py b/tests/api/test_acl_entry.py index 3bef4673..9fa514e5 100644 --- a/tests/api/test_acl_entry.py +++ b/tests/api/test_acl_entry.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 TestSaiAclEntry: # object with parent SAI_OBJECT_TYPE_ACL_TABLE diff --git a/tests/api/test_acl_range.py b/tests/api/test_acl_range.py index 3bdc5779..711fba0e 100644 --- a/tests/api/test_acl_range.py +++ b/tests/api/test_acl_range.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 TestSaiAclRange: # object with no parents diff --git a/tests/api/test_acl_table.py b/tests/api/test_acl_table.py index 707d1919..e847598a 100644 --- a/tests/api/test_acl_table.py +++ b/tests/api/test_acl_table.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 TestSaiAclTable: # object with no parents diff --git a/tests/api/test_acl_table_group.py b/tests/api/test_acl_table_group.py index 27d0928b..54598f98 100644 --- a/tests/api/test_acl_table_group.py +++ b/tests/api/test_acl_table_group.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 TestSaiAclTableGroup: # object with no parents diff --git a/tests/api/test_acl_table_group_member.py b/tests/api/test_acl_table_group_member.py index e1f717b6..bfe678a0 100644 --- a/tests/api/test_acl_table_group_member.py +++ b/tests/api/test_acl_table_group_member.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 TestSaiAclTableGroupMember: # object with parent SAI_OBJECT_TYPE_ACL_TABLE_GROUP SAI_OBJECT_TYPE_ACL_TABLE diff --git a/tests/api/test_ars.py b/tests/api/test_ars.py new file mode 100644 index 00000000..1a0d22da --- /dev/null +++ b/tests/api/test_ars.py @@ -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) diff --git a/tests/api/test_ars_profile.py b/tests/api/test_ars_profile.py new file mode 100644 index 00000000..0d45f96e --- /dev/null +++ b/tests/api/test_ars_profile.py @@ -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) diff --git a/tests/api/test_buffer_pool.py b/tests/api/test_buffer_pool.py index 9584ee11..2114394e 100644 --- a/tests/api/test_buffer_pool.py +++ b/tests/api/test_buffer_pool.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 TestSaiBufferPool: # object with no parents diff --git a/tests/api/test_buffer_profile.py b/tests/api/test_buffer_profile.py new file mode 100644 index 00000000..b938c8c1 --- /dev/null +++ b/tests/api/test_buffer_profile.py @@ -0,0 +1,51 @@ +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 TestSaiBufferProfile: + # object with parent SAI_OBJECT_TYPE_BUFFER_POOL + + def test_buffer_profile_create(self, npu): + commands = [ + { + 'name': 'buffer_pool_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_BUFFER_POOL', + 'attributes': [ + 'SAI_BUFFER_POOL_ATTR_TYPE', + 'SAI_BUFFER_POOL_TYPE_INGRESS', + 'SAI_BUFFER_POOL_ATTR_SIZE', + '10', + ], + }, + { + 'name': 'buffer_profile_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_BUFFER_PROFILE', + 'attributes': [ + 'SAI_BUFFER_PROFILE_ATTR_POOL_ID', + '$buffer_pool_1', + 'SAI_BUFFER_PROFILE_ATTR_RESERVED_BUFFER_SIZE', + '10', + 'SAI_BUFFER_PROFILE_ATTR_THRESHOLD_MODE', + 'SAI_BUFFER_PROFILE_THRESHOLD_MODE_STATIC', + 'SAI_BUFFER_PROFILE_ATTR_SHARED_DYNAMIC_TH', + '1', + 'SAI_BUFFER_PROFILE_ATTR_SHARED_STATIC_TH', + '10', + ], + }, + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) diff --git a/tests/api/test_counter.py b/tests/api/test_counter.py new file mode 100644 index 00000000..2e3ac1c5 --- /dev/null +++ b/tests/api/test_counter.py @@ -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) diff --git a/tests/api/test_debug_counter.py b/tests/api/test_debug_counter.py index d4c566a3..1f41734d 100644 --- a/tests/api/test_debug_counter.py +++ b/tests/api/test_debug_counter.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 TestSaiDebugCounter: # object with no parents diff --git a/tests/api/test_dtel.py b/tests/api/test_dtel.py new file mode 100644 index 00000000..309d5563 --- /dev/null +++ b/tests/api/test_dtel.py @@ -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) diff --git a/tests/api/test_dtel_event.py b/tests/api/test_dtel_event.py new file mode 100644 index 00000000..2b6b2778 --- /dev/null +++ b/tests/api/test_dtel_event.py @@ -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) diff --git a/tests/api/test_dtel_int_session.py b/tests/api/test_dtel_int_session.py new file mode 100644 index 00000000..0a2b9651 --- /dev/null +++ b/tests/api/test_dtel_int_session.py @@ -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) diff --git a/tests/api/test_dtel_report_session.py b/tests/api/test_dtel_report_session.py new file mode 100644 index 00000000..6369606c --- /dev/null +++ b/tests/api/test_dtel_report_session.py @@ -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) diff --git a/tests/api/test_generic_programmable.py b/tests/api/test_generic_programmable.py new file mode 100644 index 00000000..8dbccde9 --- /dev/null +++ b/tests/api/test_generic_programmable.py @@ -0,0 +1,26 @@ +from pprint import pprint + + +class TestSaiGenericProgrammable: + # object with no parents + + def test_generic_programmable_create(self, npu): + commands = [ + { + 'name': 'generic_programmable_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_GENERIC_PROGRAMMABLE', + 'attributes': ['SAI_GENERIC_PROGRAMMABLE_ATTR_OBJECT_NAME', '2:10,11'], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_generic_programmable_remove(self, npu): + commands = [{'name': 'generic_programmable_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_hash.py b/tests/api/test_hash.py new file mode 100644 index 00000000..38b9e658 --- /dev/null +++ b/tests/api/test_hash.py @@ -0,0 +1,26 @@ +from pprint import pprint + + +class TestSaiHash: + # object with no attributes + + def test_hash_create(self, npu): + commands = [ + { + 'name': 'hash_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_HASH', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_hash_remove(self, npu): + commands = [{'name': 'hash_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_hostif.py b/tests/api/test_hostif.py new file mode 100644 index 00000000..2382e367 --- /dev/null +++ b/tests/api/test_hostif.py @@ -0,0 +1,150 @@ +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 TestSaiHostif: + # object with parent SAI_OBJECT_TYPE_PORT SAI_OBJECT_TYPE_LAG SAI_OBJECT_TYPE_VLAN SAI_OBJECT_TYPE_SYSTEM_PORT + + def test_hostif_create(self, npu): + commands = [ + { + 'name': 'port_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_PORT', + 'attributes': [ + 'SAI_PORT_ATTR_HW_LANE_LIST', + '2:10,11', + 'SAI_PORT_ATTR_SPEED', + '10', + ], + }, + { + 'name': 'hostif_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_HOSTIF', + 'attributes': [ + 'SAI_HOSTIF_ATTR_TYPE', + 'SAI_HOSTIF_TYPE_NETDEV', + 'SAI_HOSTIF_ATTR_OBJ_ID', + '$port_1', + 'SAI_HOSTIF_ATTR_NAME', + 'inbound', + 'SAI_HOSTIF_ATTR_GENETLINK_MCGRP_NAME', + 'inbound', + ], + }, + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + @pytest.mark.dependency(name='test_sai_hostif_attr_oper_status_set') + def test_sai_hostif_attr_oper_status_set(self, npu): + commands = [ + { + 'name': 'hostif_1', + 'op': 'set', + 'attributes': ['SAI_HOSTIF_ATTR_OPER_STATUS', 'false'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values set =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_hostif_attr_oper_status_set']) + def test_sai_hostif_attr_oper_status_get(self, npu): + commands = [ + { + 'name': 'hostif_1', + 'op': 'get', + 'attributes': ['SAI_HOSTIF_ATTR_OPER_STATUS'], + } + ] + 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_hostif_attr_queue_set') + def test_sai_hostif_attr_queue_set(self, npu): + commands = [ + { + 'name': 'hostif_1', + 'op': 'set', + 'attributes': ['SAI_HOSTIF_ATTR_QUEUE', '0'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values set =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_hostif_attr_queue_set']) + def test_sai_hostif_attr_queue_get(self, npu): + commands = [ + {'name': 'hostif_1', 'op': 'get', 'attributes': ['SAI_HOSTIF_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 + + @pytest.mark.dependency(name='test_sai_hostif_attr_vlan_tag_set') + def test_sai_hostif_attr_vlan_tag_set(self, npu): + commands = [ + { + 'name': 'hostif_1', + 'op': 'set', + 'attributes': ['SAI_HOSTIF_ATTR_VLAN_TAG', 'SAI_HOSTIF_VLAN_TAG_STRIP'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values set =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_hostif_attr_vlan_tag_set']) + def test_sai_hostif_attr_vlan_tag_get(self, npu): + commands = [ + { + 'name': 'hostif_1', + 'op': 'get', + 'attributes': ['SAI_HOSTIF_ATTR_VLAN_TAG'], + } + ] + 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_HOSTIF_VLAN_TAG_STRIP', ( + 'Get error, expected SAI_HOSTIF_VLAN_TAG_STRIP but got %s' % r_value + ) + + def test_hostif_remove(self, npu): + commands = [ + {'name': 'hostif_1', 'op': 'remove'}, + {'name': 'port_1', 'op': 'remove'}, + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_hostif_trap.py b/tests/api/test_hostif_trap.py index 78f1def6..fbc8e33d 100644 --- a/tests/api/test_hostif_trap.py +++ b/tests/api/test_hostif_trap.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 TestSaiHostifTrap: # object with no parent objects diff --git a/tests/api/test_hostif_trap_group.py b/tests/api/test_hostif_trap_group.py index ce6db62f..24a21f1c 100644 --- a/tests/api/test_hostif_trap_group.py +++ b/tests/api/test_hostif_trap_group.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 TestSaiHostifTrapGroup: # object with no attributes diff --git a/tests/api/test_ipmc_group.py b/tests/api/test_ipmc_group.py index 7879ac80..520b329a 100644 --- a/tests/api/test_ipmc_group.py +++ b/tests/api/test_ipmc_group.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 TestSaiIpmcGroup: # object with no attributes diff --git a/tests/api/test_isolation_group.py b/tests/api/test_isolation_group.py index f8fd750f..9db00002 100644 --- a/tests/api/test_isolation_group.py +++ b/tests/api/test_isolation_group.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 TestSaiIsolationGroup: # object with no parents diff --git a/tests/api/test_isolation_group_member.py b/tests/api/test_isolation_group_member.py new file mode 100644 index 00000000..9ba07047 --- /dev/null +++ b/tests/api/test_isolation_group_member.py @@ -0,0 +1,64 @@ +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 TestSaiIsolationGroupMember: + # object with parent SAI_OBJECT_TYPE_ISOLATION_GROUP SAI_OBJECT_TYPE_PORT SAI_OBJECT_TYPE_BRIDGE_PORT + + def test_isolation_group_member_create(self, npu): + commands = [ + { + 'name': 'isolation_group_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_ISOLATION_GROUP', + 'attributes': [ + 'SAI_ISOLATION_GROUP_ATTR_TYPE', + 'SAI_ISOLATION_GROUP_TYPE_PORT', + ], + }, + { + 'name': 'port_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_PORT', + 'attributes': [ + 'SAI_PORT_ATTR_HW_LANE_LIST', + '2:10,11', + 'SAI_PORT_ATTR_SPEED', + '10', + ], + }, + { + 'name': 'isolation_group_member_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_ISOLATION_GROUP_MEMBER', + 'attributes': [ + 'SAI_ISOLATION_GROUP_MEMBER_ATTR_ISOLATION_GROUP_ID', + '$isolation_group_1', + 'SAI_ISOLATION_GROUP_MEMBER_ATTR_ISOLATION_OBJECT', + '$port_1', + ], + }, + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_isolation_group_member_remove(self, npu): + commands = [ + {'name': 'isolation_group_member_1', 'op': 'remove'}, + {'name': 'isolation_group_1', 'op': 'remove'}, + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_l2mc_group.py b/tests/api/test_l2mc_group.py new file mode 100644 index 00000000..1f05f0f4 --- /dev/null +++ b/tests/api/test_l2mc_group.py @@ -0,0 +1,26 @@ +from pprint import pprint + + +class TestSaiL2McGroup: + # object with no attributes + + def test_l2mc_group_create(self, npu): + commands = [ + { + 'name': 'l2mc_group_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_L2MC_GROUP', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_l2mc_group_remove(self, npu): + commands = [{'name': 'l2mc_group_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_lag.py b/tests/api/test_lag.py index 2b231d62..893da9bf 100644 --- a/tests/api/test_lag.py +++ b/tests/api/test_lag.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 TestSaiLag: # object with no attributes diff --git a/tests/api/test_lag_member.py b/tests/api/test_lag_member.py new file mode 100644 index 00000000..7311a0bc --- /dev/null +++ b/tests/api/test_lag_member.py @@ -0,0 +1,90 @@ +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 TestSaiLagMember: + # object with parent SAI_OBJECT_TYPE_LAG SAI_OBJECT_TYPE_PORT SAI_OBJECT_TYPE_SYSTEM_PORT + + def test_lag_member_create(self, npu): + commands = [ + { + 'name': 'lag_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_LAG', + 'attributes': [], + }, + { + 'name': 'port_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_PORT', + 'attributes': [ + 'SAI_PORT_ATTR_HW_LANE_LIST', + '2:10,11', + 'SAI_PORT_ATTR_SPEED', + '10', + ], + }, + { + 'name': 'lag_member_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_LAG_MEMBER', + 'attributes': [ + 'SAI_LAG_MEMBER_ATTR_LAG_ID', + '$lag_1', + 'SAI_LAG_MEMBER_ATTR_PORT_ID', + '$port_1', + ], + }, + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + @pytest.mark.dependency(name='test_sai_lag_member_attr_egress_disable_set') + def test_sai_lag_member_attr_egress_disable_set(self, npu): + commands = [ + { + 'name': 'lag_member_1', + 'op': 'set', + 'attributes': ['SAI_LAG_MEMBER_ATTR_EGRESS_DISABLE', 'false'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values set =======') + pprint(results) + + + @pytest.mark.dependency(name='test_sai_lag_member_attr_ingress_disable_set') + def test_sai_lag_member_attr_ingress_disable_set(self, npu): + commands = [ + { + 'name': 'lag_member_1', + 'op': 'set', + 'attributes': ['SAI_LAG_MEMBER_ATTR_INGRESS_DISABLE', 'false'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values set =======') + pprint(results) + + + def test_lag_member_remove(self, npu): + commands = [ + {'name': 'lag_member_1', 'op': 'remove'}, + {'name': 'port_1', 'op': 'remove'}, + {'name': 'lag_1', 'op': 'remove'}, + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_macsec.py b/tests/api/test_macsec.py new file mode 100644 index 00000000..b1b66dd7 --- /dev/null +++ b/tests/api/test_macsec.py @@ -0,0 +1,29 @@ +from pprint import pprint + + +class TestSaiMacsec: + # object with no parents + + def test_macsec_create(self, npu): + commands = [ + { + 'name': 'macsec_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_MACSEC', + 'attributes': [ + 'SAI_MACSEC_ATTR_DIRECTION', + 'SAI_MACSEC_DIRECTION_EGRESS', + ], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_macsec_remove(self, npu): + commands = [{'name': 'macsec_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_macsec_flow.py b/tests/api/test_macsec_flow.py new file mode 100644 index 00000000..acb9b49c --- /dev/null +++ b/tests/api/test_macsec_flow.py @@ -0,0 +1,29 @@ +from pprint import pprint + + +class TestSaiMacsecFlow: + # object with no parents + + def test_macsec_flow_create(self, npu): + commands = [ + { + 'name': 'macsec_flow_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_MACSEC_FLOW', + 'attributes': [ + 'SAI_MACSEC_FLOW_ATTR_MACSEC_DIRECTION', + 'SAI_MACSEC_DIRECTION_EGRESS', + ], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_macsec_flow_remove(self, npu): + commands = [{'name': 'macsec_flow_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_my_mac.py b/tests/api/test_my_mac.py new file mode 100644 index 00000000..a626f71d --- /dev/null +++ b/tests/api/test_my_mac.py @@ -0,0 +1,36 @@ +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 TestSaiMyMac: + # object with no attributes + + def test_my_mac_create(self, npu): + commands = [ + { + 'name': 'my_mac_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_MY_MAC', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_my_mac_remove(self, npu): + commands = [{'name': 'my_mac_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_nat_zone_counter.py b/tests/api/test_nat_zone_counter.py new file mode 100644 index 00000000..7c17626e --- /dev/null +++ b/tests/api/test_nat_zone_counter.py @@ -0,0 +1,26 @@ +from pprint import pprint + + +class TestSaiNatZoneCounter: + # object with no attributes + + def test_nat_zone_counter_create(self, npu): + commands = [ + { + 'name': 'nat_zone_counter_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_NAT_ZONE_COUNTER', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_nat_zone_counter_remove(self, npu): + commands = [{'name': 'nat_zone_counter_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_next_hop_group.py b/tests/api/test_next_hop_group.py index d20c3c58..66dcbc4a 100644 --- a/tests/api/test_next_hop_group.py +++ b/tests/api/test_next_hop_group.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 TestSaiNextHopGroup: # object with no parents @@ -21,13 +31,23 @@ def test_next_hop_group_create(self, npu): print('======= SAI commands RETURN values create =======') pprint(results) - def test_next_hop_group_remove(self, npu): + + @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': 'remove', + 'op': 'set', + 'attributes': ['SAI_NEXT_HOP_GROUP_ATTR_SET_SWITCHOVER', 'false'], } ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values set =======') + pprint(results) + + + 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 =======') diff --git a/tests/api/test_next_hop_group_map.py b/tests/api/test_next_hop_group_map.py new file mode 100644 index 00000000..0d65717e --- /dev/null +++ b/tests/api/test_next_hop_group_map.py @@ -0,0 +1,29 @@ +from pprint import pprint + + +class TestSaiNextHopGroupMap: + # object with no parents + + def test_next_hop_group_map_create(self, npu): + commands = [ + { + 'name': 'next_hop_group_map_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_NEXT_HOP_GROUP_MAP', + 'attributes': [ + 'SAI_NEXT_HOP_GROUP_MAP_ATTR_TYPE', + 'SAI_NEXT_HOP_GROUP_MAP_TYPE_FORWARDING_CLASS_TO_INDEX', + ], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_next_hop_group_map_remove(self, npu): + commands = [{'name': 'next_hop_group_map_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_policer.py b/tests/api/test_policer.py index 4c6f3352..3ca7abd6 100644 --- a/tests/api/test_policer.py +++ b/tests/api/test_policer.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 TestSaiPolicer: # object with no parents diff --git a/tests/api/test_port.py b/tests/api/test_port.py new file mode 100644 index 00000000..628f46ed --- /dev/null +++ b/tests/api/test_port.py @@ -0,0 +1,35 @@ +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 TestSaiPort: + # object with no parents + + def test_port_create(self, npu): + commands = [ + { + 'name': 'port_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_PORT', + 'attributes': [ + 'SAI_PORT_ATTR_HW_LANE_LIST', + '2:10,11', + 'SAI_PORT_ATTR_SPEED', + '10', + ], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + diff --git a/tests/api/test_rpf_group.py b/tests/api/test_rpf_group.py index 31fb3f48..79a8bfa9 100644 --- a/tests/api/test_rpf_group.py +++ b/tests/api/test_rpf_group.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 TestSaiRpfGroup: # object with no attributes diff --git a/tests/api/test_samplepacket.py b/tests/api/test_samplepacket.py index 79c404c8..0101f777 100644 --- a/tests/api/test_samplepacket.py +++ b/tests/api/test_samplepacket.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 TestSaiSamplepacket: # object with no parents diff --git a/tests/api/test_scheduler.py b/tests/api/test_scheduler.py index 34fe9acc..299c0109 100644 --- a/tests/api/test_scheduler.py +++ b/tests/api/test_scheduler.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 TestSaiScheduler: # object with no attributes diff --git a/tests/api/test_stp.py b/tests/api/test_stp.py index 15ec7d21..531b7c43 100644 --- a/tests/api/test_stp.py +++ b/tests/api/test_stp.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 TestSaiStp: # object with no attributes diff --git a/tests/api/test_tam.py b/tests/api/test_tam.py new file mode 100644 index 00000000..94aa30fe --- /dev/null +++ b/tests/api/test_tam.py @@ -0,0 +1,26 @@ +from pprint import pprint + + +class TestSaiTam: + # object with no attributes + + def test_tam_create(self, npu): + commands = [ + { + 'name': 'tam_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_TAM', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_tam_remove(self, npu): + commands = [{'name': 'tam_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_tam_collector.py b/tests/api/test_tam_collector.py new file mode 100644 index 00000000..6e5eb428 --- /dev/null +++ b/tests/api/test_tam_collector.py @@ -0,0 +1,47 @@ +from pprint import pprint + + +class TestSaiTamCollector: + # object with parent SAI_OBJECT_TYPE_TAM_TRANSPORT + + def test_tam_collector_create(self, npu): + commands = [ + { + 'name': 'tam_transport_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_TAM_TRANSPORT', + 'attributes': [ + 'SAI_TAM_TRANSPORT_ATTR_TRANSPORT_TYPE', + 'SAI_TAM_TRANSPORT_TYPE_TCP', + ], + }, + { + 'name': 'tam_collector_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_TAM_COLLECTOR', + 'attributes': [ + 'SAI_TAM_COLLECTOR_ATTR_SRC_IP', + '180.0.0.1', + 'SAI_TAM_COLLECTOR_ATTR_DST_IP', + '180.0.0.1', + 'SAI_TAM_COLLECTOR_ATTR_TRANSPORT', + '$tam_transport_1', + 'SAI_TAM_COLLECTOR_ATTR_DSCP_VALUE', + '1', + ], + }, + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_tam_collector_remove(self, npu): + commands = [ + {'name': 'tam_collector_1', 'op': 'remove'}, + {'name': 'tam_transport_1', 'op': 'remove'}, + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_tunnel_map.py b/tests/api/test_tunnel_map.py index dfd174bc..e697a647 100644 --- a/tests/api/test_tunnel_map.py +++ b/tests/api/test_tunnel_map.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 TestSaiTunnelMap: # object with no parents diff --git a/tests/api/test_udf.py b/tests/api/test_udf.py new file mode 100644 index 00000000..566ec48d --- /dev/null +++ b/tests/api/test_udf.py @@ -0,0 +1,93 @@ +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 TestSaiUdf: + # object with parent SAI_OBJECT_TYPE_UDF_MATCH SAI_OBJECT_TYPE_UDF_GROUP + + def test_udf_create(self, npu): + commands = [ + { + 'name': 'udf_match_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_UDF_MATCH', + 'attributes': [], + }, + { + 'name': 'udf_group_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_UDF_GROUP', + 'attributes': ['SAI_UDF_GROUP_ATTR_LENGTH', '10'], + }, + { + 'name': 'udf_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_UDF', + 'attributes': [ + 'SAI_UDF_ATTR_MATCH_ID', + '$udf_match_1', + 'SAI_UDF_ATTR_GROUP_ID', + '$udf_group_1', + 'SAI_UDF_ATTR_OFFSET', + '10', + ], + }, + ] + + results = [*npu.process_commands(commands)] + 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'}, + {'name': 'udf_group_1', 'op': 'remove'}, + {'name': 'udf_match_1', 'op': 'remove'}, + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_udf_group.py b/tests/api/test_udf_group.py index 3ad0303b..93bafed3 100644 --- a/tests/api/test_udf_group.py +++ b/tests/api/test_udf_group.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 TestSaiUdfGroup: # object with no parents diff --git a/tests/api/test_udf_match.py b/tests/api/test_udf_match.py new file mode 100644 index 00000000..53fa01fc --- /dev/null +++ b/tests/api/test_udf_match.py @@ -0,0 +1,26 @@ +from pprint import pprint + + +class TestSaiUdfMatch: + # object with no attributes + + def test_udf_match_create(self, npu): + commands = [ + { + 'name': 'udf_match_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_UDF_MATCH', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_udf_match_remove(self, npu): + commands = [{'name': 'udf_match_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_virtual_router.py b/tests/api/test_virtual_router.py index 285e9cee..ba86c93c 100644 --- a/tests/api/test_virtual_router.py +++ b/tests/api/test_virtual_router.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 TestSaiVirtualRouter: # object with no attributes @@ -18,13 +28,71 @@ def test_virtual_router_create(self, npu): print('======= SAI commands RETURN values create =======') pprint(results) - def test_virtual_router_remove(self, npu): + @pytest.mark.dependency(name='test_sai_virtual_router_attr_admin_v4_state_set') + def test_sai_virtual_router_attr_admin_v4_state_set(self, npu): + commands = [ + { + 'name': 'virtual_router_1', + 'op': 'set', + 'attributes': ['SAI_VIRTUAL_ROUTER_ATTR_ADMIN_V4_STATE', 'true'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values set =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_virtual_router_attr_admin_v4_state_set']) + def test_sai_virtual_router_attr_admin_v4_state_get(self, npu): commands = [ { 'name': 'virtual_router_1', - 'op': 'remove', + 'op': 'get', + 'attributes': ['SAI_VIRTUAL_ROUTER_ATTR_ADMIN_V4_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_virtual_router_attr_admin_v6_state_set') + def test_sai_virtual_router_attr_admin_v6_state_set(self, npu): + commands = [ + { + 'name': 'virtual_router_1', + 'op': 'set', + 'attributes': ['SAI_VIRTUAL_ROUTER_ATTR_ADMIN_V6_STATE', 'true'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values set =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_virtual_router_attr_admin_v6_state_set']) + def test_sai_virtual_router_attr_admin_v6_state_get(self, npu): + commands = [ + { + 'name': 'virtual_router_1', + 'op': 'get', + 'attributes': ['SAI_VIRTUAL_ROUTER_ATTR_ADMIN_V6_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 + + + def test_virtual_router_remove(self, npu): + commands = [{'name': 'virtual_router_1', 'op': 'remove'}] results = [*npu.process_commands(commands)] print('======= SAI commands RETURN values remove =======') diff --git a/tests/api/test_vlan.py b/tests/api/test_vlan.py index 8dac7c9e..72308e29 100644 --- a/tests/api/test_vlan.py +++ b/tests/api/test_vlan.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 TestSaiVlan: # object with no parents @@ -18,13 +28,41 @@ def test_vlan_create(self, npu): print('======= SAI commands RETURN values create =======') pprint(results) - def test_vlan_remove(self, npu): + + @pytest.mark.dependency(name='test_sai_vlan_attr_max_learned_addresses_set') + def test_sai_vlan_attr_max_learned_addresses_set(self, npu): commands = [ { 'name': 'vlan_1', - 'op': 'remove', + 'op': 'set', + 'attributes': ['SAI_VLAN_ATTR_MAX_LEARNED_ADDRESSES', '0'], } ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values set =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_vlan_attr_max_learned_addresses_set']) + def test_sai_vlan_attr_max_learned_addresses_get(self, npu): + commands = [ + { + 'name': 'vlan_1', + 'op': 'get', + 'attributes': ['SAI_VLAN_ATTR_MAX_LEARNED_ADDRESSES'], + } + ] + 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_vlan_remove(self, npu): + commands = [{'name': 'vlan_1', 'op': 'remove'}] results = [*npu.process_commands(commands)] print('======= SAI commands RETURN values remove =======') diff --git a/tests/api/test_wred.py b/tests/api/test_wred.py index 5a809f14..f9c90853 100644 --- a/tests/api/test_wred.py +++ b/tests/api/test_wred.py @@ -1,6 +1,15 @@ 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 TestSaiWred: # object with no attributes