diff --git a/tests/api/test_acl_counter.py b/tests/api/test_acl_counter.py index fb65afe3..2f8dcb63 100644 --- a/tests/api/test_acl_counter.py +++ b/tests/api/test_acl_counter.py @@ -1,6 +1,21 @@ from pprint import pprint +import pytest + +@pytest.fixture(scope="module", autouse=True) +def discovery(npu): + npu.objects_discovery() + + +@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 @@ -19,23 +34,31 @@ def test_acl_counter_create(self, npu): 'attributes': ['SAI_ACL_COUNTER_ATTR_TABLE_ID', '$acl_table_1'], }, ] - + npu.objects_discovery() 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', - }, + 'op': 'set', + 'attributes': ['SAI_ACL_COUNTER_ATTR_LABEL', '""'], + } ] + npu.objects_discovery() + 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'}, + ] + npu.objects_discovery() results = [*npu.process_commands(commands)] print('======= SAI commands RETURN values remove =======') pprint(results) diff --git a/tests/api/test_hostif_trap_group.py b/tests/api/test_hostif_trap_group.py index ce6db62f..69680867 100644 --- a/tests/api/test_hostif_trap_group.py +++ b/tests/api/test_hostif_trap_group.py @@ -1,5 +1,19 @@ from pprint import pprint +import pytest + + +@pytest.fixture(scope="module", autouse=True) +def discovery(npu): + npu.objects_discovery() + + +@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)) + class TestSaiHostifTrapGroup: # object with no attributes @@ -18,13 +32,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 =======') diff --git a/tests/api/test_next_hop_group.py b/tests/api/test_next_hop_group.py index d20c3c58..df1236e6 100644 --- a/tests/api/test_next_hop_group.py +++ b/tests/api/test_next_hop_group.py @@ -1,34 +1,75 @@ + from pprint import pprint +import pytest + + +@pytest.fixture(scope="module", autouse=True) +def discovery(npu): + npu.objects_discovery() + +@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 def test_next_hop_group_create(self, npu): + + commands = [{'name': 'next_hop_group_1', 'op': 'create', 'type': 'SAI_OBJECT_TYPE_NEXT_HOP_GROUP', 'attributes': ['SAI_NEXT_HOP_GROUP_ATTR_TYPE', 'SAI_NEXT_HOP_GROUP_TYPE_DYNAMIC_UNORDERED_ECMP']}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + + @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': 'create', - 'type': 'SAI_OBJECT_TYPE_NEXT_HOP_GROUP', - 'attributes': [ - 'SAI_NEXT_HOP_GROUP_ATTR_TYPE', - 'SAI_NEXT_HOP_GROUP_TYPE_DYNAMIC_UNORDERED_ECMP', - ], + "name": "next_hop_group_1", + "op": "set", + "attributes": ["SAI_NEXT_HOP_GROUP_ATTR_SET_SWITCHOVER", 'false'] } ] - results = [*npu.process_commands(commands)] - print('======= SAI commands RETURN values create =======') + print("======= SAI commands RETURN values set =======") pprint(results) - def test_next_hop_group_remove(self, npu): + + + @pytest.mark.dependency(depends=["test_sai_next_hop_group_attr_set_switchover_set"]) + def test_sai_next_hop_group_attr_set_switchover_get(self, npu): + commands = [ { - 'name': 'next_hop_group_1', - 'op': 'remove', + "name": "next_hop_group_1", + "op": "get", + "attributes": ["SAI_NEXT_HOP_GROUP_ATTR_SET_SWITCHOVER"] } ] + 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 + + + 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 =======') pprint(results) + diff --git a/tests/api/test_policer.py b/tests/api/test_policer.py index 4c6f3352..1b6531b4 100644 --- a/tests/api/test_policer.py +++ b/tests/api/test_policer.py @@ -1,36 +1,292 @@ + from pprint import pprint +import pytest + + +@pytest.fixture(scope="module", autouse=True) +def discovery(npu): + npu.objects_discovery() + + +@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 def test_policer_create(self, npu): + + commands = [{'name': 'policer_1', 'op': 'create', 'type': 'SAI_OBJECT_TYPE_POLICER', 'attributes': ['SAI_POLICER_ATTR_METER_TYPE', 'SAI_METER_TYPE_PACKETS', 'SAI_POLICER_ATTR_MODE', 'SAI_POLICER_MODE_SR_TCM']}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + + + @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 set =======") + 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': 'create', - 'type': 'SAI_OBJECT_TYPE_POLICER', - 'attributes': [ - 'SAI_POLICER_ATTR_METER_TYPE', - 'SAI_METER_TYPE_PACKETS', - 'SAI_POLICER_ATTR_MODE', - 'SAI_POLICER_MODE_SR_TCM', - ], + "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 create =======') + print("======= SAI commands RETURN values set =======") pprint(results) - def test_policer_remove(self, npu): + + + @pytest.mark.dependency(depends=["test_sai_policer_attr_cir_set"]) + def test_sai_policer_attr_cir_get(self, npu): + commands = [ { - 'name': 'policer_1', - 'op': 'remove', + "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 set =======") + 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 set =======") + 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": "set", + "attributes": ["SAI_POLICER_ATTR_GREEN_PACKET_ACTION", 'SAI_PACKET_ACTION_FORWARD'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + 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 set =======") + 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 set =======") + 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 =======') pprint(results) + diff --git a/tests/api/test_scheduler.py b/tests/api/test_scheduler.py index 34fe9acc..f84033a2 100644 --- a/tests/api/test_scheduler.py +++ b/tests/api/test_scheduler.py @@ -1,5 +1,19 @@ from pprint import pprint +import pytest + + +@pytest.fixture(scope="module", autouse=True) +def discovery(npu): + npu.objects_discovery() + + +@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)) + class TestSaiScheduler: # object with no attributes @@ -18,13 +32,236 @@ def test_scheduler_create(self, npu): print('======= SAI commands RETURN values create =======') pprint(results) - def test_scheduler_remove(self, npu): + @pytest.mark.dependency(name='test_sai_scheduler_attr_scheduling_type_set') + def test_sai_scheduler_attr_scheduling_type_set(self, npu): + commands = [ + { + 'name': 'scheduler_1', + 'op': 'set', + 'attributes': [ + 'SAI_SCHEDULER_ATTR_SCHEDULING_TYPE', + 'SAI_SCHEDULING_TYPE_WRR', + ], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_scheduler_attr_scheduling_type_set']) + def test_sai_scheduler_attr_scheduling_type_get(self, npu): + commands = [ + { + 'name': 'scheduler_1', + 'op': 'get', + 'attributes': ['SAI_SCHEDULER_ATTR_SCHEDULING_TYPE'], + } + ] + 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_SCHEDULING_TYPE_WRR', ( + 'Get error, expected SAI_SCHEDULING_TYPE_WRR but got %s' % r_value + ) + + @pytest.mark.dependency(name='test_sai_scheduler_attr_scheduling_weight_set') + def test_sai_scheduler_attr_scheduling_weight_set(self, npu): + commands = [ + { + 'name': 'scheduler_1', + 'op': 'set', + 'attributes': ['SAI_SCHEDULER_ATTR_SCHEDULING_WEIGHT', '1'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_scheduler_attr_scheduling_weight_set']) + def test_sai_scheduler_attr_scheduling_weight_get(self, npu): + commands = [ + { + 'name': 'scheduler_1', + 'op': 'get', + 'attributes': ['SAI_SCHEDULER_ATTR_SCHEDULING_WEIGHT'], + } + ] + 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 == '1', 'Get error, expected 1 but got %s' % r_value + + @pytest.mark.dependency(name='test_sai_scheduler_attr_meter_type_set') + def test_sai_scheduler_attr_meter_type_set(self, npu): commands = [ { 'name': 'scheduler_1', - 'op': 'remove', + 'op': 'set', + 'attributes': ['SAI_SCHEDULER_ATTR_METER_TYPE', 'SAI_METER_TYPE_BYTES'], } ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_scheduler_attr_meter_type_set']) + def test_sai_scheduler_attr_meter_type_get(self, npu): + commands = [ + { + 'name': 'scheduler_1', + 'op': 'get', + 'attributes': ['SAI_SCHEDULER_ATTR_METER_TYPE'], + } + ] + 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_METER_TYPE_BYTES', ( + 'Get error, expected SAI_METER_TYPE_BYTES but got %s' % r_value + ) + + @pytest.mark.dependency(name='test_sai_scheduler_attr_min_bandwidth_rate_set') + def test_sai_scheduler_attr_min_bandwidth_rate_set(self, npu): + commands = [ + { + 'name': 'scheduler_1', + 'op': 'set', + 'attributes': ['SAI_SCHEDULER_ATTR_MIN_BANDWIDTH_RATE', '0'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_scheduler_attr_min_bandwidth_rate_set']) + def test_sai_scheduler_attr_min_bandwidth_rate_get(self, npu): + commands = [ + { + 'name': 'scheduler_1', + 'op': 'get', + 'attributes': ['SAI_SCHEDULER_ATTR_MIN_BANDWIDTH_RATE'], + } + ] + 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_scheduler_attr_min_bandwidth_burst_rate_set') + def test_sai_scheduler_attr_min_bandwidth_burst_rate_set(self, npu): + commands = [ + { + 'name': 'scheduler_1', + 'op': 'set', + 'attributes': ['SAI_SCHEDULER_ATTR_MIN_BANDWIDTH_BURST_RATE', '0'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency( + depends=['test_sai_scheduler_attr_min_bandwidth_burst_rate_set'] + ) + def test_sai_scheduler_attr_min_bandwidth_burst_rate_get(self, npu): + commands = [ + { + 'name': 'scheduler_1', + 'op': 'get', + 'attributes': ['SAI_SCHEDULER_ATTR_MIN_BANDWIDTH_BURST_RATE'], + } + ] + 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_scheduler_attr_max_bandwidth_rate_set') + def test_sai_scheduler_attr_max_bandwidth_rate_set(self, npu): + commands = [ + { + 'name': 'scheduler_1', + 'op': 'set', + 'attributes': ['SAI_SCHEDULER_ATTR_MAX_BANDWIDTH_RATE', '0'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_scheduler_attr_max_bandwidth_rate_set']) + def test_sai_scheduler_attr_max_bandwidth_rate_get(self, npu): + commands = [ + { + 'name': 'scheduler_1', + 'op': 'get', + 'attributes': ['SAI_SCHEDULER_ATTR_MAX_BANDWIDTH_RATE'], + } + ] + 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_scheduler_attr_max_bandwidth_burst_rate_set') + def test_sai_scheduler_attr_max_bandwidth_burst_rate_set(self, npu): + commands = [ + { + 'name': 'scheduler_1', + 'op': 'set', + 'attributes': ['SAI_SCHEDULER_ATTR_MAX_BANDWIDTH_BURST_RATE', '0'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency( + depends=['test_sai_scheduler_attr_max_bandwidth_burst_rate_set'] + ) + def test_sai_scheduler_attr_max_bandwidth_burst_rate_get(self, npu): + commands = [ + { + 'name': 'scheduler_1', + 'op': 'get', + 'attributes': ['SAI_SCHEDULER_ATTR_MAX_BANDWIDTH_BURST_RATE'], + } + ] + 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_scheduler_remove(self, npu): + commands = [{'name': 'scheduler_1', 'op': 'remove'}] results = [*npu.process_commands(commands)] print('======= SAI commands RETURN values remove =======') diff --git a/tests/api/test_udf.py b/tests/api/test_udf.py new file mode 100644 index 00000000..1566e1e6 --- /dev/null +++ b/tests/api/test_udf.py @@ -0,0 +1,112 @@ + +from pprint import pprint + +import pytest + + +@pytest.fixture(scope="module", autouse=True) +def discovery(npu): + npu.objects_discovery() + + +@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 + + + @pytest.mark.dependency(name="test_sai_udf_attr_hash_mask_set") + def test_sai_udf_attr_hash_mask_set(self, npu): + + commands = [ + { + "name": "udf_1", + "op": "set", + "attributes": ["SAI_UDF_ATTR_HASH_MASK", 'const'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + pprint(results) + + + + @pytest.mark.dependency(depends=["test_sai_udf_attr_hash_mask_set"]) + def test_sai_udf_attr_hash_mask_get(self, npu): + + commands = [ + { + "name": "udf_1", + "op": "get", + "attributes": ["SAI_UDF_ATTR_HASH_MASK"] + } + ] + 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 == 'const', 'Get error, expected const 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_virtual_router.py b/tests/api/test_virtual_router.py index 285e9cee..241cdcd7 100644 --- a/tests/api/test_virtual_router.py +++ b/tests/api/test_virtual_router.py @@ -1,31 +1,292 @@ + from pprint import pprint +import pytest + + +@pytest.fixture(scope="module", autouse=True) +def discovery(npu): + npu.objects_discovery() + + +@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 def test_virtual_router_create(self, npu): + + commands = [{'name': 'virtual_router_1', 'op': 'create', 'type': 'SAI_OBJECT_TYPE_VIRTUAL_ROUTER', 'attributes': []}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + + + @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': 'create', - 'type': 'SAI_OBJECT_TYPE_VIRTUAL_ROUTER', - 'attributes': [], + "name": "virtual_router_1", + "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 create =======') + print("======= SAI commands RETURN values set =======") pprint(results) - def test_virtual_router_remove(self, npu): + + + @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': 'remove', + "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 + + + @pytest.mark.dependency(name="test_sai_virtual_router_attr_src_mac_address_set") + def test_sai_virtual_router_attr_src_mac_address_set(self, npu): + + commands = [ + { + "name": "virtual_router_1", + "op": "set", + "attributes": ["SAI_VIRTUAL_ROUTER_ATTR_SRC_MAC_ADDRESS", 'SAI_SWITCH_ATTR_SRC_MAC_ADDRESS'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + pprint(results) + + + + @pytest.mark.dependency(depends=["test_sai_virtual_router_attr_src_mac_address_set"]) + def test_sai_virtual_router_attr_src_mac_address_get(self, npu): + + commands = [ + { + "name": "virtual_router_1", + "op": "get", + "attributes": ["SAI_VIRTUAL_ROUTER_ATTR_SRC_MAC_ADDRESS"] + } + ] + 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_SWITCH_ATTR_SRC_MAC_ADDRESS', 'Get error, expected SAI_SWITCH_ATTR_SRC_MAC_ADDRESS but got %s' % r_value + + + @pytest.mark.dependency(name="test_sai_virtual_router_attr_violation_ttl1_packet_action_set") + def test_sai_virtual_router_attr_violation_ttl1_packet_action_set(self, npu): + + commands = [ + { + "name": "virtual_router_1", + "op": "set", + "attributes": ["SAI_VIRTUAL_ROUTER_ATTR_VIOLATION_TTL1_PACKET_ACTION", 'SAI_PACKET_ACTION_TRAP'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + pprint(results) + + + + @pytest.mark.dependency(depends=["test_sai_virtual_router_attr_violation_ttl1_packet_action_set"]) + def test_sai_virtual_router_attr_violation_ttl1_packet_action_get(self, npu): + + commands = [ + { + "name": "virtual_router_1", + "op": "get", + "attributes": ["SAI_VIRTUAL_ROUTER_ATTR_VIOLATION_TTL1_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_TRAP', 'Get error, expected SAI_PACKET_ACTION_TRAP but got %s' % r_value + + + @pytest.mark.dependency(name="test_sai_virtual_router_attr_violation_ip_options_packet_action_set") + def test_sai_virtual_router_attr_violation_ip_options_packet_action_set(self, npu): + + commands = [ + { + "name": "virtual_router_1", + "op": "set", + "attributes": ["SAI_VIRTUAL_ROUTER_ATTR_VIOLATION_IP_OPTIONS_PACKET_ACTION", 'SAI_PACKET_ACTION_TRAP'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + pprint(results) + + + + @pytest.mark.dependency(depends=["test_sai_virtual_router_attr_violation_ip_options_packet_action_set"]) + def test_sai_virtual_router_attr_violation_ip_options_packet_action_get(self, npu): + + commands = [ + { + "name": "virtual_router_1", + "op": "get", + "attributes": ["SAI_VIRTUAL_ROUTER_ATTR_VIOLATION_IP_OPTIONS_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_TRAP', 'Get error, expected SAI_PACKET_ACTION_TRAP but got %s' % r_value + + + @pytest.mark.dependency(name="test_sai_virtual_router_attr_unknown_l3_multicast_packet_action_set") + def test_sai_virtual_router_attr_unknown_l3_multicast_packet_action_set(self, npu): + + commands = [ + { + "name": "virtual_router_1", + "op": "set", + "attributes": ["SAI_VIRTUAL_ROUTER_ATTR_UNKNOWN_L3_MULTICAST_PACKET_ACTION", 'SAI_PACKET_ACTION_DROP'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + pprint(results) + + + + @pytest.mark.dependency(depends=["test_sai_virtual_router_attr_unknown_l3_multicast_packet_action_set"]) + def test_sai_virtual_router_attr_unknown_l3_multicast_packet_action_get(self, npu): + + commands = [ + { + "name": "virtual_router_1", + "op": "get", + "attributes": ["SAI_VIRTUAL_ROUTER_ATTR_UNKNOWN_L3_MULTICAST_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_DROP', 'Get error, expected SAI_PACKET_ACTION_DROP but got %s' % r_value + + + @pytest.mark.dependency(name="test_sai_virtual_router_attr_label_set") + def test_sai_virtual_router_attr_label_set(self, npu): + + commands = [ + { + "name": "virtual_router_1", + "op": "set", + "attributes": ["SAI_VIRTUAL_ROUTER_ATTR_LABEL", '""'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + pprint(results) + + + + @pytest.mark.dependency(depends=["test_sai_virtual_router_attr_label_set"]) + def test_sai_virtual_router_attr_label_get(self, npu): + + commands = [ + { + "name": "virtual_router_1", + "op": "get", + "attributes": ["SAI_VIRTUAL_ROUTER_ATTR_LABEL"] + } + ] + 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 == '""', 'Get error, expected "" 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 =======') pprint(results) + diff --git a/tests/api/test_vlan.py b/tests/api/test_vlan.py index 8dac7c9e..5c9bf142 100644 --- a/tests/api/test_vlan.py +++ b/tests/api/test_vlan.py @@ -1,31 +1,780 @@ + from pprint import pprint +import pytest + + +@pytest.fixture(scope="module", autouse=True) +def discovery(npu): + npu.objects_discovery() + + +@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 def test_vlan_create(self, npu): + + commands = [{'name': 'vlan_1', 'op': 'create', 'type': 'SAI_OBJECT_TYPE_VLAN', 'attributes': ['SAI_VLAN_ATTR_VLAN_ID', '10']}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + + + + def test_sai_vlan_attr_member_list_get(self, npu): + commands = [ { - 'name': 'vlan_1', - 'op': 'create', - 'type': 'SAI_OBJECT_TYPE_VLAN', - 'attributes': ['SAI_VLAN_ATTR_VLAN_ID', '10'], + "name": "vlan_1", + "op": "get", + "attributes": ["SAI_VLAN_ATTR_MEMBER_LIST"] } ] + 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 == 'TODO', 'Get error, expected TODO but got %s' % r_value + + + @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": "set", + "attributes": ["SAI_VLAN_ATTR_MAX_LEARNED_ADDRESSES", '0'] + } + ] results = [*npu.process_commands(commands)] - print('======= SAI commands RETURN values create =======') + print("======= SAI commands RETURN values set =======") pprint(results) - def test_vlan_remove(self, npu): + + + @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 + + + @pytest.mark.dependency(name="test_sai_vlan_attr_stp_instance_set") + def test_sai_vlan_attr_stp_instance_set(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "set", + "attributes": ["SAI_VLAN_ATTR_STP_INSTANCE", 'SAI_SWITCH_ATTR_DEFAULT_STP_INST_ID'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + pprint(results) + + + + @pytest.mark.dependency(depends=["test_sai_vlan_attr_stp_instance_set"]) + def test_sai_vlan_attr_stp_instance_get(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "get", + "attributes": ["SAI_VLAN_ATTR_STP_INSTANCE"] + } + ] + 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_SWITCH_ATTR_DEFAULT_STP_INST_ID', 'Get error, expected SAI_SWITCH_ATTR_DEFAULT_STP_INST_ID but got %s' % r_value + + + @pytest.mark.dependency(name="test_sai_vlan_attr_learn_disable_set") + def test_sai_vlan_attr_learn_disable_set(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "set", + "attributes": ["SAI_VLAN_ATTR_LEARN_DISABLE", 'false'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + pprint(results) + + + + @pytest.mark.dependency(depends=["test_sai_vlan_attr_learn_disable_set"]) + def test_sai_vlan_attr_learn_disable_get(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "get", + "attributes": ["SAI_VLAN_ATTR_LEARN_DISABLE"] + } + ] + 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_vlan_attr_ipv4_mcast_lookup_key_type_set") + def test_sai_vlan_attr_ipv4_mcast_lookup_key_type_set(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "set", + "attributes": ["SAI_VLAN_ATTR_IPV4_MCAST_LOOKUP_KEY_TYPE", 'SAI_VLAN_MCAST_LOOKUP_KEY_TYPE_MAC_DA'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + pprint(results) + + + + @pytest.mark.dependency(depends=["test_sai_vlan_attr_ipv4_mcast_lookup_key_type_set"]) + def test_sai_vlan_attr_ipv4_mcast_lookup_key_type_get(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "get", + "attributes": ["SAI_VLAN_ATTR_IPV4_MCAST_LOOKUP_KEY_TYPE"] + } + ] + 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_VLAN_MCAST_LOOKUP_KEY_TYPE_MAC_DA', 'Get error, expected SAI_VLAN_MCAST_LOOKUP_KEY_TYPE_MAC_DA but got %s' % r_value + + + @pytest.mark.dependency(name="test_sai_vlan_attr_ipv6_mcast_lookup_key_type_set") + def test_sai_vlan_attr_ipv6_mcast_lookup_key_type_set(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "set", + "attributes": ["SAI_VLAN_ATTR_IPV6_MCAST_LOOKUP_KEY_TYPE", 'SAI_VLAN_MCAST_LOOKUP_KEY_TYPE_MAC_DA'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + pprint(results) + + + + @pytest.mark.dependency(depends=["test_sai_vlan_attr_ipv6_mcast_lookup_key_type_set"]) + def test_sai_vlan_attr_ipv6_mcast_lookup_key_type_get(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "get", + "attributes": ["SAI_VLAN_ATTR_IPV6_MCAST_LOOKUP_KEY_TYPE"] + } + ] + 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_VLAN_MCAST_LOOKUP_KEY_TYPE_MAC_DA', 'Get error, expected SAI_VLAN_MCAST_LOOKUP_KEY_TYPE_MAC_DA but got %s' % r_value + + + @pytest.mark.dependency(name="test_sai_vlan_attr_unknown_non_ip_mcast_output_group_id_set") + def test_sai_vlan_attr_unknown_non_ip_mcast_output_group_id_set(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "set", + "attributes": ["SAI_VLAN_ATTR_UNKNOWN_NON_IP_MCAST_OUTPUT_GROUP_ID", 'SAI_NULL_OBJECT_ID'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + pprint(results) + + + + @pytest.mark.dependency(depends=["test_sai_vlan_attr_unknown_non_ip_mcast_output_group_id_set"]) + def test_sai_vlan_attr_unknown_non_ip_mcast_output_group_id_get(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "get", + "attributes": ["SAI_VLAN_ATTR_UNKNOWN_NON_IP_MCAST_OUTPUT_GROUP_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 == 'SAI_NULL_OBJECT_ID', 'Get error, expected SAI_NULL_OBJECT_ID but got %s' % r_value + + + @pytest.mark.dependency(name="test_sai_vlan_attr_unknown_ipv4_mcast_output_group_id_set") + def test_sai_vlan_attr_unknown_ipv4_mcast_output_group_id_set(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "set", + "attributes": ["SAI_VLAN_ATTR_UNKNOWN_IPV4_MCAST_OUTPUT_GROUP_ID", 'SAI_NULL_OBJECT_ID'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + pprint(results) + + + + @pytest.mark.dependency(depends=["test_sai_vlan_attr_unknown_ipv4_mcast_output_group_id_set"]) + def test_sai_vlan_attr_unknown_ipv4_mcast_output_group_id_get(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "get", + "attributes": ["SAI_VLAN_ATTR_UNKNOWN_IPV4_MCAST_OUTPUT_GROUP_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 == 'SAI_NULL_OBJECT_ID', 'Get error, expected SAI_NULL_OBJECT_ID but got %s' % r_value + + + @pytest.mark.dependency(name="test_sai_vlan_attr_unknown_ipv6_mcast_output_group_id_set") + def test_sai_vlan_attr_unknown_ipv6_mcast_output_group_id_set(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "set", + "attributes": ["SAI_VLAN_ATTR_UNKNOWN_IPV6_MCAST_OUTPUT_GROUP_ID", 'SAI_NULL_OBJECT_ID'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + pprint(results) + + + + @pytest.mark.dependency(depends=["test_sai_vlan_attr_unknown_ipv6_mcast_output_group_id_set"]) + def test_sai_vlan_attr_unknown_ipv6_mcast_output_group_id_get(self, npu): + commands = [ { - 'name': 'vlan_1', - 'op': 'remove', + "name": "vlan_1", + "op": "get", + "attributes": ["SAI_VLAN_ATTR_UNKNOWN_IPV6_MCAST_OUTPUT_GROUP_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 == 'SAI_NULL_OBJECT_ID', 'Get error, expected SAI_NULL_OBJECT_ID but got %s' % r_value + + + @pytest.mark.dependency(name="test_sai_vlan_attr_unknown_linklocal_mcast_output_group_id_set") + def test_sai_vlan_attr_unknown_linklocal_mcast_output_group_id_set(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "set", + "attributes": ["SAI_VLAN_ATTR_UNKNOWN_LINKLOCAL_MCAST_OUTPUT_GROUP_ID", 'SAI_NULL_OBJECT_ID'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + pprint(results) + + + + @pytest.mark.dependency(depends=["test_sai_vlan_attr_unknown_linklocal_mcast_output_group_id_set"]) + def test_sai_vlan_attr_unknown_linklocal_mcast_output_group_id_get(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "get", + "attributes": ["SAI_VLAN_ATTR_UNKNOWN_LINKLOCAL_MCAST_OUTPUT_GROUP_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 == 'SAI_NULL_OBJECT_ID', 'Get error, expected SAI_NULL_OBJECT_ID but got %s' % r_value + + + @pytest.mark.dependency(name="test_sai_vlan_attr_ingress_acl_set") + def test_sai_vlan_attr_ingress_acl_set(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "set", + "attributes": ["SAI_VLAN_ATTR_INGRESS_ACL", 'SAI_NULL_OBJECT_ID'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + pprint(results) + + + + @pytest.mark.dependency(depends=["test_sai_vlan_attr_ingress_acl_set"]) + def test_sai_vlan_attr_ingress_acl_get(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "get", + "attributes": ["SAI_VLAN_ATTR_INGRESS_ACL"] + } + ] + 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_NULL_OBJECT_ID', 'Get error, expected SAI_NULL_OBJECT_ID but got %s' % r_value + + + @pytest.mark.dependency(name="test_sai_vlan_attr_egress_acl_set") + def test_sai_vlan_attr_egress_acl_set(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "set", + "attributes": ["SAI_VLAN_ATTR_EGRESS_ACL", 'SAI_NULL_OBJECT_ID'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + pprint(results) + + + + @pytest.mark.dependency(depends=["test_sai_vlan_attr_egress_acl_set"]) + def test_sai_vlan_attr_egress_acl_get(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "get", + "attributes": ["SAI_VLAN_ATTR_EGRESS_ACL"] + } + ] + 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_NULL_OBJECT_ID', 'Get error, expected SAI_NULL_OBJECT_ID but got %s' % r_value + + + @pytest.mark.dependency(name="test_sai_vlan_attr_meta_data_set") + def test_sai_vlan_attr_meta_data_set(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "set", + "attributes": ["SAI_VLAN_ATTR_META_DATA", '0'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + pprint(results) + + + + @pytest.mark.dependency(depends=["test_sai_vlan_attr_meta_data_set"]) + def test_sai_vlan_attr_meta_data_get(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "get", + "attributes": ["SAI_VLAN_ATTR_META_DATA"] + } + ] + 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_vlan_attr_unknown_unicast_flood_control_type_set") + def test_sai_vlan_attr_unknown_unicast_flood_control_type_set(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "set", + "attributes": ["SAI_VLAN_ATTR_UNKNOWN_UNICAST_FLOOD_CONTROL_TYPE", 'SAI_VLAN_FLOOD_CONTROL_TYPE_ALL'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + pprint(results) + + + + @pytest.mark.dependency(depends=["test_sai_vlan_attr_unknown_unicast_flood_control_type_set"]) + def test_sai_vlan_attr_unknown_unicast_flood_control_type_get(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "get", + "attributes": ["SAI_VLAN_ATTR_UNKNOWN_UNICAST_FLOOD_CONTROL_TYPE"] + } + ] + 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_VLAN_FLOOD_CONTROL_TYPE_ALL', 'Get error, expected SAI_VLAN_FLOOD_CONTROL_TYPE_ALL but got %s' % r_value + + + @pytest.mark.dependency(name="test_sai_vlan_attr_unknown_unicast_flood_group_set") + def test_sai_vlan_attr_unknown_unicast_flood_group_set(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "set", + "attributes": ["SAI_VLAN_ATTR_UNKNOWN_UNICAST_FLOOD_GROUP", 'SAI_NULL_OBJECT_ID'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + pprint(results) + + + + @pytest.mark.dependency(depends=["test_sai_vlan_attr_unknown_unicast_flood_group_set"]) + def test_sai_vlan_attr_unknown_unicast_flood_group_get(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "get", + "attributes": ["SAI_VLAN_ATTR_UNKNOWN_UNICAST_FLOOD_GROUP"] + } + ] + 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_NULL_OBJECT_ID', 'Get error, expected SAI_NULL_OBJECT_ID but got %s' % r_value + + + @pytest.mark.dependency(name="test_sai_vlan_attr_unknown_multicast_flood_control_type_set") + def test_sai_vlan_attr_unknown_multicast_flood_control_type_set(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "set", + "attributes": ["SAI_VLAN_ATTR_UNKNOWN_MULTICAST_FLOOD_CONTROL_TYPE", 'SAI_VLAN_FLOOD_CONTROL_TYPE_ALL'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + pprint(results) + + + + @pytest.mark.dependency(depends=["test_sai_vlan_attr_unknown_multicast_flood_control_type_set"]) + def test_sai_vlan_attr_unknown_multicast_flood_control_type_get(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "get", + "attributes": ["SAI_VLAN_ATTR_UNKNOWN_MULTICAST_FLOOD_CONTROL_TYPE"] + } + ] + 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_VLAN_FLOOD_CONTROL_TYPE_ALL', 'Get error, expected SAI_VLAN_FLOOD_CONTROL_TYPE_ALL but got %s' % r_value + + + @pytest.mark.dependency(name="test_sai_vlan_attr_unknown_multicast_flood_group_set") + def test_sai_vlan_attr_unknown_multicast_flood_group_set(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "set", + "attributes": ["SAI_VLAN_ATTR_UNKNOWN_MULTICAST_FLOOD_GROUP", 'SAI_NULL_OBJECT_ID'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + pprint(results) + + + + @pytest.mark.dependency(depends=["test_sai_vlan_attr_unknown_multicast_flood_group_set"]) + def test_sai_vlan_attr_unknown_multicast_flood_group_get(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "get", + "attributes": ["SAI_VLAN_ATTR_UNKNOWN_MULTICAST_FLOOD_GROUP"] + } + ] + 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_NULL_OBJECT_ID', 'Get error, expected SAI_NULL_OBJECT_ID but got %s' % r_value + + + @pytest.mark.dependency(name="test_sai_vlan_attr_broadcast_flood_control_type_set") + def test_sai_vlan_attr_broadcast_flood_control_type_set(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "set", + "attributes": ["SAI_VLAN_ATTR_BROADCAST_FLOOD_CONTROL_TYPE", 'SAI_VLAN_FLOOD_CONTROL_TYPE_ALL'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + pprint(results) + + + + @pytest.mark.dependency(depends=["test_sai_vlan_attr_broadcast_flood_control_type_set"]) + def test_sai_vlan_attr_broadcast_flood_control_type_get(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "get", + "attributes": ["SAI_VLAN_ATTR_BROADCAST_FLOOD_CONTROL_TYPE"] + } + ] + 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_VLAN_FLOOD_CONTROL_TYPE_ALL', 'Get error, expected SAI_VLAN_FLOOD_CONTROL_TYPE_ALL but got %s' % r_value + + + @pytest.mark.dependency(name="test_sai_vlan_attr_broadcast_flood_group_set") + def test_sai_vlan_attr_broadcast_flood_group_set(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "set", + "attributes": ["SAI_VLAN_ATTR_BROADCAST_FLOOD_GROUP", 'SAI_NULL_OBJECT_ID'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + pprint(results) + + + + @pytest.mark.dependency(depends=["test_sai_vlan_attr_broadcast_flood_group_set"]) + def test_sai_vlan_attr_broadcast_flood_group_get(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "get", + "attributes": ["SAI_VLAN_ATTR_BROADCAST_FLOOD_GROUP"] + } + ] + 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_NULL_OBJECT_ID', 'Get error, expected SAI_NULL_OBJECT_ID but got %s' % r_value + + + @pytest.mark.dependency(name="test_sai_vlan_attr_custom_igmp_snooping_enable_set") + def test_sai_vlan_attr_custom_igmp_snooping_enable_set(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "set", + "attributes": ["SAI_VLAN_ATTR_CUSTOM_IGMP_SNOOPING_ENABLE", 'false'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + pprint(results) + + + + @pytest.mark.dependency(depends=["test_sai_vlan_attr_custom_igmp_snooping_enable_set"]) + def test_sai_vlan_attr_custom_igmp_snooping_enable_get(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "get", + "attributes": ["SAI_VLAN_ATTR_CUSTOM_IGMP_SNOOPING_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_vlan_attr_tam_object_set") + def test_sai_vlan_attr_tam_object_set(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "set", + "attributes": ["SAI_VLAN_ATTR_TAM_OBJECT", 'empty'] + } + ] + results = [*npu.process_commands(commands)] + print("======= SAI commands RETURN values set =======") + pprint(results) + + + + @pytest.mark.dependency(depends=["test_sai_vlan_attr_tam_object_set"]) + def test_sai_vlan_attr_tam_object_get(self, npu): + + commands = [ + { + "name": "vlan_1", + "op": "get", + "attributes": ["SAI_VLAN_ATTR_TAM_OBJECT"] + } + ] + 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 == 'empty', 'Get error, expected empty 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 =======') pprint(results) + diff --git a/tests/api/test_wred.py b/tests/api/test_wred.py index 5a809f14..c4bfe06b 100644 --- a/tests/api/test_wred.py +++ b/tests/api/test_wred.py @@ -1,5 +1,19 @@ from pprint import pprint +import pytest + + +@pytest.fixture(scope="module", autouse=True) +def discovery(npu): + npu.objects_discovery() + + +@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)) + class TestSaiWred: # object with no attributes @@ -18,13 +32,715 @@ def test_wred_create(self, npu): print('======= SAI commands RETURN values create =======') pprint(results) - def test_wred_remove(self, npu): + @pytest.mark.dependency(name='test_sai_wred_attr_green_enable_set') + def test_sai_wred_attr_green_enable_set(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'set', + 'attributes': ['SAI_WRED_ATTR_GREEN_ENABLE', 'false'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_wred_attr_green_enable_set']) + def test_sai_wred_attr_green_enable_get(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'get', + 'attributes': ['SAI_WRED_ATTR_GREEN_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_wred_attr_green_min_threshold_set') + def test_sai_wred_attr_green_min_threshold_set(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'set', + 'attributes': ['SAI_WRED_ATTR_GREEN_MIN_THRESHOLD', '0'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_wred_attr_green_min_threshold_set']) + def test_sai_wred_attr_green_min_threshold_get(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'get', + 'attributes': ['SAI_WRED_ATTR_GREEN_MIN_THRESHOLD'], + } + ] + 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_wred_attr_green_max_threshold_set') + def test_sai_wred_attr_green_max_threshold_set(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'set', + 'attributes': ['SAI_WRED_ATTR_GREEN_MAX_THRESHOLD', '0'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_wred_attr_green_max_threshold_set']) + def test_sai_wred_attr_green_max_threshold_get(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'get', + 'attributes': ['SAI_WRED_ATTR_GREEN_MAX_THRESHOLD'], + } + ] + 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_wred_attr_green_drop_probability_set') + def test_sai_wred_attr_green_drop_probability_set(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'set', + 'attributes': ['SAI_WRED_ATTR_GREEN_DROP_PROBABILITY', '100'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_wred_attr_green_drop_probability_set']) + def test_sai_wred_attr_green_drop_probability_get(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'get', + 'attributes': ['SAI_WRED_ATTR_GREEN_DROP_PROBABILITY'], + } + ] + 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 == '100', 'Get error, expected 100 but got %s' % r_value + + @pytest.mark.dependency(name='test_sai_wred_attr_yellow_enable_set') + def test_sai_wred_attr_yellow_enable_set(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'set', + 'attributes': ['SAI_WRED_ATTR_YELLOW_ENABLE', 'false'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_wred_attr_yellow_enable_set']) + def test_sai_wred_attr_yellow_enable_get(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'get', + 'attributes': ['SAI_WRED_ATTR_YELLOW_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_wred_attr_yellow_min_threshold_set') + def test_sai_wred_attr_yellow_min_threshold_set(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'set', + 'attributes': ['SAI_WRED_ATTR_YELLOW_MIN_THRESHOLD', '0'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_wred_attr_yellow_min_threshold_set']) + def test_sai_wred_attr_yellow_min_threshold_get(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'get', + 'attributes': ['SAI_WRED_ATTR_YELLOW_MIN_THRESHOLD'], + } + ] + 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_wred_attr_yellow_max_threshold_set') + def test_sai_wred_attr_yellow_max_threshold_set(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'set', + 'attributes': ['SAI_WRED_ATTR_YELLOW_MAX_THRESHOLD', '0'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_wred_attr_yellow_max_threshold_set']) + def test_sai_wred_attr_yellow_max_threshold_get(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'get', + 'attributes': ['SAI_WRED_ATTR_YELLOW_MAX_THRESHOLD'], + } + ] + 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_wred_attr_yellow_drop_probability_set') + def test_sai_wred_attr_yellow_drop_probability_set(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'set', + 'attributes': ['SAI_WRED_ATTR_YELLOW_DROP_PROBABILITY', '100'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_wred_attr_yellow_drop_probability_set']) + def test_sai_wred_attr_yellow_drop_probability_get(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'get', + 'attributes': ['SAI_WRED_ATTR_YELLOW_DROP_PROBABILITY'], + } + ] + 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 == '100', 'Get error, expected 100 but got %s' % r_value + + @pytest.mark.dependency(name='test_sai_wred_attr_red_enable_set') + def test_sai_wred_attr_red_enable_set(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'set', + 'attributes': ['SAI_WRED_ATTR_RED_ENABLE', 'false'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_wred_attr_red_enable_set']) + def test_sai_wred_attr_red_enable_get(self, npu): + commands = [ + {'name': 'wred_1', 'op': 'get', 'attributes': ['SAI_WRED_ATTR_RED_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_wred_attr_red_min_threshold_set') + def test_sai_wred_attr_red_min_threshold_set(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'set', + 'attributes': ['SAI_WRED_ATTR_RED_MIN_THRESHOLD', '0'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_wred_attr_red_min_threshold_set']) + def test_sai_wred_attr_red_min_threshold_get(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'get', + 'attributes': ['SAI_WRED_ATTR_RED_MIN_THRESHOLD'], + } + ] + 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_wred_attr_red_max_threshold_set') + def test_sai_wred_attr_red_max_threshold_set(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'set', + 'attributes': ['SAI_WRED_ATTR_RED_MAX_THRESHOLD', '0'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_wred_attr_red_max_threshold_set']) + def test_sai_wred_attr_red_max_threshold_get(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'get', + 'attributes': ['SAI_WRED_ATTR_RED_MAX_THRESHOLD'], + } + ] + 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_wred_attr_red_drop_probability_set') + def test_sai_wred_attr_red_drop_probability_set(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'set', + 'attributes': ['SAI_WRED_ATTR_RED_DROP_PROBABILITY', '100'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_wred_attr_red_drop_probability_set']) + def test_sai_wred_attr_red_drop_probability_get(self, npu): commands = [ { 'name': 'wred_1', - 'op': 'remove', + 'op': 'get', + 'attributes': ['SAI_WRED_ATTR_RED_DROP_PROBABILITY'], } ] + 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 == '100', 'Get error, expected 100 but got %s' % r_value + + @pytest.mark.dependency(name='test_sai_wred_attr_weight_set') + def test_sai_wred_attr_weight_set(self, npu): + commands = [ + {'name': 'wred_1', 'op': 'set', 'attributes': ['SAI_WRED_ATTR_WEIGHT', '0']} + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_wred_attr_weight_set']) + def test_sai_wred_attr_weight_get(self, npu): + commands = [ + {'name': 'wred_1', 'op': 'get', 'attributes': ['SAI_WRED_ATTR_WEIGHT']} + ] + 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_wred_attr_ecn_mark_mode_set') + def test_sai_wred_attr_ecn_mark_mode_set(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'set', + 'attributes': ['SAI_WRED_ATTR_ECN_MARK_MODE', 'SAI_ECN_MARK_MODE_NONE'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_wred_attr_ecn_mark_mode_set']) + def test_sai_wred_attr_ecn_mark_mode_get(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'get', + 'attributes': ['SAI_WRED_ATTR_ECN_MARK_MODE'], + } + ] + 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_ECN_MARK_MODE_NONE', ( + 'Get error, expected SAI_ECN_MARK_MODE_NONE but got %s' % r_value + ) + + @pytest.mark.dependency(name='test_sai_wred_attr_ecn_green_min_threshold_set') + def test_sai_wred_attr_ecn_green_min_threshold_set(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'set', + 'attributes': ['SAI_WRED_ATTR_ECN_GREEN_MIN_THRESHOLD', '0'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_wred_attr_ecn_green_min_threshold_set']) + def test_sai_wred_attr_ecn_green_min_threshold_get(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'get', + 'attributes': ['SAI_WRED_ATTR_ECN_GREEN_MIN_THRESHOLD'], + } + ] + 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_wred_attr_ecn_green_max_threshold_set') + def test_sai_wred_attr_ecn_green_max_threshold_set(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'set', + 'attributes': ['SAI_WRED_ATTR_ECN_GREEN_MAX_THRESHOLD', '0'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_wred_attr_ecn_green_max_threshold_set']) + def test_sai_wred_attr_ecn_green_max_threshold_get(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'get', + 'attributes': ['SAI_WRED_ATTR_ECN_GREEN_MAX_THRESHOLD'], + } + ] + 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_wred_attr_ecn_green_mark_probability_set') + def test_sai_wred_attr_ecn_green_mark_probability_set(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'set', + 'attributes': ['SAI_WRED_ATTR_ECN_GREEN_MARK_PROBABILITY', '100'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency( + depends=['test_sai_wred_attr_ecn_green_mark_probability_set'] + ) + def test_sai_wred_attr_ecn_green_mark_probability_get(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'get', + 'attributes': ['SAI_WRED_ATTR_ECN_GREEN_MARK_PROBABILITY'], + } + ] + 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 == '100', 'Get error, expected 100 but got %s' % r_value + + @pytest.mark.dependency(name='test_sai_wred_attr_ecn_yellow_min_threshold_set') + def test_sai_wred_attr_ecn_yellow_min_threshold_set(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'set', + 'attributes': ['SAI_WRED_ATTR_ECN_YELLOW_MIN_THRESHOLD', '0'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_wred_attr_ecn_yellow_min_threshold_set']) + def test_sai_wred_attr_ecn_yellow_min_threshold_get(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'get', + 'attributes': ['SAI_WRED_ATTR_ECN_YELLOW_MIN_THRESHOLD'], + } + ] + 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_wred_attr_ecn_yellow_max_threshold_set') + def test_sai_wred_attr_ecn_yellow_max_threshold_set(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'set', + 'attributes': ['SAI_WRED_ATTR_ECN_YELLOW_MAX_THRESHOLD', '0'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_wred_attr_ecn_yellow_max_threshold_set']) + def test_sai_wred_attr_ecn_yellow_max_threshold_get(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'get', + 'attributes': ['SAI_WRED_ATTR_ECN_YELLOW_MAX_THRESHOLD'], + } + ] + 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_wred_attr_ecn_yellow_mark_probability_set') + def test_sai_wred_attr_ecn_yellow_mark_probability_set(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'set', + 'attributes': ['SAI_WRED_ATTR_ECN_YELLOW_MARK_PROBABILITY', '100'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency( + depends=['test_sai_wred_attr_ecn_yellow_mark_probability_set'] + ) + def test_sai_wred_attr_ecn_yellow_mark_probability_get(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'get', + 'attributes': ['SAI_WRED_ATTR_ECN_YELLOW_MARK_PROBABILITY'], + } + ] + 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 == '100', 'Get error, expected 100 but got %s' % r_value + + @pytest.mark.dependency(name='test_sai_wred_attr_ecn_red_min_threshold_set') + def test_sai_wred_attr_ecn_red_min_threshold_set(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'set', + 'attributes': ['SAI_WRED_ATTR_ECN_RED_MIN_THRESHOLD', '0'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_wred_attr_ecn_red_min_threshold_set']) + def test_sai_wred_attr_ecn_red_min_threshold_get(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'get', + 'attributes': ['SAI_WRED_ATTR_ECN_RED_MIN_THRESHOLD'], + } + ] + 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_wred_attr_ecn_red_max_threshold_set') + def test_sai_wred_attr_ecn_red_max_threshold_set(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'set', + 'attributes': ['SAI_WRED_ATTR_ECN_RED_MAX_THRESHOLD', '0'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_wred_attr_ecn_red_max_threshold_set']) + def test_sai_wred_attr_ecn_red_max_threshold_get(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'get', + 'attributes': ['SAI_WRED_ATTR_ECN_RED_MAX_THRESHOLD'], + } + ] + 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_wred_attr_ecn_red_mark_probability_set') + def test_sai_wred_attr_ecn_red_mark_probability_set(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'set', + 'attributes': ['SAI_WRED_ATTR_ECN_RED_MARK_PROBABILITY', '100'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_wred_attr_ecn_red_mark_probability_set']) + def test_sai_wred_attr_ecn_red_mark_probability_get(self, npu): + commands = [ + { + 'name': 'wred_1', + 'op': 'get', + 'attributes': ['SAI_WRED_ATTR_ECN_RED_MARK_PROBABILITY'], + } + ] + 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 == '100', 'Get error, expected 100 but got %s' % r_value + + def test_wred_remove(self, npu): + commands = [{'name': 'wred_1', 'op': 'remove'}] results = [*npu.process_commands(commands)] print('======= SAI commands RETURN values remove =======')