diff --git a/common/sai_client/sai_thrift_client/sai_thrift_utils.py b/common/sai_client/sai_thrift_client/sai_thrift_utils.py index e7152fa2..6f2b1093 100644 --- a/common/sai_client/sai_thrift_client/sai_thrift_utils.py +++ b/common/sai_client/sai_thrift_client/sai_thrift_utils.py @@ -362,7 +362,7 @@ def object_id(oid): "16" => 16 "oid:0x10" => 16 """ - if oid == None or oid == 'null': + if oid == None or oid == 'null' or oid == 'SAI_NULL_OBJECT_ID': return 0 if isinstance(oid, str) and oid.startswith('oid:0x'): return int(oid[4:], 16) diff --git a/common/sai_npu.py b/common/sai_npu.py index edb69c46..6f51bf16 100644 --- a/common/sai_npu.py +++ b/common/sai_npu.py @@ -207,11 +207,14 @@ def set_sku_mode(self, sku): # Remove existing ports num_ports = len(self.dot1q_bp_oids) for idx in range(num_ports): - self.remove_vlan_member(self.default_vlan_oid, self.dot1q_bp_oids[idx]) - self.remove(self.dot1q_bp_oids[idx]) - oid = self.get(self.port_oids[idx], ["SAI_PORT_ATTR_PORT_SERDES_ID"]).oid() - if oid != "oid:0x0": + oid = self.get_vlan_member(self.default_vlan_oid, self.dot1q_bp_oids[idx]) + if oid: self.remove(oid) + self.remove(self.dot1q_bp_oids[idx]) + status, data = self.get(self.port_oids[idx], ["SAI_PORT_ATTR_PORT_SERDES_ID"], do_assert=False) + serdes_oid = data.oid() + if status == "SAI_STATUS_SUCCESS" and serdes_oid != "oid:0x0": + self.remove(serdes_oid) self.remove(self.port_oids[idx]) self.port_oids.clear() self.dot1q_bp_oids.clear() diff --git a/tests/api/test_dash_acl_group.py b/tests/api/test_dash_acl_group.py new file mode 100644 index 00000000..3551a051 --- /dev/null +++ b/tests/api/test_dash_acl_group.py @@ -0,0 +1,56 @@ + +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_direction_lookup_entry.py b/tests/api/test_direction_lookup_entry.py new file mode 100644 index 00000000..c94ace8d --- /dev/null +++ b/tests/api/test_direction_lookup_entry.py @@ -0,0 +1,54 @@ + +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 TestSaiDirectionLookupEntry: + # object with no attributes + + def test_direction_lookup_entry_create(self, dpu): + commands = [ + { + 'name': 'direction_lookup_entry_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_DIRECTION_LOOKUP_ENTRY', + 'attributes': [], + 'key': {'switch_id': '$SWITCH_ID', 'vni': "2000"} + } + ] + results = [*dpu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + + + @pytest.mark.dependency(name="test_sai_direction_lookup_entry_attr_action_set") + def test_sai_direction_lookup_entry_attr_action_set(self, dpu): + + commands = [ + { + "name": "direction_lookup_entry_1", + "op": "set", + "attributes": ["SAI_DIRECTION_LOOKUP_ENTRY_ATTR_ACTION", 'SAI_DIRECTION_LOOKUP_ENTRY_ACTION_SET_OUTBOUND_DIRECTION'] + } + ] + results = [*dpu.process_commands(commands)] + print("======= SAI commands RETURN values get =======") + pprint(results) + + + def test_direction_lookup_entry_remove(self, dpu): + + commands = [{'name': 'direction_lookup_entry_1', 'key': {'switch_id': '$SWITCH_ID', 'vni': '2000'}, 'op': 'remove'}] + + results = [*dpu.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..e420e991 --- /dev/null +++ b/tests/api/test_eni.py @@ -0,0 +1,489 @@ +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_inbound_routing_entry.py b/tests/api/test_inbound_routing_entry.py new file mode 100644 index 00000000..54b0ea54 --- /dev/null +++ b/tests/api/test_inbound_routing_entry.py @@ -0,0 +1,97 @@ + +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 TestSaiInboundRoutingEntry: + # object with no attributes + + def test_inbound_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': 'inbound_routing_entry_1', 'op': 'create', 'type': 'SAI_OBJECT_TYPE_INBOUND_ROUTING_ENTRY', + 'attributes': [ + "SAI_INBOUND_ROUTING_ENTRY_ATTR_ACTION","SAI_INBOUND_ROUTING_ENTRY_ACTION_VXLAN_DECAP_PA_VALIDATE", + "SAI_INBOUND_ROUTING_ENTRY_ATTR_SRC_VNET_ID","$vnet" + ], + 'key': {'switch_id': '$SWITCH_ID', 'eni_id': "33", 'vni': '2000', 'sip': '1.1.1.1', 'sip_mask': '32', 'priority': '0'} + } + ] + + results = [*dpu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + + + @pytest.mark.dependency(name="test_sai_inbound_routing_entry_attr_action_set") + def test_sai_inbound_routing_entry_attr_action_set(self, dpu): + + commands = [ + { + "name": "inbound_routing_entry_1", + "op": "set", + "attributes": [ + "SAI_INBOUND_ROUTING_ENTRY_ATTR_ACTION", + 'SAI_INBOUND_ROUTING_ENTRY_ACTION_VXLAN_DECAP' + ], + } + ] + results = [*dpu.process_commands(commands)] + print("======= SAI commands RETURN values get =======") + pprint(results) + + @pytest.mark.dependency(name="test_sai_inbound_routing_entry_attr_src_vnet_id_set") + def test_sai_inbound_routing_entry_attr_src_vnet_id_set(self, dpu): + + commands = [ + { + "name": "inbound_routing_entry_1", + "op": "set", + "attributes": ["SAI_INBOUND_ROUTING_ENTRY_ATTR_SRC_VNET_ID", '0'] + } + ] + results = [*dpu.process_commands(commands)] + print("======= SAI commands RETURN values get =======") + pprint(results) + + + def test_inbound_routing_entry_remove(self, dpu): + + commands = [ + { + 'name': 'inbound_routing_entry_1', + 'op': 'remove', + 'key': + { + 'switch_id': '$SWITCH_ID', + 'eni_id': '33', + 'vni': '2000', + 'sip': '1.1.1.1', + 'sip_mask': '32', + 'priority': '0' + }, + }, + {'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_outbound_ca_to_pa_entry.py b/tests/api/test_outbound_ca_to_pa_entry.py new file mode 100644 index 00000000..100b036e --- /dev/null +++ b/tests/api/test_outbound_ca_to_pa_entry.py @@ -0,0 +1,124 @@ + +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_pa_validation_entry.py b/tests/api/test_pa_validation_entry.py new file mode 100644 index 00000000..118b8f7e --- /dev/null +++ b/tests/api/test_pa_validation_entry.py @@ -0,0 +1,79 @@ + +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 TestSaiPaValidationEntry: + # object with no attributes + + def test_pa_validation_entry_create(self, dpu): + + commands = [ + { + "name": "vnet", + "op": "create", + "type": "SAI_OBJECT_TYPE_VNET", + "attributes": ["SAI_VNET_ATTR_VNI","7000"] + }, + { + 'name': 'pa_validation_entry_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_PA_VALIDATION_ENTRY', + 'attributes': [], + 'key': + { + 'switch_id': '$SWITCH_ID', + 'vnet_id': '$vnet', + 'sip': '1.1.1.1' + } + } + ] + results = [*dpu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + + + @pytest.mark.dependency(name="test_sai_pa_validation_entry_attr_action_set") + def test_sai_pa_validation_entry_attr_action_set(self, dpu): + + commands = [ + { + "name": "pa_validation_entry_1", + "op": "set", + "attributes": [ + "SAI_PA_VALIDATION_ENTRY_ATTR_ACTION", + 'SAI_PA_VALIDATION_ENTRY_ACTION_PERMIT' + ], + } + ] + results = [*dpu.process_commands(commands)] + print("======= SAI commands RETURN values get =======") + pprint(results) + + def test_pa_validation_entry_remove(self, dpu): + + commands = [ + { + 'name': 'pa_validation_entry_1', + 'op': 'remove', + 'key': + { + 'switch_id': '$SWITCH_ID', + 'vnet_id': '$vnet', + 'sip': '1.1.1.1' + }, + } + ] + + results = [*dpu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) + diff --git a/tests/api/test_vip_entry.py b/tests/api/test_vip_entry.py new file mode 100644 index 00000000..d59e619f --- /dev/null +++ b/tests/api/test_vip_entry.py @@ -0,0 +1,55 @@ + +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 TestSaiVipEntry: + # object with no attributes + + def test_vip_entry_create(self, dpu): + + commands = [ + { + 'name': 'vip_entry_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_VIP_ENTRY', + 'attributes': [], + 'key': {'switch_id': '$SWITCH_ID', 'vip': '1.2.1.1'} + } + ] + results = [*dpu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + + + @pytest.mark.dependency(name="test_sai_vip_entry_attr_action_set") + def test_sai_vip_entry_attr_action_set(self, dpu): + + commands = [ + { + "name": "vip_entry_1", + "op": "set", + "attributes": ["SAI_VIP_ENTRY_ATTR_ACTION", 'SAI_VIP_ENTRY_ACTION_ACCEPT'] + } + ] + results = [*dpu.process_commands(commands)] + print("======= SAI commands RETURN values get =======") + pprint(results) + + + def test_vip_entry_remove(self, dpu): + + commands = [{'name': 'vip_entry_1', 'key': {'switch_id': '$SWITCH_ID', 'vip': '1.2.1.1'}, 'op': 'remove'}] + + results = [*dpu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) + diff --git a/tests/api/test_vnet.py b/tests/api/test_vnet.py new file mode 100644 index 00000000..db35a3cf --- /dev/null +++ b/tests/api/test_vnet.py @@ -0,0 +1,54 @@ + +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 TestSaiVnet: + # object with no attributes + + def test_vnet_create(self, dpu): + + commands = [ + { + 'name': 'vnet_1', + 'op': 'create', + 'type': 'SAI_OBJECT_TYPE_VNET', + 'attributes': ["SAI_VNET_ATTR_VNI", '2001'] + } + ] + + results = [*dpu.process_commands(commands)] + print('======= SAI commands RETURN values create =======') + pprint(results) + + + @pytest.mark.dependency(name="test_sai_vnet_attr_vni_set") + def test_sai_vnet_attr_vni_set(self, dpu): + + commands = [ + { + "name": "vnet_1", + "op": "set", + "attributes": ["SAI_VNET_ATTR_VNI", '2001'] + } + ] + results = [*dpu.process_commands(commands)] + print("======= SAI commands RETURN values get =======") + pprint(results) + + + def test_vnet_remove(self, dpu): + + commands = [{'name': 'vnet_1', 'op': 'remove'}] + + results = [*dpu.process_commands(commands)] + print('======= SAI commands RETURN values remove =======') + pprint(results) +