From 1a4c1b2c61bfad2e9cf2cc3e6170ad68d389f1ae Mon Sep 17 00:00:00 2001 From: Dinesh Kumar Sellappan <40899231+selldinesh@users.noreply.github.com> Date: Tue, 29 Aug 2023 12:01:52 -0700 Subject: [PATCH] adding additional create remove cases (#14) Signed-off-by: selldinesh --- tests/api/test_ars.py | 26 ++++++++++++ tests/api/test_ars_profile.py | 26 ++++++++++++ tests/api/test_bridge.py | 26 ++++++++++++ tests/api/test_counter.py | 26 ++++++++++++ tests/api/test_dash_acl_group.py | 26 ++++++++++++ tests/api/test_dtel.py | 26 ++++++++++++ tests/api/test_dtel_event.py | 29 +++++++++++++ tests/api/test_dtel_int_session.py | 26 ++++++++++++ tests/api/test_dtel_report_session.py | 26 ++++++++++++ tests/api/test_eni.py | 26 ++++++++++++ tests/api/test_generic_programmable.py | 26 ++++++++++++ tests/api/test_hash.py | 26 ++++++++++++ tests/api/test_isolation_group_member.py | 54 ++++++++++++++++++++++++ tests/api/test_l2mc_group.py | 26 ++++++++++++ tests/api/test_macsec.py | 29 +++++++++++++ tests/api/test_macsec_flow.py | 29 +++++++++++++ tests/api/test_nat_zone_counter.py | 26 ++++++++++++ tests/api/test_next_hop_group_map.py | 29 +++++++++++++ tests/api/test_switch_tunnel.py | 29 +++++++++++++ tests/api/test_tam.py | 26 ++++++++++++ tests/api/test_tam_collector.py | 47 +++++++++++++++++++++ tests/api/test_udf.py | 49 +++++++++++++++++++++ tests/api/test_udf_match.py | 26 ++++++++++++ 23 files changed, 685 insertions(+) create mode 100644 tests/api/test_ars.py create mode 100644 tests/api/test_ars_profile.py create mode 100644 tests/api/test_bridge.py create mode 100644 tests/api/test_counter.py create mode 100644 tests/api/test_dash_acl_group.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 create mode 100644 tests/api/test_eni.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 create mode 100644 tests/api/test_switch_tunnel.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.py create mode 100644 tests/api/test_udf_match.py diff --git a/tests/api/test_ars.py b/tests/api/test_ars.py new file mode 100644 index 00000000..1a0d22da --- /dev/null +++ b/tests/api/test_ars.py @@ -0,0 +1,26 @@ +from pprint import pprint + + +class TestSaiArs: + # object with no attributes + + def test_ars_create(self, npu): + commands = [ + { + 'name': 'ars_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_ARS', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_ars_remove(self, npu): + commands = [{'name': 'ars_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_ars_profile.py b/tests/api/test_ars_profile.py new file mode 100644 index 00000000..0d45f96e --- /dev/null +++ b/tests/api/test_ars_profile.py @@ -0,0 +1,26 @@ +from pprint import pprint + + +class TestSaiArsProfile: + # object with no attributes + + def test_ars_profile_create(self, npu): + commands = [ + { + 'name': 'ars_profile_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_ARS_PROFILE', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_ars_profile_remove(self, npu): + commands = [{'name': 'ars_profile_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_bridge.py b/tests/api/test_bridge.py new file mode 100644 index 00000000..2f6115b7 --- /dev/null +++ b/tests/api/test_bridge.py @@ -0,0 +1,26 @@ +from pprint import pprint + + +class TestSaiBridge: + # object with no parents + + def test_bridge_create(self, npu): + commands = [ + { + 'name': 'bridge_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_BRIDGE', + 'attributes': ['SAI_BRIDGE_ATTR_TYPE', 'SAI_BRIDGE_TYPE_1Q'], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_bridge_remove(self, npu): + commands = [{'name': 'bridge_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_counter.py b/tests/api/test_counter.py new file mode 100644 index 00000000..2e3ac1c5 --- /dev/null +++ b/tests/api/test_counter.py @@ -0,0 +1,26 @@ +from pprint import pprint + + +class TestSaiCounter: + # object with no attributes + + def test_counter_create(self, npu): + commands = [ + { + 'name': 'counter_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_COUNTER', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_counter_remove(self, npu): + commands = [{'name': 'counter_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_dash_acl_group.py b/tests/api/test_dash_acl_group.py new file mode 100644 index 00000000..071c3c54 --- /dev/null +++ b/tests/api/test_dash_acl_group.py @@ -0,0 +1,26 @@ +from pprint import pprint + + +class TestSaiDashAclGroup: + # object with no attributes + + def test_dash_acl_group_create(self, npu): + commands = [ + { + 'name': 'dash_acl_group_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_DASH_ACL_GROUP', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_dash_acl_group_remove(self, npu): + commands = [{'name': 'dash_acl_group_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_dtel.py b/tests/api/test_dtel.py new file mode 100644 index 00000000..fdd5b268 --- /dev/null +++ b/tests/api/test_dtel.py @@ -0,0 +1,26 @@ +from pprint import pprint + + +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) + + def test_dtel_remove(self, npu): + commands = [{'name': 'dtel_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_dtel_event.py b/tests/api/test_dtel_event.py new file mode 100644 index 00000000..2b6b2778 --- /dev/null +++ b/tests/api/test_dtel_event.py @@ -0,0 +1,29 @@ +from pprint import pprint + + +class TestSaiDtelEvent: + # object with no parents + + def test_dtel_event_create(self, npu): + commands = [ + { + 'name': 'dtel_event_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_DTEL_EVENT', + 'attributes': [ + 'SAI_DTEL_EVENT_ATTR_TYPE', + 'SAI_DTEL_EVENT_TYPE_FLOW_STATE', + ], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_dtel_event_remove(self, npu): + commands = [{'name': 'dtel_event_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_dtel_int_session.py b/tests/api/test_dtel_int_session.py new file mode 100644 index 00000000..0a2b9651 --- /dev/null +++ b/tests/api/test_dtel_int_session.py @@ -0,0 +1,26 @@ +from pprint import pprint + + +class TestSaiDtelIntSession: + # object with no attributes + + def test_dtel_int_session_create(self, npu): + commands = [ + { + 'name': 'dtel_int_session_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_DTEL_INT_SESSION', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_dtel_int_session_remove(self, npu): + commands = [{'name': 'dtel_int_session_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_dtel_report_session.py b/tests/api/test_dtel_report_session.py new file mode 100644 index 00000000..6369606c --- /dev/null +++ b/tests/api/test_dtel_report_session.py @@ -0,0 +1,26 @@ +from pprint import pprint + + +class TestSaiDtelReportSession: + # object with no attributes + + def test_dtel_report_session_create(self, npu): + commands = [ + { + 'name': 'dtel_report_session_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_DTEL_REPORT_SESSION', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_dtel_report_session_remove(self, npu): + commands = [{'name': 'dtel_report_session_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_eni.py b/tests/api/test_eni.py new file mode 100644 index 00000000..e1748159 --- /dev/null +++ b/tests/api/test_eni.py @@ -0,0 +1,26 @@ +from pprint import pprint + + +class TestSaiEni: + # object with no attributes + + def test_eni_create(self, npu): + commands = [ + { + 'name': 'eni_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_ENI', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_eni_remove(self, npu): + commands = [{'name': 'eni_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_generic_programmable.py b/tests/api/test_generic_programmable.py new file mode 100644 index 00000000..8dbccde9 --- /dev/null +++ b/tests/api/test_generic_programmable.py @@ -0,0 +1,26 @@ +from pprint import pprint + + +class TestSaiGenericProgrammable: + # object with no parents + + def test_generic_programmable_create(self, npu): + commands = [ + { + 'name': 'generic_programmable_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_GENERIC_PROGRAMMABLE', + 'attributes': ['SAI_GENERIC_PROGRAMMABLE_ATTR_OBJECT_NAME', '2:10,11'], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_generic_programmable_remove(self, npu): + commands = [{'name': 'generic_programmable_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_hash.py b/tests/api/test_hash.py new file mode 100644 index 00000000..38b9e658 --- /dev/null +++ b/tests/api/test_hash.py @@ -0,0 +1,26 @@ +from pprint import pprint + + +class TestSaiHash: + # object with no attributes + + def test_hash_create(self, npu): + commands = [ + { + 'name': 'hash_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_HASH', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_hash_remove(self, npu): + commands = [{'name': 'hash_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_isolation_group_member.py b/tests/api/test_isolation_group_member.py new file mode 100644 index 00000000..7fa6b50d --- /dev/null +++ b/tests/api/test_isolation_group_member.py @@ -0,0 +1,54 @@ +from pprint import pprint + + +class TestSaiIsolationGroupMember: + # object with parent SAI_OBJECT_TYPE_ISOLATION_GROUP SAI_OBJECT_TYPE_PORT SAI_OBJECT_TYPE_BRIDGE_PORT + + def test_isolation_group_member_create(self, npu): + commands = [ + { + 'name': 'isolation_group_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_ISOLATION_GROUP', + 'attributes': [ + 'SAI_ISOLATION_GROUP_ATTR_TYPE', + 'SAI_ISOLATION_GROUP_TYPE_PORT', + ], + }, + { + 'name': 'port_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_PORT', + 'attributes': [ + 'SAI_PORT_ATTR_HW_LANE_LIST', + '2:10,11', + 'SAI_PORT_ATTR_SPEED', + '10', + ], + }, + { + 'name': 'isolation_group_member_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_ISOLATION_GROUP_MEMBER', + 'attributes': [ + 'SAI_ISOLATION_GROUP_MEMBER_ATTR_ISOLATION_GROUP_ID', + '$isolation_group_1', + 'SAI_ISOLATION_GROUP_MEMBER_ATTR_ISOLATION_OBJECT', + '$port_1', + ], + }, + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_isolation_group_member_remove(self, npu): + commands = [ + {'name': 'isolation_group_member_1', 'op': 'remove'}, + {'name': 'isolation_group_1', 'op': 'remove'}, + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_l2mc_group.py b/tests/api/test_l2mc_group.py new file mode 100644 index 00000000..1f05f0f4 --- /dev/null +++ b/tests/api/test_l2mc_group.py @@ -0,0 +1,26 @@ +from pprint import pprint + + +class TestSaiL2McGroup: + # object with no attributes + + def test_l2mc_group_create(self, npu): + commands = [ + { + 'name': 'l2mc_group_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_L2MC_GROUP', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_l2mc_group_remove(self, npu): + commands = [{'name': 'l2mc_group_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_macsec.py b/tests/api/test_macsec.py new file mode 100644 index 00000000..b1b66dd7 --- /dev/null +++ b/tests/api/test_macsec.py @@ -0,0 +1,29 @@ +from pprint import pprint + + +class TestSaiMacsec: + # object with no parents + + def test_macsec_create(self, npu): + commands = [ + { + 'name': 'macsec_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_MACSEC', + 'attributes': [ + 'SAI_MACSEC_ATTR_DIRECTION', + 'SAI_MACSEC_DIRECTION_EGRESS', + ], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_macsec_remove(self, npu): + commands = [{'name': 'macsec_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_macsec_flow.py b/tests/api/test_macsec_flow.py new file mode 100644 index 00000000..acb9b49c --- /dev/null +++ b/tests/api/test_macsec_flow.py @@ -0,0 +1,29 @@ +from pprint import pprint + + +class TestSaiMacsecFlow: + # object with no parents + + def test_macsec_flow_create(self, npu): + commands = [ + { + 'name': 'macsec_flow_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_MACSEC_FLOW', + 'attributes': [ + 'SAI_MACSEC_FLOW_ATTR_MACSEC_DIRECTION', + 'SAI_MACSEC_DIRECTION_EGRESS', + ], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_macsec_flow_remove(self, npu): + commands = [{'name': 'macsec_flow_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_nat_zone_counter.py b/tests/api/test_nat_zone_counter.py new file mode 100644 index 00000000..7c17626e --- /dev/null +++ b/tests/api/test_nat_zone_counter.py @@ -0,0 +1,26 @@ +from pprint import pprint + + +class TestSaiNatZoneCounter: + # object with no attributes + + def test_nat_zone_counter_create(self, npu): + commands = [ + { + 'name': 'nat_zone_counter_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_NAT_ZONE_COUNTER', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_nat_zone_counter_remove(self, npu): + commands = [{'name': 'nat_zone_counter_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_next_hop_group_map.py b/tests/api/test_next_hop_group_map.py new file mode 100644 index 00000000..0d65717e --- /dev/null +++ b/tests/api/test_next_hop_group_map.py @@ -0,0 +1,29 @@ +from pprint import pprint + + +class TestSaiNextHopGroupMap: + # object with no parents + + def test_next_hop_group_map_create(self, npu): + commands = [ + { + 'name': 'next_hop_group_map_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_NEXT_HOP_GROUP_MAP', + 'attributes': [ + 'SAI_NEXT_HOP_GROUP_MAP_ATTR_TYPE', + 'SAI_NEXT_HOP_GROUP_MAP_TYPE_FORWARDING_CLASS_TO_INDEX', + ], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_next_hop_group_map_remove(self, npu): + commands = [{'name': 'next_hop_group_map_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_switch_tunnel.py b/tests/api/test_switch_tunnel.py new file mode 100644 index 00000000..a70f896b --- /dev/null +++ b/tests/api/test_switch_tunnel.py @@ -0,0 +1,29 @@ +from pprint import pprint + + +class TestSaiSwitchTunnel: + # object with no parents + + def test_switch_tunnel_create(self, npu): + commands = [ + { + 'name': 'switch_tunnel_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_SWITCH_TUNNEL', + 'attributes': [ + 'SAI_SWITCH_TUNNEL_ATTR_TUNNEL_TYPE', + 'SAI_TUNNEL_TYPE_IPINIP', + ], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_switch_tunnel_remove(self, npu): + commands = [{'name': 'switch_tunnel_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_tam.py b/tests/api/test_tam.py new file mode 100644 index 00000000..94aa30fe --- /dev/null +++ b/tests/api/test_tam.py @@ -0,0 +1,26 @@ +from pprint import pprint + + +class TestSaiTam: + # object with no attributes + + def test_tam_create(self, npu): + commands = [ + { + 'name': 'tam_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_TAM', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_tam_remove(self, npu): + commands = [{'name': 'tam_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_tam_collector.py b/tests/api/test_tam_collector.py new file mode 100644 index 00000000..6e5eb428 --- /dev/null +++ b/tests/api/test_tam_collector.py @@ -0,0 +1,47 @@ +from pprint import pprint + + +class TestSaiTamCollector: + # object with parent SAI_OBJECT_TYPE_TAM_TRANSPORT + + def test_tam_collector_create(self, npu): + commands = [ + { + 'name': 'tam_transport_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_TAM_TRANSPORT', + 'attributes': [ + 'SAI_TAM_TRANSPORT_ATTR_TRANSPORT_TYPE', + 'SAI_TAM_TRANSPORT_TYPE_TCP', + ], + }, + { + 'name': 'tam_collector_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_TAM_COLLECTOR', + 'attributes': [ + 'SAI_TAM_COLLECTOR_ATTR_SRC_IP', + '180.0.0.1', + 'SAI_TAM_COLLECTOR_ATTR_DST_IP', + '180.0.0.1', + 'SAI_TAM_COLLECTOR_ATTR_TRANSPORT', + '$tam_transport_1', + 'SAI_TAM_COLLECTOR_ATTR_DSCP_VALUE', + '1', + ], + }, + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_tam_collector_remove(self, npu): + commands = [ + {'name': 'tam_collector_1', 'op': 'remove'}, + {'name': 'tam_transport_1', 'op': 'remove'}, + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_udf.py b/tests/api/test_udf.py new file mode 100644 index 00000000..bc66c284 --- /dev/null +++ b/tests/api/test_udf.py @@ -0,0 +1,49 @@ +from pprint import pprint + + +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) + + def test_udf_remove(self, npu): + commands = [ + {'name': 'udf_1', 'op': 'remove'}, + {'name': 'udf_group_1', 'op': 'remove'}, + {'name': 'udf_match_1', 'op': 'remove'}, + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) diff --git a/tests/api/test_udf_match.py b/tests/api/test_udf_match.py new file mode 100644 index 00000000..53fa01fc --- /dev/null +++ b/tests/api/test_udf_match.py @@ -0,0 +1,26 @@ +from pprint import pprint + + +class TestSaiUdfMatch: + # object with no attributes + + def test_udf_match_create(self, npu): + commands = [ + { + 'name': 'udf_match_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_UDF_MATCH', + 'attributes': [], + } + ] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + def test_udf_match_remove(self, npu): + commands = [{'name': 'udf_match_1', 'op': 'remove'}] + + results = [*npu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results)