From 1cd40f69bf998b416dd36a34b3140eaf80476f82 Mon Sep 17 00:00:00 2001 From: Dinesh Kumar Sellappan Date: Thu, 5 Oct 2023 10:18:39 -0700 Subject: [PATCH] Cases that passed in tofino, failed in CI/CD Cases that passed in tofino, failed in CI/CD Signed-off-by: Dinesh Kumar Sellappan --- tests/api/test_buffer_profile.py | 51 ++++++++ tests/api/test_hostif.py | 150 +++++++++++++++++++++++ tests/api/test_isolation_group_member.py | 64 ++++++++++ tests/api/test_lag_member.py | 90 ++++++++++++++ tests/api/test_my_mac.py | 36 ++++++ tests/api/test_port.py | 35 ++++++ 6 files changed, 426 insertions(+) create mode 100644 tests/api/test_buffer_profile.py create mode 100644 tests/api/test_hostif.py create mode 100644 tests/api/test_isolation_group_member.py create mode 100644 tests/api/test_lag_member.py create mode 100644 tests/api/test_my_mac.py create mode 100644 tests/api/test_port.py 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_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_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_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_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_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) +