From ad9cd557fe199acfbdb54f09843186808cc009a8 Mon Sep 17 00:00:00 2001 From: Dinesh Kumar Sellappan <40899231+selldinesh@users.noreply.github.com> Date: Thu, 5 Oct 2023 08:57:25 -0700 Subject: [PATCH] Adding additional set of pass cases in tofino (#25) * Add LAG hash seed test-case (#184) Signed-off-by: Yurii Lisovskyi Signed-off-by: selldinesh * adding additional create remove cases (#14) Signed-off-by: selldinesh * removing switch tunnel Signed-off-by: selldinesh * resolving PR comments and merge conflict Signed-off-by: selldinesh * resolving precommit checks Signed-off-by: selldinesh * reverting sai and l2 basic Signed-off-by: selldinesh * Fixed u8/u16 and range Thrift conversions (#188) Signed-off-by: Andriy Kokhan Signed-off-by: selldinesh * Updated PTF use-case. Enabled PTF TCs run from CI/CD (#189) Signed-off-by: Andriy Kokhan Signed-off-by: selldinesh * Fix oper status check (#192) Signed-off-by: Yurii Lisovskyi Signed-off-by: selldinesh * Added support for string SAI_NULL_OBJECT_ID for Thrift RPC (#194) Signed-off-by: Vinod Kumar Signed-off-by: selldinesh * Remove unnecessary adding BPs to default VLAN on init (#193) Signed-off-by: Yurii Lisovskyi Signed-off-by: selldinesh * Adding new DASH TCs for create, set and remove API (#195) Signed-off-by: Vinod Kumar Signed-off-by: selldinesh * Adding new DASH TCs for create, set and remove API 2nd set (#197) Signed-off-by: Vinod Kumar Signed-off-by: selldinesh * Fixed set_sku_mode() (#198) Signed-off-by: Andriy Kokhan Signed-off-by: selldinesh * Added FDB basic UTs (#199) Signed-off-by: Andriy Kokhan Signed-off-by: selldinesh * Added LAG basic UTs (#200) Signed-off-by: Andriy Kokhan Signed-off-by: selldinesh * Added FDB flush UTs (#201) Signed-off-by: Andriy Kokhan Signed-off-by: selldinesh * [CI/CD] Fixed checks what Docker images have to be rebuild (#206) Signed-off-by: Andriy Kokhan Signed-off-by: selldinesh * Updated to SAI v1.13+ (#205) * Added nlohmann-json3-dev as new sairedis dependency * Extended list of unsupported types in get_by_type() --------- Signed-off-by: Andriy Kokhan Signed-off-by: selldinesh * Fixed pytest warnings (#207) Signed-off-by: Andriy Kokhan Signed-off-by: selldinesh * Refactored Redis RPC I/O failure processing (#208) Signed-off-by: Andriy Kokhan Signed-off-by: selldinesh * Removed obsoleted exec option. Please use "--testbed" instead (#209) Signed-off-by: Andriy Kokhan Signed-off-by: selldinesh * Add generic SAI Thrift server (#203) Signed-off-by: Yurii Lisovskyi Signed-off-by: selldinesh * Fixed "--traffic" option behavior (#210) Signed-off-by: Andriy Kokhan Signed-off-by: selldinesh * line ending change Signed-off-by: selldinesh * adding additional tofino vs pass cases * adding skip all * pytest --------- Signed-off-by: Yurii Lisovskyi Signed-off-by: selldinesh Signed-off-by: Andriy Kokhan Signed-off-by: Vinod Kumar Signed-off-by: Andriy Kokhan Co-authored-by: Yurii Lisovskyi Co-authored-by: Andriy Kokhan Co-authored-by: vikumarks <119973184+vikumarks@users.noreply.github.com> Co-authored-by: Andriy Kokhan --- tests/api/test_acl_counter.py | 8 + tests/api/test_acl_entry.py | 10 + tests/api/test_acl_range.py | 10 + tests/api/test_acl_table.py | 10 + tests/api/test_acl_table_group.py | 10 + tests/api/test_acl_table_group_member.py | 10 + tests/api/test_ars.py | 35 ++ tests/api/test_ars_profile.py | 35 ++ tests/api/test_buffer_pool.py | 10 + tests/api/test_counter.py | 36 ++ tests/api/test_dash_acl_group.py | 56 -- tests/api/test_dash_acl_rule.py | 68 --- tests/api/test_debug_counter.py | 10 + tests/api/test_dtel.py | 218 ++++++++ tests/api/test_dtel_event.py | 39 ++ tests/api/test_dtel_int_session.py | 36 ++ tests/api/test_dtel_report_session.py | 36 ++ tests/api/test_eni.py | 489 ------------------ tests/api/test_eni_ether_address_map_entry.py | 71 --- tests/api/test_generic_programmable.py | 36 ++ tests/api/test_hash.py | 36 ++ tests/api/test_hostif_trap.py | 10 + tests/api/test_hostif_trap_group.py | 10 + tests/api/test_ipmc_group.py | 10 + tests/api/test_isolation_group.py | 10 + tests/api/test_isolation_group_member.py | 67 +++ tests/api/test_l2mc_group.py | 36 ++ tests/api/test_lag.py | 10 + tests/api/test_macsec.py | 39 ++ tests/api/test_macsec_flow.py | 39 ++ tests/api/test_nat_zone_counter.py | 36 ++ tests/api/test_next_hop_group.py | 24 +- tests/api/test_next_hop_group_map.py | 39 ++ tests/api/test_outbound_ca_to_pa_entry.py | 124 ----- tests/api/test_outbound_routing_entry.py | 132 ----- tests/api/test_policer.py | 10 + tests/api/test_rpf_group.py | 10 + tests/api/test_samplepacket.py | 10 + tests/api/test_scheduler.py | 10 + tests/api/test_stp.py | 10 + tests/api/test_tam.py | 36 ++ tests/api/test_tam_collector.py | 57 ++ tests/api/test_tunnel_map.py | 10 + tests/api/test_udf_group.py | 10 + tests/api/test_udf_match.py | 36 ++ tests/api/test_virtual_router.py | 72 ++- tests/api/test_vlan.py | 42 +- tests/api/test_wred.py | 9 + 48 files changed, 1231 insertions(+), 946 deletions(-) create mode 100644 tests/api/test_ars.py create mode 100644 tests/api/test_ars_profile.py create mode 100644 tests/api/test_counter.py delete mode 100644 tests/api/test_dash_acl_group.py delete mode 100644 tests/api/test_dash_acl_rule.py create mode 100644 tests/api/test_dtel.py create mode 100644 tests/api/test_dtel_event.py create mode 100644 tests/api/test_dtel_int_session.py create mode 100644 tests/api/test_dtel_report_session.py delete mode 100644 tests/api/test_eni.py delete mode 100644 tests/api/test_eni_ether_address_map_entry.py create mode 100644 tests/api/test_generic_programmable.py create mode 100644 tests/api/test_hash.py create mode 100644 tests/api/test_isolation_group_member.py create mode 100644 tests/api/test_l2mc_group.py create mode 100644 tests/api/test_macsec.py create mode 100644 tests/api/test_macsec_flow.py create mode 100644 tests/api/test_nat_zone_counter.py create mode 100644 tests/api/test_next_hop_group_map.py delete mode 100644 tests/api/test_outbound_ca_to_pa_entry.py delete mode 100644 tests/api/test_outbound_routing_entry.py create mode 100644 tests/api/test_tam.py create mode 100644 tests/api/test_tam_collector.py create mode 100644 tests/api/test_udf_match.py diff --git a/tests/api/test_acl_counter.py b/tests/api/test_acl_counter.py index fb65afe3..f2a6409e 100644 --- a/tests/api/test_acl_counter.py +++ b/tests/api/test_acl_counter.py @@ -1,6 +1,14 @@ 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 TestSaiAclCounter: # object with parent SAI_OBJECT_TYPE_ACL_TABLE diff --git a/tests/api/test_acl_entry.py b/tests/api/test_acl_entry.py index 3bef4673..9fa514e5 100644 --- a/tests/api/test_acl_entry.py +++ b/tests/api/test_acl_entry.py @@ -1,6 +1,16 @@ from pprint import pprint +import pytest + +@pytest.fixture(scope='module', autouse=True) +def skip_all(testbed_instance): + testbed = testbed_instance + if testbed is not None and len(testbed.npu) != 1: + pytest.skip('invalid for {} testbed'.format(testbed.name)) + + +@pytest.mark.npu class TestSaiAclEntry: # object with parent SAI_OBJECT_TYPE_ACL_TABLE diff --git a/tests/api/test_acl_range.py b/tests/api/test_acl_range.py index 3bdc5779..711fba0e 100644 --- a/tests/api/test_acl_range.py +++ b/tests/api/test_acl_range.py @@ -1,6 +1,16 @@ from pprint import pprint +import pytest + +@pytest.fixture(scope='module', autouse=True) +def skip_all(testbed_instance): + testbed = testbed_instance + if testbed is not None and len(testbed.npu) != 1: + pytest.skip('invalid for {} testbed'.format(testbed.name)) + + +@pytest.mark.npu class TestSaiAclRange: # object with no parents diff --git a/tests/api/test_acl_table.py b/tests/api/test_acl_table.py index 707d1919..e847598a 100644 --- a/tests/api/test_acl_table.py +++ b/tests/api/test_acl_table.py @@ -1,6 +1,16 @@ from pprint import pprint +import pytest + +@pytest.fixture(scope='module', autouse=True) +def skip_all(testbed_instance): + testbed = testbed_instance + if testbed is not None and len(testbed.npu) != 1: + pytest.skip('invalid for {} testbed'.format(testbed.name)) + + +@pytest.mark.npu class TestSaiAclTable: # object with no parents diff --git a/tests/api/test_acl_table_group.py b/tests/api/test_acl_table_group.py index 27d0928b..54598f98 100644 --- a/tests/api/test_acl_table_group.py +++ b/tests/api/test_acl_table_group.py @@ -1,6 +1,16 @@ from pprint import pprint +import pytest + +@pytest.fixture(scope='module', autouse=True) +def skip_all(testbed_instance): + testbed = testbed_instance + if testbed is not None and len(testbed.npu) != 1: + pytest.skip('invalid for {} testbed'.format(testbed.name)) + + +@pytest.mark.npu class TestSaiAclTableGroup: # object with no parents diff --git a/tests/api/test_acl_table_group_member.py b/tests/api/test_acl_table_group_member.py index e1f717b6..bfe678a0 100644 --- a/tests/api/test_acl_table_group_member.py +++ b/tests/api/test_acl_table_group_member.py @@ -1,6 +1,16 @@ from pprint import pprint +import pytest + +@pytest.fixture(scope='module', autouse=True) +def skip_all(testbed_instance): + testbed = testbed_instance + if testbed is not None and len(testbed.npu) != 1: + pytest.skip('invalid for {} testbed'.format(testbed.name)) + + +@pytest.mark.npu class TestSaiAclTableGroupMember: # object with parent SAI_OBJECT_TYPE_ACL_TABLE_GROUP SAI_OBJECT_TYPE_ACL_TABLE diff --git a/tests/api/test_ars.py b/tests/api/test_ars.py new file mode 100644 index 00000000..d4d3b9dd --- /dev/null +++ b/tests/api/test_ars.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 TestSaiArs: + # object with no attributes + + def test_ars_create(self, npu): + commands = [ + { + 'name': 'ars_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_ARS', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_ars_remove(self, npu): + commands = [{'name': 'ars_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_ars_profile.py b/tests/api/test_ars_profile.py new file mode 100644 index 00000000..6871ce42 --- /dev/null +++ b/tests/api/test_ars_profile.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 TestSaiArsProfile: + # object with no attributes + + def test_ars_profile_create(self, npu): + commands = [ + { + 'name': 'ars_profile_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_ARS_PROFILE', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_ars_profile_remove(self, npu): + commands = [{'name': 'ars_profile_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_buffer_pool.py b/tests/api/test_buffer_pool.py index 9584ee11..2114394e 100644 --- a/tests/api/test_buffer_pool.py +++ b/tests/api/test_buffer_pool.py @@ -1,6 +1,16 @@ from pprint import pprint +import pytest + +@pytest.fixture(scope='module', autouse=True) +def skip_all(testbed_instance): + testbed = testbed_instance + if testbed is not None and len(testbed.npu) != 1: + pytest.skip('invalid for {} testbed'.format(testbed.name)) + + +@pytest.mark.npu class TestSaiBufferPool: # object with no parents diff --git a/tests/api/test_counter.py b/tests/api/test_counter.py new file mode 100644 index 00000000..c01c951c --- /dev/null +++ b/tests/api/test_counter.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 TestSaiCounter: + # object with no attributes + + def test_counter_create(self, npu): + commands = [ + { + 'name': 'counter_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_COUNTER', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_counter_remove(self, npu): + commands = [{'name': 'counter_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_dash_acl_group.py b/tests/api/test_dash_acl_group.py deleted file mode 100644 index 3551a051..00000000 --- a/tests/api/test_dash_acl_group.py +++ /dev/null @@ -1,56 +0,0 @@ - -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.dpu) != 1: - pytest.skip("invalid for \"{}\" testbed".format(testbed.name)) - -@pytest.mark.dpu -class TestSaiDashAclGroup: - # object with no attributes - - def test_dash_acl_group_create(self, dpu): - #Attribs are not marked mandatory but if we dont gives it throws an error - commands = [ - { - 'name': 'dash_acl_group_1', - 'op': 'create', - 'type': 'SAI_OBJECT_TYPE_DASH_ACL_GROUP', - 'attributes': ["SAI_DASH_ACL_GROUP_ATTR_IP_ADDR_FAMILY","SAI_IP_ADDR_FAMILY_IPV4"] - } - ] - - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values create =======') - pprint(results) - - - - @pytest.mark.dependency(name="test_sai_dash_acl_group_attr_ip_addr_family_set") - def test_sai_dash_acl_group_attr_ip_addr_family_set(self, dpu): - - commands = [ - { - "name": "dash_acl_group_1", - "op": "set", - "attributes": ["SAI_DASH_ACL_GROUP_ATTR_IP_ADDR_FAMILY", 'SAI_IP_ADDR_FAMILY_IPV4'] - } - ] - results = [*dpu.process_commands(commands)] - print("======= SAI commands RETURN values get =======") - pprint(results) - - - - def test_dash_acl_group_remove(self, dpu): - - commands = [{'name': 'dash_acl_group_1', 'op': 'remove'}] - - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values remove =======') - pprint(results) - diff --git a/tests/api/test_dash_acl_rule.py b/tests/api/test_dash_acl_rule.py deleted file mode 100644 index 2cfd3986..00000000 --- a/tests/api/test_dash_acl_rule.py +++ /dev/null @@ -1,68 +0,0 @@ -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.dpu) != 1: - pytest.skip("invalid for \"{}\" testbed".format(testbed.name)) - -@pytest.mark.dpu -class TestSaiDashAclRule: - # object with parent SAI_OBJECT_TYPE_DASH_ACL_GROUP - - def test_dash_acl_rule_create(self, dpu): - commands = [ - { - 'name': 'dash_acl_group_1', - 'op': 'create', - 'type': 'SAI_OBJECT_TYPE_DASH_ACL_GROUP', - 'attributes': ['SAI_DASH_ACL_GROUP_ATTR_IP_ADDR_FAMILY', 'SAI_IP_ADDR_FAMILY_IPV4',], - }, - { - 'name': 'dash_acl_rule_1', - 'op': 'create', - 'type': 'SAI_OBJECT_TYPE_DASH_ACL_RULE', - 'attributes': [ - 'SAI_DASH_ACL_RULE_ATTR_DASH_ACL_GROUP_ID','$dash_acl_group_1', - 'SAI_DASH_ACL_RULE_ATTR_DIP','1.1.1.1', - 'SAI_DASH_ACL_RULE_ATTR_SIP','2.2.2.2', - 'SAI_DASH_ACL_RULE_ATTR_PROTOCOL','17', - 'SAI_DASH_ACL_RULE_ATTR_SRC_PORT','5678', - 'SAI_DASH_ACL_RULE_ATTR_DST_PORT','8765', - 'SAI_DASH_ACL_RULE_ATTR_PRIORITY','10', - ], - }, - ] - - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values create =======') - pprint(results) - - @pytest.mark.dependency(name='test_sai_dash_acl_rule_attr_action_set') - def test_sai_dash_acl_rule_attr_action_set(self, dpu): - commands = [ - { - 'name': 'dash_acl_rule_1', - 'op': 'set', - 'attributes': [ - 'SAI_DASH_ACL_RULE_ATTR_ACTION', - 'SAI_DASH_ACL_RULE_ACTION_PERMIT', - ], - } - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values set =======') - pprint(results) - - - def test_dash_acl_rule_remove(self, dpu): - commands = [ - {'name': 'dash_acl_rule_1', 'op': 'remove'}, - {'name': 'dash_acl_group_1', 'op': 'remove'}, - ] - - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values remove =======') - pprint(results) diff --git a/tests/api/test_debug_counter.py b/tests/api/test_debug_counter.py index d4c566a3..1f41734d 100644 --- a/tests/api/test_debug_counter.py +++ b/tests/api/test_debug_counter.py @@ -1,6 +1,16 @@ from pprint import pprint +import pytest + +@pytest.fixture(scope='module', autouse=True) +def skip_all(testbed_instance): + testbed = testbed_instance + if testbed is not None and len(testbed.npu) != 1: + pytest.skip('invalid for {} testbed'.format(testbed.name)) + + +@pytest.mark.npu class TestSaiDebugCounter: # object with no parents diff --git a/tests/api/test_dtel.py b/tests/api/test_dtel.py new file mode 100644 index 00000000..309d5563 --- /dev/null +++ b/tests/api/test_dtel.py @@ -0,0 +1,218 @@ +from pprint import pprint + +import pytest + + +@pytest.fixture(scope='module', autouse=True) +def skip_all(testbed_instance): + testbed = testbed_instance + if testbed is not None and len(testbed.npu) != 1: + pytest.skip('invalid for {} testbed'.format(testbed.name)) + + +@pytest.mark.npu +class TestSaiDtel: + # object with no attributes + + def test_dtel_create(self, npu): + commands = [ + { + 'name': 'dtel_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_DTEL', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + @pytest.mark.dependency(name='test_sai_dtel_attr_postcard_enable_set') + def test_sai_dtel_attr_postcard_enable_set(self, npu): + commands = [ + { + 'name': 'dtel_1', + 'op': 'set', + 'attributes': ['SAI_DTEL_ATTR_POSTCARD_ENABLE', 'false'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values set =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_dtel_attr_postcard_enable_set']) + def test_sai_dtel_attr_postcard_enable_get(self, npu): + commands = [ + { + 'name': 'dtel_1', + 'op': 'get', + 'attributes': ['SAI_DTEL_ATTR_POSTCARD_ENABLE'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + for command in results: + for attribute in command: + pprint(attribute.raw()) + r_value = results[0][0].value() + print(r_value) + assert r_value == 'false', 'Get error, expected false but got %s' % r_value + + @pytest.mark.dependency(name='test_sai_dtel_attr_drop_report_enable_set') + def test_sai_dtel_attr_drop_report_enable_set(self, npu): + commands = [ + { + 'name': 'dtel_1', + 'op': 'set', + 'attributes': ['SAI_DTEL_ATTR_DROP_REPORT_ENABLE', 'false'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values set =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_dtel_attr_drop_report_enable_set']) + def test_sai_dtel_attr_drop_report_enable_get(self, npu): + commands = [ + { + 'name': 'dtel_1', + 'op': 'get', + 'attributes': ['SAI_DTEL_ATTR_DROP_REPORT_ENABLE'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + for command in results: + for attribute in command: + pprint(attribute.raw()) + r_value = results[0][0].value() + print(r_value) + assert r_value == 'false', 'Get error, expected false but got %s' % r_value + + @pytest.mark.dependency(name='test_sai_dtel_attr_queue_report_enable_set') + def test_sai_dtel_attr_queue_report_enable_set(self, npu): + commands = [ + { + 'name': 'dtel_1', + 'op': 'set', + 'attributes': ['SAI_DTEL_ATTR_QUEUE_REPORT_ENABLE', 'false'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values set =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_dtel_attr_queue_report_enable_set']) + def test_sai_dtel_attr_queue_report_enable_get(self, npu): + commands = [ + { + 'name': 'dtel_1', + 'op': 'get', + 'attributes': ['SAI_DTEL_ATTR_QUEUE_REPORT_ENABLE'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + for command in results: + for attribute in command: + pprint(attribute.raw()) + r_value = results[0][0].value() + print(r_value) + assert r_value == 'false', 'Get error, expected false but got %s' % r_value + + @pytest.mark.dependency(name='test_sai_dtel_attr_switch_id_set') + def test_sai_dtel_attr_switch_id_set(self, npu): + commands = [ + { + 'name': 'dtel_1', + 'op': 'set', + 'attributes': ['SAI_DTEL_ATTR_SWITCH_ID', '0'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values set =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_dtel_attr_switch_id_set']) + def test_sai_dtel_attr_switch_id_get(self, npu): + commands = [ + {'name': 'dtel_1', 'op': 'get', 'attributes': ['SAI_DTEL_ATTR_SWITCH_ID']} + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + for command in results: + for attribute in command: + pprint(attribute.raw()) + r_value = results[0][0].value() + print(r_value) + assert r_value == '0', 'Get error, expected 0 but got %s' % r_value + + @pytest.mark.dependency(name='test_sai_dtel_attr_flow_state_clear_cycle_set') + def test_sai_dtel_attr_flow_state_clear_cycle_set(self, npu): + commands = [ + { + 'name': 'dtel_1', + 'op': 'set', + 'attributes': ['SAI_DTEL_ATTR_FLOW_STATE_CLEAR_CYCLE', '0'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values set =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_dtel_attr_flow_state_clear_cycle_set']) + def test_sai_dtel_attr_flow_state_clear_cycle_get(self, npu): + commands = [ + { + 'name': 'dtel_1', + 'op': 'get', + 'attributes': ['SAI_DTEL_ATTR_FLOW_STATE_CLEAR_CYCLE'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + for command in results: + for attribute in command: + pprint(attribute.raw()) + r_value = results[0][0].value() + print(r_value) + assert r_value == '0', 'Get error, expected 0 but got %s' % r_value + + @pytest.mark.dependency(name='test_sai_dtel_attr_latency_sensitivity_set') + def test_sai_dtel_attr_latency_sensitivity_set(self, npu): + commands = [ + { + 'name': 'dtel_1', + 'op': 'set', + 'attributes': ['SAI_DTEL_ATTR_LATENCY_SENSITIVITY', '0'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values set =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_dtel_attr_latency_sensitivity_set']) + def test_sai_dtel_attr_latency_sensitivity_get(self, npu): + commands = [ + { + 'name': 'dtel_1', + 'op': 'get', + 'attributes': ['SAI_DTEL_ATTR_LATENCY_SENSITIVITY'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + for command in results: + for attribute in command: + pprint(attribute.raw()) + r_value = results[0][0].value() + print(r_value) + assert r_value == '0', 'Get error, expected 0 but got %s' % r_value + + def test_dtel_remove(self, npu): + commands = [{'name': 'dtel_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_dtel_event.py b/tests/api/test_dtel_event.py new file mode 100644 index 00000000..da60b056 --- /dev/null +++ b/tests/api/test_dtel_event.py @@ -0,0 +1,39 @@ +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 TestSaiDtelEvent: + # object with no parents + + def test_dtel_event_create(self, npu): + commands = [ + { + 'name': 'dtel_event_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_DTEL_EVENT', + 'attributes': [ + 'SAI_DTEL_EVENT_ATTR_TYPE', + 'SAI_DTEL_EVENT_TYPE_FLOW_STATE', + ], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_dtel_event_remove(self, npu): + commands = [{'name': 'dtel_event_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_dtel_int_session.py b/tests/api/test_dtel_int_session.py new file mode 100644 index 00000000..50e0baec --- /dev/null +++ b/tests/api/test_dtel_int_session.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 TestSaiDtelIntSession: + # object with no attributes + + def test_dtel_int_session_create(self, npu): + commands = [ + { + 'name': 'dtel_int_session_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_DTEL_INT_SESSION', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_dtel_int_session_remove(self, npu): + commands = [{'name': 'dtel_int_session_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_dtel_report_session.py b/tests/api/test_dtel_report_session.py new file mode 100644 index 00000000..458cc124 --- /dev/null +++ b/tests/api/test_dtel_report_session.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 TestSaiDtelReportSession: + # object with no attributes + + def test_dtel_report_session_create(self, npu): + commands = [ + { + 'name': 'dtel_report_session_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_DTEL_REPORT_SESSION', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_dtel_report_session_remove(self, npu): + commands = [{'name': 'dtel_report_session_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_eni.py b/tests/api/test_eni.py deleted file mode 100644 index e420e991..00000000 --- a/tests/api/test_eni.py +++ /dev/null @@ -1,489 +0,0 @@ -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.dpu) != 1: - pytest.skip("invalid for \"{}\" testbed".format(testbed.name)) - -@pytest.mark.dpu -class TestSaiEni: - # object with no attributes - - def test_eni_create(self, dpu): - commands = [ - {"name": "vnet","op": "create","type": "SAI_OBJECT_TYPE_VNET","attributes": ["SAI_VNET_ATTR_VNI","2000"]}, - { - "name": "eni_1", - "op": "create", - "type": "SAI_OBJECT_TYPE_ENI", - "attributes": [ - "SAI_ENI_ATTR_ADMIN_STATE","True", - "SAI_ENI_ATTR_VM_UNDERLAY_DIP","10.10.1.10", - "SAI_ENI_ATTR_VM_VNI","2000", - "SAI_ENI_ATTR_VNET_ID","$vnet", - ] - } - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values create =======') - pprint(results) - - - @pytest.mark.dependency(name='test_sai_eni_attr_cps_set') - def test_sai_eni_attr_cps_set(self, dpu): - commands = [ - {'name': 'eni_1', 'op': 'set', 'attributes': ['SAI_ENI_ATTR_CPS', '0']} - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - - @pytest.mark.dependency(name='test_sai_eni_attr_pps_set') - def test_sai_eni_attr_pps_set(self, dpu): - commands = [ - {'name': 'eni_1', 'op': 'set', 'attributes': ['SAI_ENI_ATTR_PPS', '0']} - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - @pytest.mark.dependency(name='test_sai_eni_attr_flows_set') - def test_sai_eni_attr_flows_set(self, dpu): - commands = [ - {'name': 'eni_1', 'op': 'set', 'attributes': ['SAI_ENI_ATTR_FLOWS', '0']} - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - @pytest.mark.dependency(name='test_sai_eni_attr_admin_state_set') - def test_sai_eni_attr_admin_state_set(self, dpu): - commands = [ - { - 'name': 'eni_1', - 'op': 'set', - 'attributes': ['SAI_ENI_ATTR_ADMIN_STATE', 'false'], - } - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - @pytest.mark.dependency(name='test_sai_eni_attr_vm_underlay_dip_set') - def test_sai_eni_attr_vm_underlay_dip_set(self, dpu): - commands = [ - { - 'name': 'eni_1', - 'op': 'set', - 'attributes': ['SAI_ENI_ATTR_VM_UNDERLAY_DIP', '0.0.0.0'], - } - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - @pytest.mark.dependency(name='test_sai_eni_attr_vm_vni_set') - def test_sai_eni_attr_vm_vni_set(self, dpu): - commands = [ - {'name': 'eni_1', 'op': 'set', 'attributes': ['SAI_ENI_ATTR_VM_VNI', '0']} - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - @pytest.mark.dependency(name='test_sai_eni_attr_vnet_id_set') - def test_sai_eni_attr_vnet_id_set(self, dpu): - commands = [ - { - 'name': 'eni_1', - 'op': 'set', - 'attributes': ['SAI_ENI_ATTR_VNET_ID', 'null'], - } - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - @pytest.mark.dependency( - name='test_sai_eni_attr_inbound_v4_stage1_dash_acl_group_id_set' - ) - def test_sai_eni_attr_inbound_v4_stage1_dash_acl_group_id_set(self, dpu): - commands = [ - { - 'name': 'eni_1', - 'op': 'set', - 'attributes': [ - 'SAI_ENI_ATTR_INBOUND_V4_STAGE1_DASH_ACL_GROUP_ID', - 'null', - ], - } - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - @pytest.mark.dependency( - name='test_sai_eni_attr_inbound_v4_stage2_dash_acl_group_id_set' - ) - def test_sai_eni_attr_inbound_v4_stage2_dash_acl_group_id_set(self, dpu): - commands = [ - { - 'name': 'eni_1', - 'op': 'set', - 'attributes': [ - 'SAI_ENI_ATTR_INBOUND_V4_STAGE2_DASH_ACL_GROUP_ID', - 'null', - ], - } - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - @pytest.mark.dependency( - name='test_sai_eni_attr_inbound_v4_stage3_dash_acl_group_id_set' - ) - def test_sai_eni_attr_inbound_v4_stage3_dash_acl_group_id_set(self, dpu): - commands = [ - { - 'name': 'eni_1', - 'op': 'set', - 'attributes': [ - 'SAI_ENI_ATTR_INBOUND_V4_STAGE3_DASH_ACL_GROUP_ID', - 'null', - ], - } - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - @pytest.mark.dependency( - name='test_sai_eni_attr_inbound_v4_stage4_dash_acl_group_id_set' - ) - def test_sai_eni_attr_inbound_v4_stage4_dash_acl_group_id_set(self, dpu): - commands = [ - { - 'name': 'eni_1', - 'op': 'set', - 'attributes': [ - 'SAI_ENI_ATTR_INBOUND_V4_STAGE4_DASH_ACL_GROUP_ID', - 'null', - ], - } - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - @pytest.mark.dependency( - name='test_sai_eni_attr_inbound_v4_stage5_dash_acl_group_id_set' - ) - def test_sai_eni_attr_inbound_v4_stage5_dash_acl_group_id_set(self, dpu): - commands = [ - { - 'name': 'eni_1', - 'op': 'set', - 'attributes': [ - 'SAI_ENI_ATTR_INBOUND_V4_STAGE5_DASH_ACL_GROUP_ID', - 'null', - ], - } - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - - @pytest.mark.dependency( - name='test_sai_eni_attr_inbound_v6_stage1_dash_acl_group_id_set' - ) - def test_sai_eni_attr_inbound_v6_stage1_dash_acl_group_id_set(self, dpu): - commands = [ - { - 'name': 'eni_1', - 'op': 'set', - 'attributes': [ - 'SAI_ENI_ATTR_INBOUND_V6_STAGE1_DASH_ACL_GROUP_ID', - 'null', - ], - } - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - @pytest.mark.dependency( - name='test_sai_eni_attr_inbound_v6_stage2_dash_acl_group_id_set' - ) - def test_sai_eni_attr_inbound_v6_stage2_dash_acl_group_id_set(self, dpu): - commands = [ - { - 'name': 'eni_1', - 'op': 'set', - 'attributes': [ - 'SAI_ENI_ATTR_INBOUND_V6_STAGE2_DASH_ACL_GROUP_ID', - 'null', - ], - } - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - @pytest.mark.dependency( - name='test_sai_eni_attr_inbound_v6_stage3_dash_acl_group_id_set' - ) - def test_sai_eni_attr_inbound_v6_stage3_dash_acl_group_id_set(self, dpu): - commands = [ - { - 'name': 'eni_1', - 'op': 'set', - 'attributes': [ - 'SAI_ENI_ATTR_INBOUND_V6_STAGE3_DASH_ACL_GROUP_ID', - 'null', - ], - } - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - @pytest.mark.dependency( - name='test_sai_eni_attr_inbound_v6_stage4_dash_acl_group_id_set' - ) - def test_sai_eni_attr_inbound_v6_stage4_dash_acl_group_id_set(self, dpu): - commands = [ - { - 'name': 'eni_1', - 'op': 'set', - 'attributes': [ - 'SAI_ENI_ATTR_INBOUND_V6_STAGE4_DASH_ACL_GROUP_ID', - 'null', - ], - } - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - - @pytest.mark.dependency( - name='test_sai_eni_attr_inbound_v6_stage5_dash_acl_group_id_set' - ) - def test_sai_eni_attr_inbound_v6_stage5_dash_acl_group_id_set(self, dpu): - commands = [ - { - 'name': 'eni_1', - 'op': 'set', - 'attributes': [ - 'SAI_ENI_ATTR_INBOUND_V6_STAGE5_DASH_ACL_GROUP_ID', - 'null', - ], - } - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - - @pytest.mark.dependency( - name='test_sai_eni_attr_outbound_v4_stage1_dash_acl_group_id_set' - ) - def test_sai_eni_attr_outbound_v4_stage1_dash_acl_group_id_set(self, dpu): - commands = [ - { - 'name': 'eni_1', - 'op': 'set', - 'attributes': [ - 'SAI_ENI_ATTR_OUTBOUND_V4_STAGE1_DASH_ACL_GROUP_ID', - 'null', - ], - } - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - @pytest.mark.dependency( - name='test_sai_eni_attr_outbound_v4_stage2_dash_acl_group_id_set' - ) - def test_sai_eni_attr_outbound_v4_stage2_dash_acl_group_id_set(self, dpu): - commands = [ - { - 'name': 'eni_1', - 'op': 'set', - 'attributes': [ - 'SAI_ENI_ATTR_OUTBOUND_V4_STAGE2_DASH_ACL_GROUP_ID', - 'null', - ], - } - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - - @pytest.mark.dependency( - name='test_sai_eni_attr_outbound_v4_stage3_dash_acl_group_id_set' - ) - def test_sai_eni_attr_outbound_v4_stage3_dash_acl_group_id_set(self, dpu): - commands = [ - { - 'name': 'eni_1', - 'op': 'set', - 'attributes': [ - 'SAI_ENI_ATTR_OUTBOUND_V4_STAGE3_DASH_ACL_GROUP_ID', - 'null', - ], - } - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - - @pytest.mark.dependency( - name='test_sai_eni_attr_outbound_v4_stage4_dash_acl_group_id_set' - ) - def test_sai_eni_attr_outbound_v4_stage4_dash_acl_group_id_set(self, dpu): - commands = [ - { - 'name': 'eni_1', - 'op': 'set', - 'attributes': [ - 'SAI_ENI_ATTR_OUTBOUND_V4_STAGE4_DASH_ACL_GROUP_ID', - 'null', - ], - } - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - - @pytest.mark.dependency( - name='test_sai_eni_attr_outbound_v4_stage5_dash_acl_group_id_set' - ) - def test_sai_eni_attr_outbound_v4_stage5_dash_acl_group_id_set(self, dpu): - commands = [ - { - 'name': 'eni_1', - 'op': 'set', - 'attributes': [ - 'SAI_ENI_ATTR_OUTBOUND_V4_STAGE5_DASH_ACL_GROUP_ID', - 'null', - ], - } - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - @pytest.mark.dependency( - name='test_sai_eni_attr_outbound_v6_stage1_dash_acl_group_id_set' - ) - def test_sai_eni_attr_outbound_v6_stage1_dash_acl_group_id_set(self, dpu): - commands = [ - { - 'name': 'eni_1', - 'op': 'set', - 'attributes': [ - 'SAI_ENI_ATTR_OUTBOUND_V6_STAGE1_DASH_ACL_GROUP_ID', - 'null', - ], - } - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - @pytest.mark.dependency( - name='test_sai_eni_attr_outbound_v6_stage2_dash_acl_group_id_set' - ) - def test_sai_eni_attr_outbound_v6_stage2_dash_acl_group_id_set(self, dpu): - commands = [ - { - 'name': 'eni_1', - 'op': 'set', - 'attributes': [ - 'SAI_ENI_ATTR_OUTBOUND_V6_STAGE2_DASH_ACL_GROUP_ID', - 'null', - ], - } - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - - @pytest.mark.dependency( - name='test_sai_eni_attr_outbound_v6_stage3_dash_acl_group_id_set' - ) - def test_sai_eni_attr_outbound_v6_stage3_dash_acl_group_id_set(self, dpu): - commands = [ - { - 'name': 'eni_1', - 'op': 'set', - 'attributes': [ - 'SAI_ENI_ATTR_OUTBOUND_V6_STAGE3_DASH_ACL_GROUP_ID', - 'null', - ], - } - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - @pytest.mark.dependency( - name='test_sai_eni_attr_outbound_v6_stage4_dash_acl_group_id_set' - ) - def test_sai_eni_attr_outbound_v6_stage4_dash_acl_group_id_set(self, dpu): - commands = [ - { - 'name': 'eni_1', - 'op': 'set', - 'attributes': [ - 'SAI_ENI_ATTR_OUTBOUND_V6_STAGE4_DASH_ACL_GROUP_ID', - 'null', - ], - } - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - - @pytest.mark.dependency( - name='test_sai_eni_attr_outbound_v6_stage5_dash_acl_group_id_set' - ) - def test_sai_eni_attr_outbound_v6_stage5_dash_acl_group_id_set(self, dpu): - commands = [ - { - 'name': 'eni_1', - 'op': 'set', - 'attributes': [ - 'SAI_ENI_ATTR_OUTBOUND_V6_STAGE5_DASH_ACL_GROUP_ID', - 'null', - ], - } - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values get =======') - pprint(results) - - - def test_eni_remove(self, dpu): - - commands = [ - {'name': 'eni_1', 'op': 'remove'}, - {"name": "vnet","op": "remove"}, - ] - - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values remove =======') - pprint(results) \ No newline at end of file diff --git a/tests/api/test_eni_ether_address_map_entry.py b/tests/api/test_eni_ether_address_map_entry.py deleted file mode 100644 index 359c7788..00000000 --- a/tests/api/test_eni_ether_address_map_entry.py +++ /dev/null @@ -1,71 +0,0 @@ -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.dpu) != 1: - pytest.skip("invalid for \"{}\" testbed".format(testbed.name)) - -@pytest.mark.dpu -class TestSaiEniEtherAddressMapEntry: - # object with no attributes - - def test_eni_ether_address_map_entry_create(self, dpu): - commands = [ - {"name": "vnet","op": "create","type": "SAI_OBJECT_TYPE_VNET","attributes": ["SAI_VNET_ATTR_VNI","2000"]}, - { - "name": "eni_1", - "op": "create", - "type": "SAI_OBJECT_TYPE_ENI", - "attributes": [ - "SAI_ENI_ATTR_ADMIN_STATE","True", - "SAI_ENI_ATTR_VM_UNDERLAY_DIP","10.10.1.10", - "SAI_ENI_ATTR_VM_VNI","2000", - "SAI_ENI_ATTR_VNET_ID","$vnet", - ] - }, - { - 'name': 'eni_ether_address_map_entry_1', - 'op': 'create', - 'type': 'SAI_OBJECT_TYPE_ENI_ETHER_ADDRESS_MAP_ENTRY', - 'attributes': ["SAI_ENI_ETHER_ADDRESS_MAP_ENTRY_ATTR_ENI_ID","$eni_1"], - 'key': {'switch_id': '$SWITCH_ID', 'address': '00:AA:AA:AA:AB:00'}, - } - ] - - results = [*dpu.process_commands(commands)] - print('\n======= SAI commands RETURN values create =======\n') - pprint(results) - - @pytest.mark.dependency(name='test_sai_eni_ether_address_map_entry_attr_eni_id_set') - def test_sai_eni_ether_address_map_entry_attr_eni_id_set(self, dpu): - commands = [ - { - 'name': 'eni_ether_address_map_entry_1', - 'op': 'set', - 'attributes': ['SAI_ENI_ETHER_ADDRESS_MAP_ENTRY_ATTR_ENI_ID', 'null'], - } - ] - results = [*dpu.process_commands(commands)] - print('\n======= SAI commands RETURN values set =======\n') - pprint(results) - - - def test_eni_ether_address_map_entry_remove(self, dpu): - commands = [ - - { - 'name': 'eni_ether_address_map_entry_1', - 'key': {'switch_id': '$SWITCH_ID', 'address': '00:AA:AA:AA:AB:00'}, - 'op': 'remove', - }, - {'name': 'eni_1', 'op': 'remove'}, - {"name": "vnet","op": "remove"}, - ] - - results = [*dpu.process_commands(commands)] - print('\n======= SAI commands RETURN values remove =======\n') - pprint(results) - diff --git a/tests/api/test_generic_programmable.py b/tests/api/test_generic_programmable.py new file mode 100644 index 00000000..de4b322a --- /dev/null +++ b/tests/api/test_generic_programmable.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 TestSaiGenericProgrammable: + # object with no parents + + def test_generic_programmable_create(self, npu): + commands = [ + { + 'name': 'generic_programmable_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_GENERIC_PROGRAMMABLE', + 'attributes': ['SAI_GENERIC_PROGRAMMABLE_ATTR_OBJECT_NAME', '2:10,11'], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_generic_programmable_remove(self, npu): + commands = [{'name': 'generic_programmable_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_hash.py b/tests/api/test_hash.py new file mode 100644 index 00000000..f6140f0a --- /dev/null +++ b/tests/api/test_hash.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 TestSaiHash: + # object with no attributes + + def test_hash_create(self, npu): + commands = [ + { + 'name': 'hash_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_HASH', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_hash_remove(self, npu): + commands = [{'name': 'hash_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_hostif_trap.py b/tests/api/test_hostif_trap.py index 78f1def6..fbc8e33d 100644 --- a/tests/api/test_hostif_trap.py +++ b/tests/api/test_hostif_trap.py @@ -1,6 +1,16 @@ from pprint import pprint +import pytest + +@pytest.fixture(scope='module', autouse=True) +def skip_all(testbed_instance): + testbed = testbed_instance + if testbed is not None and len(testbed.npu) != 1: + pytest.skip('invalid for {} testbed'.format(testbed.name)) + + +@pytest.mark.npu class TestSaiHostifTrap: # object with no parent objects diff --git a/tests/api/test_hostif_trap_group.py b/tests/api/test_hostif_trap_group.py index ce6db62f..24a21f1c 100644 --- a/tests/api/test_hostif_trap_group.py +++ b/tests/api/test_hostif_trap_group.py @@ -1,6 +1,16 @@ from pprint import pprint +import pytest + +@pytest.fixture(scope='module', autouse=True) +def skip_all(testbed_instance): + testbed = testbed_instance + if testbed is not None and len(testbed.npu) != 1: + pytest.skip('invalid for {} testbed'.format(testbed.name)) + + +@pytest.mark.npu class TestSaiHostifTrapGroup: # object with no attributes diff --git a/tests/api/test_ipmc_group.py b/tests/api/test_ipmc_group.py index 7879ac80..520b329a 100644 --- a/tests/api/test_ipmc_group.py +++ b/tests/api/test_ipmc_group.py @@ -1,6 +1,16 @@ from pprint import pprint +import pytest + +@pytest.fixture(scope='module', autouse=True) +def skip_all(testbed_instance): + testbed = testbed_instance + if testbed is not None and len(testbed.npu) != 1: + pytest.skip('invalid for {} testbed'.format(testbed.name)) + + +@pytest.mark.npu class TestSaiIpmcGroup: # object with no attributes diff --git a/tests/api/test_isolation_group.py b/tests/api/test_isolation_group.py index f8fd750f..9db00002 100644 --- a/tests/api/test_isolation_group.py +++ b/tests/api/test_isolation_group.py @@ -1,6 +1,16 @@ from pprint import pprint +import pytest + +@pytest.fixture(scope='module', autouse=True) +def skip_all(testbed_instance): + testbed = testbed_instance + if testbed is not None and len(testbed.npu) != 1: + pytest.skip('invalid for {} testbed'.format(testbed.name)) + + +@pytest.mark.npu class TestSaiIsolationGroup: # object with no parents diff --git a/tests/api/test_isolation_group_member.py b/tests/api/test_isolation_group_member.py new file mode 100644 index 00000000..9ad26a24 --- /dev/null +++ b/tests/api/test_isolation_group_member.py @@ -0,0 +1,67 @@ +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 TestSaiIsolationGroupMember: + # object with parent SAI_OBJECT_TYPE_ISOLATION_GROUP SAI_OBJECT_TYPE_PORT SAI_OBJECT_TYPE_BRIDGE_PORT + + def test_isolation_group_member_create(self, npu): + commands = [ + { + 'name': 'isolation_group_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_ISOLATION_GROUP', + 'attributes': [ + 'SAI_ISOLATION_GROUP_ATTR_TYPE', + 'SAI_ISOLATION_GROUP_TYPE_PORT', + ], + }, + { + 'name': 'port_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_PORT', + 'attributes': [ + 'SAI_PORT_ATTR_HW_LANE_LIST', + '2:10,11', + 'SAI_PORT_ATTR_SPEED', + '10', + ], + }, + { + 'name': 'isolation_group_member_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_ISOLATION_GROUP_MEMBER', + 'attributes': [ + 'SAI_ISOLATION_GROUP_MEMBER_ATTR_ISOLATION_GROUP_ID', + '$isolation_group_1', + 'SAI_ISOLATION_GROUP_MEMBER_ATTR_ISOLATION_OBJECT', + '$port_1', + ], + }, + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_isolation_group_member_remove(self, npu): + commands = [ + {'name': 'isolation_group_member_1', 'op': 'remove'}, + {'name': 'isolation_group_1', 'op': 'remove'}, + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_l2mc_group.py b/tests/api/test_l2mc_group.py new file mode 100644 index 00000000..2c9d0614 --- /dev/null +++ b/tests/api/test_l2mc_group.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 TestSaiL2McGroup: + # object with no attributes + + def test_l2mc_group_create(self, npu): + commands = [ + { + 'name': 'l2mc_group_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_L2MC_GROUP', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_l2mc_group_remove(self, npu): + commands = [{'name': 'l2mc_group_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_lag.py b/tests/api/test_lag.py index 2b231d62..893da9bf 100644 --- a/tests/api/test_lag.py +++ b/tests/api/test_lag.py @@ -1,6 +1,16 @@ from pprint import pprint +import pytest + +@pytest.fixture(scope='module', autouse=True) +def skip_all(testbed_instance): + testbed = testbed_instance + if testbed is not None and len(testbed.npu) != 1: + pytest.skip('invalid for {} testbed'.format(testbed.name)) + + +@pytest.mark.npu class TestSaiLag: # object with no attributes diff --git a/tests/api/test_macsec.py b/tests/api/test_macsec.py new file mode 100644 index 00000000..22989449 --- /dev/null +++ b/tests/api/test_macsec.py @@ -0,0 +1,39 @@ +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 TestSaiMacsec: + # object with no parents + + def test_macsec_create(self, npu): + commands = [ + { + 'name': 'macsec_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_MACSEC', + 'attributes': [ + 'SAI_MACSEC_ATTR_DIRECTION', + 'SAI_MACSEC_DIRECTION_EGRESS', + ], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_macsec_remove(self, npu): + commands = [{'name': 'macsec_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_macsec_flow.py b/tests/api/test_macsec_flow.py new file mode 100644 index 00000000..e550a4fd --- /dev/null +++ b/tests/api/test_macsec_flow.py @@ -0,0 +1,39 @@ +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 TestSaiMacsecFlow: + # object with no parents + + def test_macsec_flow_create(self, npu): + commands = [ + { + 'name': 'macsec_flow_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_MACSEC_FLOW', + 'attributes': [ + 'SAI_MACSEC_FLOW_ATTR_MACSEC_DIRECTION', + 'SAI_MACSEC_DIRECTION_EGRESS', + ], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_macsec_flow_remove(self, npu): + commands = [{'name': 'macsec_flow_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_nat_zone_counter.py b/tests/api/test_nat_zone_counter.py new file mode 100644 index 00000000..7b5f6eaf --- /dev/null +++ b/tests/api/test_nat_zone_counter.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 TestSaiNatZoneCounter: + # object with no attributes + + def test_nat_zone_counter_create(self, npu): + commands = [ + { + 'name': 'nat_zone_counter_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_NAT_ZONE_COUNTER', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_nat_zone_counter_remove(self, npu): + commands = [{'name': 'nat_zone_counter_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_next_hop_group.py b/tests/api/test_next_hop_group.py index d20c3c58..66dcbc4a 100644 --- a/tests/api/test_next_hop_group.py +++ b/tests/api/test_next_hop_group.py @@ -1,6 +1,16 @@ from pprint import pprint +import pytest + +@pytest.fixture(scope='module', autouse=True) +def skip_all(testbed_instance): + testbed = testbed_instance + if testbed is not None and len(testbed.npu) != 1: + pytest.skip('invalid for {} testbed'.format(testbed.name)) + + +@pytest.mark.npu class TestSaiNextHopGroup: # object with no parents @@ -21,13 +31,23 @@ def test_next_hop_group_create(self, npu): print('======= SAI commands RETURN values create =======') pprint(results) - def test_next_hop_group_remove(self, npu): + + @pytest.mark.dependency(name='test_sai_next_hop_group_attr_set_switchover_set') + def test_sai_next_hop_group_attr_set_switchover_set(self, npu): commands = [ { 'name': 'next_hop_group_1', - 'op': 'remove', + 'op': 'set', + 'attributes': ['SAI_NEXT_HOP_GROUP_ATTR_SET_SWITCHOVER', 'false'], } ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values set =======') + pprint(results) + + + def test_next_hop_group_remove(self, npu): + commands = [{'name': 'next_hop_group_1', 'op': 'remove'}] results = [*npu.process_commands(commands)] print('======= SAI commands RETURN values remove =======') diff --git a/tests/api/test_next_hop_group_map.py b/tests/api/test_next_hop_group_map.py new file mode 100644 index 00000000..1d4b1dfb --- /dev/null +++ b/tests/api/test_next_hop_group_map.py @@ -0,0 +1,39 @@ +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 TestSaiNextHopGroupMap: + # object with no parents + + def test_next_hop_group_map_create(self, npu): + commands = [ + { + 'name': 'next_hop_group_map_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_NEXT_HOP_GROUP_MAP', + 'attributes': [ + 'SAI_NEXT_HOP_GROUP_MAP_ATTR_TYPE', + 'SAI_NEXT_HOP_GROUP_MAP_TYPE_FORWARDING_CLASS_TO_INDEX', + ], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_next_hop_group_map_remove(self, npu): + commands = [{'name': 'next_hop_group_map_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_outbound_ca_to_pa_entry.py b/tests/api/test_outbound_ca_to_pa_entry.py deleted file mode 100644 index 100b036e..00000000 --- a/tests/api/test_outbound_ca_to_pa_entry.py +++ /dev/null @@ -1,124 +0,0 @@ - -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.dpu) != 1: - pytest.skip("invalid for \"{}\" testbed".format(testbed.name)) - -@pytest.mark.dpu -class TestSaiOutboundCaToPaEntry: - # object with no attributes - - def test_outbound_ca_to_pa_entry_create(self, dpu): - - commands = [ - { - "name": "vnet", - "op": "create", - "type": "SAI_OBJECT_TYPE_VNET", - "attributes": ["SAI_VNET_ATTR_VNI","2000"] - }, - { - 'name': 'outbound_ca_to_pa_entry_1', - 'op': 'create', - 'type': 'SAI_OBJECT_TYPE_OUTBOUND_CA_TO_PA_ENTRY', - 'attributes': [ - "SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_UNDERLAY_DIP","221.0.2.100", - "SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_OVERLAY_DMAC","00:1B:6E:00:00:01", - "SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_USE_DST_VNET_VNI","True", - ], - 'key': {'switch_id': '$SWITCH_ID', 'dst_vnet_id': '$vnet', 'dip': '1.128.0.1'} - } - ] - - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values create =======') - pprint(results) - - - - @pytest.mark.dependency(name="test_sai_outbound_ca_to_pa_entry_attr_underlay_dip_set") - def test_sai_outbound_ca_to_pa_entry_attr_underlay_dip_set(self, dpu): - - commands = [ - { - "name": "outbound_ca_to_pa_entry_1", - "op": "set", - "attributes": ["SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_UNDERLAY_DIP", '0.0.0.0'] - } - ] - results = [*dpu.process_commands(commands)] - print("======= SAI commands RETURN values get =======") - pprint(results) - - - - @pytest.mark.dependency(name="test_sai_outbound_ca_to_pa_entry_attr_overlay_dmac_set") - def test_sai_outbound_ca_to_pa_entry_attr_overlay_dmac_set(self, dpu): - - commands = [ - { - "name": "outbound_ca_to_pa_entry_1", - "op": "set", - "attributes": ["SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_OVERLAY_DMAC", '0:0:0:0:0:0'] - } - ] - results = [*dpu.process_commands(commands)] - print("======= SAI commands RETURN values get =======") - pprint(results) - - - @pytest.mark.dependency(name="test_sai_outbound_ca_to_pa_entry_attr_use_dst_vnet_vni_set") - def test_sai_outbound_ca_to_pa_entry_attr_use_dst_vnet_vni_set(self, dpu): - - commands = [ - { - "name": "outbound_ca_to_pa_entry_1", - "op": "set", - "attributes": ["SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_USE_DST_VNET_VNI", 'false'] - } - ] - results = [*dpu.process_commands(commands)] - print("======= SAI commands RETURN values get =======") - pprint(results) - - - @pytest.mark.dependency(name="test_sai_outbound_ca_to_pa_entry_attr_counter_id_set") - def test_sai_outbound_ca_to_pa_entry_attr_counter_id_set(self, dpu): - - commands = [ - { - "name": "outbound_ca_to_pa_entry_1", - "op": "set", - "attributes": ["SAI_OUTBOUND_CA_TO_PA_ENTRY_ATTR_COUNTER_ID", '0'] - } - ] - results = [*dpu.process_commands(commands)] - print("======= SAI commands RETURN values get =======") - pprint(results) - - - def test_outbound_ca_to_pa_entry_remove(self, dpu): - - commands = [ - { - 'name': 'outbound_ca_to_pa_entry_1', - 'op': 'remove', - 'key': - { - 'switch_id': '$SWITCH_ID', - 'dst_vnet_id': '$vnet', - 'dip': '1.128.0.1' - }, - }, - {"name": "vnet","op": "remove"}, - - ] - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values remove =======') - pprint(results) - diff --git a/tests/api/test_outbound_routing_entry.py b/tests/api/test_outbound_routing_entry.py deleted file mode 100644 index be7b5af0..00000000 --- a/tests/api/test_outbound_routing_entry.py +++ /dev/null @@ -1,132 +0,0 @@ -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.dpu) != 1: - pytest.skip("invalid for \"{}\" testbed".format(testbed.name)) - - -@pytest.mark.dpu -class TestSaiOutboundRoutingEntry: - # object with no attributes - - def test_outbound_routing_entry_create(self, dpu): - commands = [ - {"name": "vnet","op": "create","type": "SAI_OBJECT_TYPE_VNET","attributes": ["SAI_VNET_ATTR_VNI","2000"]}, - { - "name": "eni_1", - "op": "create", - "type": "SAI_OBJECT_TYPE_ENI", - "attributes": [ - "SAI_ENI_ATTR_ADMIN_STATE","True", - "SAI_ENI_ATTR_VM_UNDERLAY_DIP","10.10.1.10", - "SAI_ENI_ATTR_VM_VNI","2000", - "SAI_ENI_ATTR_VNET_ID","$vnet", - ] - }, - { - 'name': 'outbound_routing_entry_1', - 'op': 'create', - 'type': 'SAI_OBJECT_TYPE_OUTBOUND_ROUTING_ENTRY', - 'attributes': ["SAI_OUTBOUND_ROUTING_ENTRY_ATTR_ACTION", "SAI_OUTBOUND_ROUTING_ENTRY_ACTION_ROUTE_VNET","SAI_OUTBOUND_ROUTING_ENTRY_ATTR_DST_VNET_ID", "$vnet"], - 'key': { - 'switch_id': '$SWITCH_ID', - 'eni_id': '$eni_1', - 'destination': '10.1.0.0/16', - }, - } - ] - - results = [*dpu.process_commands(commands)] - print('\n======= SAI commands RETURN values create =======\n') - pprint(results) - - @pytest.mark.dependency(name='test_sai_outbound_routing_entry_attr_action_set') - def test_sai_outbound_routing_entry_attr_action_set(self, dpu): - commands = [ - { - 'name': 'outbound_routing_entry_1', - 'op': 'set', - 'attributes': [ - 'SAI_OUTBOUND_ROUTING_ENTRY_ATTR_ACTION', - 'SAI_OUTBOUND_ROUTING_ENTRY_ACTION_ROUTE_VNET', - "SAI_OUTBOUND_ROUTING_ENTRY_ATTR_DST_VNET_ID", "$vnet" - ], - } - ] - results = [*dpu.process_commands(commands)] - print('\n======= SAI commands RETURN values set =======\n') - pprint(results) - - - @pytest.mark.dependency(name='test_sai_outbound_routing_entry_attr_dst_vnet_id_set') - def test_sai_outbound_routing_entry_attr_dst_vnet_id_set(self, dpu): - commands = [ - { - 'name': 'outbound_routing_entry_1', - 'op': 'set', - 'attributes': [ - 'SAI_OUTBOUND_ROUTING_ENTRY_ATTR_ACTION', - 'SAI_OUTBOUND_ROUTING_ENTRY_ACTION_ROUTE_VNET', - "SAI_OUTBOUND_ROUTING_ENTRY_ATTR_DST_VNET_ID", "$vnet" - ], - } - ] - results = [*dpu.process_commands(commands)] - print('\n======= SAI commands RETURN values set =======\n') - pprint(results) - - - - - @pytest.mark.dependency(name='test_sai_outbound_routing_entry_attr_overlay_ip_set') - def test_sai_outbound_routing_entry_attr_overlay_ip_set(self, dpu): - commands = [ - { - 'name': 'outbound_routing_entry_1', - 'op': 'set', - 'attributes': ['SAI_OUTBOUND_ROUTING_ENTRY_ATTR_OVERLAY_IP', '0.0.0.0'], - } - ] - results = [*dpu.process_commands(commands)] - print('\n======= SAI commands RETURN values set =======\n') - pprint(results) - - - @pytest.mark.dependency(name='test_sai_outbound_routing_entry_attr_counter_id_set') - def test_sai_outbound_routing_entry_attr_counter_id_set(self, dpu): - commands = [ - { - 'name': 'outbound_routing_entry_1', - 'op': 'set', - 'attributes': ['SAI_OUTBOUND_ROUTING_ENTRY_ATTR_COUNTER_ID', 'null'], - } - ] - results = [*dpu.process_commands(commands)] - print('\n======= SAI commands RETURN values set =======\n') - pprint(results) - - - - def test_outbound_routing_entry_remove(self, dpu): - commands = [ - { - 'name': 'outbound_routing_entry_1', - 'key': { - 'switch_id': '$SWITCH_ID', - 'eni_id': '$eni_1', - 'destination': '10.1.0.0/16', - }, - 'op': 'remove', - }, - {'name': 'eni_1', 'op': 'remove'}, - {"name": "vnet","op": "remove"}, - - ] - - results = [*dpu.process_commands(commands)] - print('======= SAI commands RETURN values remove =======') - pprint(results) diff --git a/tests/api/test_policer.py b/tests/api/test_policer.py index 4c6f3352..3ca7abd6 100644 --- a/tests/api/test_policer.py +++ b/tests/api/test_policer.py @@ -1,6 +1,16 @@ from pprint import pprint +import pytest + +@pytest.fixture(scope='module', autouse=True) +def skip_all(testbed_instance): + testbed = testbed_instance + if testbed is not None and len(testbed.npu) != 1: + pytest.skip('invalid for {} testbed'.format(testbed.name)) + + +@pytest.mark.npu class TestSaiPolicer: # object with no parents diff --git a/tests/api/test_rpf_group.py b/tests/api/test_rpf_group.py index 31fb3f48..79a8bfa9 100644 --- a/tests/api/test_rpf_group.py +++ b/tests/api/test_rpf_group.py @@ -1,6 +1,16 @@ from pprint import pprint +import pytest + +@pytest.fixture(scope='module', autouse=True) +def skip_all(testbed_instance): + testbed = testbed_instance + if testbed is not None and len(testbed.npu) != 1: + pytest.skip('invalid for {} testbed'.format(testbed.name)) + + +@pytest.mark.npu class TestSaiRpfGroup: # object with no attributes diff --git a/tests/api/test_samplepacket.py b/tests/api/test_samplepacket.py index 79c404c8..0101f777 100644 --- a/tests/api/test_samplepacket.py +++ b/tests/api/test_samplepacket.py @@ -1,6 +1,16 @@ from pprint import pprint +import pytest + +@pytest.fixture(scope='module', autouse=True) +def skip_all(testbed_instance): + testbed = testbed_instance + if testbed is not None and len(testbed.npu) != 1: + pytest.skip('invalid for {} testbed'.format(testbed.name)) + + +@pytest.mark.npu class TestSaiSamplepacket: # object with no parents diff --git a/tests/api/test_scheduler.py b/tests/api/test_scheduler.py index 34fe9acc..299c0109 100644 --- a/tests/api/test_scheduler.py +++ b/tests/api/test_scheduler.py @@ -1,6 +1,16 @@ from pprint import pprint +import pytest + +@pytest.fixture(scope='module', autouse=True) +def skip_all(testbed_instance): + testbed = testbed_instance + if testbed is not None and len(testbed.npu) != 1: + pytest.skip('invalid for {} testbed'.format(testbed.name)) + + +@pytest.mark.npu class TestSaiScheduler: # object with no attributes diff --git a/tests/api/test_stp.py b/tests/api/test_stp.py index 15ec7d21..531b7c43 100644 --- a/tests/api/test_stp.py +++ b/tests/api/test_stp.py @@ -1,6 +1,16 @@ from pprint import pprint +import pytest + +@pytest.fixture(scope='module', autouse=True) +def skip_all(testbed_instance): + testbed = testbed_instance + if testbed is not None and len(testbed.npu) != 1: + pytest.skip('invalid for {} testbed'.format(testbed.name)) + + +@pytest.mark.npu class TestSaiStp: # object with no attributes diff --git a/tests/api/test_tam.py b/tests/api/test_tam.py new file mode 100644 index 00000000..68806e51 --- /dev/null +++ b/tests/api/test_tam.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 TestSaiTam: + # object with no attributes + + def test_tam_create(self, npu): + commands = [ + { + 'name': 'tam_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_TAM', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_tam_remove(self, npu): + commands = [{'name': 'tam_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_tam_collector.py b/tests/api/test_tam_collector.py new file mode 100644 index 00000000..6ee6c239 --- /dev/null +++ b/tests/api/test_tam_collector.py @@ -0,0 +1,57 @@ +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 TestSaiTamCollector: + # object with parent SAI_OBJECT_TYPE_TAM_TRANSPORT + + def test_tam_collector_create(self, npu): + commands = [ + { + 'name': 'tam_transport_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_TAM_TRANSPORT', + 'attributes': [ + 'SAI_TAM_TRANSPORT_ATTR_TRANSPORT_TYPE', + 'SAI_TAM_TRANSPORT_TYPE_TCP', + ], + }, + { + 'name': 'tam_collector_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_TAM_COLLECTOR', + 'attributes': [ + 'SAI_TAM_COLLECTOR_ATTR_SRC_IP', + '180.0.0.1', + 'SAI_TAM_COLLECTOR_ATTR_DST_IP', + '180.0.0.1', + 'SAI_TAM_COLLECTOR_ATTR_TRANSPORT', + '$tam_transport_1', + 'SAI_TAM_COLLECTOR_ATTR_DSCP_VALUE', + '1', + ], + }, + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_tam_collector_remove(self, npu): + commands = [ + {'name': 'tam_collector_1', 'op': 'remove'}, + {'name': 'tam_transport_1', 'op': 'remove'}, + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_tunnel_map.py b/tests/api/test_tunnel_map.py index dfd174bc..e697a647 100644 --- a/tests/api/test_tunnel_map.py +++ b/tests/api/test_tunnel_map.py @@ -1,6 +1,16 @@ from pprint import pprint +import pytest + +@pytest.fixture(scope='module', autouse=True) +def skip_all(testbed_instance): + testbed = testbed_instance + if testbed is not None and len(testbed.npu) != 1: + pytest.skip('invalid for {} testbed'.format(testbed.name)) + + +@pytest.mark.npu class TestSaiTunnelMap: # object with no parents diff --git a/tests/api/test_udf_group.py b/tests/api/test_udf_group.py index 3ad0303b..93bafed3 100644 --- a/tests/api/test_udf_group.py +++ b/tests/api/test_udf_group.py @@ -1,6 +1,16 @@ from pprint import pprint +import pytest + +@pytest.fixture(scope='module', autouse=True) +def skip_all(testbed_instance): + testbed = testbed_instance + if testbed is not None and len(testbed.npu) != 1: + pytest.skip('invalid for {} testbed'.format(testbed.name)) + + +@pytest.mark.npu class TestSaiUdfGroup: # object with no parents diff --git a/tests/api/test_udf_match.py b/tests/api/test_udf_match.py new file mode 100644 index 00000000..7796e924 --- /dev/null +++ b/tests/api/test_udf_match.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 TestSaiUdfMatch: + # object with no attributes + + def test_udf_match_create(self, npu): + commands = [ + { + 'name': 'udf_match_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_UDF_MATCH', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_udf_match_remove(self, npu): + commands = [{'name': 'udf_match_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_virtual_router.py b/tests/api/test_virtual_router.py index 285e9cee..ba86c93c 100644 --- a/tests/api/test_virtual_router.py +++ b/tests/api/test_virtual_router.py @@ -1,6 +1,16 @@ from pprint import pprint +import pytest + +@pytest.fixture(scope='module', autouse=True) +def skip_all(testbed_instance): + testbed = testbed_instance + if testbed is not None and len(testbed.npu) != 1: + pytest.skip('invalid for {} testbed'.format(testbed.name)) + + +@pytest.mark.npu class TestSaiVirtualRouter: # object with no attributes @@ -18,13 +28,71 @@ def test_virtual_router_create(self, npu): print('======= SAI commands RETURN values create =======') pprint(results) - def test_virtual_router_remove(self, npu): + @pytest.mark.dependency(name='test_sai_virtual_router_attr_admin_v4_state_set') + def test_sai_virtual_router_attr_admin_v4_state_set(self, npu): + commands = [ + { + 'name': 'virtual_router_1', + 'op': 'set', + 'attributes': ['SAI_VIRTUAL_ROUTER_ATTR_ADMIN_V4_STATE', 'true'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values set =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_virtual_router_attr_admin_v4_state_set']) + def test_sai_virtual_router_attr_admin_v4_state_get(self, npu): commands = [ { 'name': 'virtual_router_1', - 'op': 'remove', + 'op': 'get', + 'attributes': ['SAI_VIRTUAL_ROUTER_ATTR_ADMIN_V4_STATE'], } ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + for command in results: + for attribute in command: + pprint(attribute.raw()) + r_value = results[0][0].value() + print(r_value) + assert r_value == 'true', 'Get error, expected true but got %s' % r_value + + @pytest.mark.dependency(name='test_sai_virtual_router_attr_admin_v6_state_set') + def test_sai_virtual_router_attr_admin_v6_state_set(self, npu): + commands = [ + { + 'name': 'virtual_router_1', + 'op': 'set', + 'attributes': ['SAI_VIRTUAL_ROUTER_ATTR_ADMIN_V6_STATE', 'true'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values set =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_virtual_router_attr_admin_v6_state_set']) + def test_sai_virtual_router_attr_admin_v6_state_get(self, npu): + commands = [ + { + 'name': 'virtual_router_1', + 'op': 'get', + 'attributes': ['SAI_VIRTUAL_ROUTER_ATTR_ADMIN_V6_STATE'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + for command in results: + for attribute in command: + pprint(attribute.raw()) + r_value = results[0][0].value() + print(r_value) + assert r_value == 'true', 'Get error, expected true but got %s' % r_value + + + def test_virtual_router_remove(self, npu): + commands = [{'name': 'virtual_router_1', 'op': 'remove'}] results = [*npu.process_commands(commands)] print('======= SAI commands RETURN values remove =======') diff --git a/tests/api/test_vlan.py b/tests/api/test_vlan.py index 8dac7c9e..72308e29 100644 --- a/tests/api/test_vlan.py +++ b/tests/api/test_vlan.py @@ -1,6 +1,16 @@ from pprint import pprint +import pytest + +@pytest.fixture(scope='module', autouse=True) +def skip_all(testbed_instance): + testbed = testbed_instance + if testbed is not None and len(testbed.npu) != 1: + pytest.skip('invalid for {} testbed'.format(testbed.name)) + + +@pytest.mark.npu class TestSaiVlan: # object with no parents @@ -18,13 +28,41 @@ def test_vlan_create(self, npu): print('======= SAI commands RETURN values create =======') pprint(results) - def test_vlan_remove(self, npu): + + @pytest.mark.dependency(name='test_sai_vlan_attr_max_learned_addresses_set') + def test_sai_vlan_attr_max_learned_addresses_set(self, npu): commands = [ { 'name': 'vlan_1', - 'op': 'remove', + 'op': 'set', + 'attributes': ['SAI_VLAN_ATTR_MAX_LEARNED_ADDRESSES', '0'], } ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values set =======') + pprint(results) + + @pytest.mark.dependency(depends=['test_sai_vlan_attr_max_learned_addresses_set']) + def test_sai_vlan_attr_max_learned_addresses_get(self, npu): + commands = [ + { + 'name': 'vlan_1', + 'op': 'get', + 'attributes': ['SAI_VLAN_ATTR_MAX_LEARNED_ADDRESSES'], + } + ] + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values get =======') + for command in results: + for attribute in command: + pprint(attribute.raw()) + r_value = results[0][0].value() + print(r_value) + assert r_value == '0', 'Get error, expected 0 but got %s' % r_value + + + def test_vlan_remove(self, npu): + commands = [{'name': 'vlan_1', 'op': 'remove'}] results = [*npu.process_commands(commands)] print('======= SAI commands RETURN values remove =======') diff --git a/tests/api/test_wred.py b/tests/api/test_wred.py index 5a809f14..f9c90853 100644 --- a/tests/api/test_wred.py +++ b/tests/api/test_wred.py @@ -1,6 +1,15 @@ from pprint import pprint +import pytest +@pytest.fixture(scope='module', autouse=True) +def skip_all(testbed_instance): + testbed = testbed_instance + if testbed is not None and len(testbed.npu) != 1: + pytest.skip('invalid for {} testbed'.format(testbed.name)) + + +@pytest.mark.npu class TestSaiWred: # object with no attributes