diff --git a/tests/dash/conftest.py b/tests/dash/conftest.py index 445fba4ae85..21495f3d3a2 100644 --- a/tests/dash/conftest.py +++ b/tests/dash/conftest.py @@ -7,8 +7,8 @@ from ipaddress import ip_interface from constants import ENI, VM_VNI, VNET1_VNI, VNET2_VNI, REMOTE_CA_IP, LOCAL_CA_IP, REMOTE_ENI_MAC,\ LOCAL_ENI_MAC, REMOTE_CA_PREFIX, LOOPBACK_IP, DUT_MAC, LOCAL_PA_IP, LOCAL_PTF_INTF, LOCAL_PTF_MAC,\ - REMOTE_PA_IP, REMOTE_PTF_INTF, REMOTE_PTF_MAC, REMOTE_PA_PREFIX, VNET1_NAME, VNET2_NAME, ROUTING_ACTION, \ - ROUTING_ACTION_TYPE, LOOKUP_OVERLAY_IP, ACL_GROUP, ACL_STAGE + REMOTE_PA_IP, REMOTE_PTF_INTF, REMOTE_PTF_MAC, REMOTE_PA_PREFIX, VNET1_NAME, VNET2_NAME, ROUTING_TYPE, \ + ROUTING_ACTION_TYPE, LOOKUP_OVERLAY_IP, ACL_GROUP, ACL_STAGE, OUTBOUND_ROUTING_GROUP from dash_utils import render_template_to_host, apply_swssconfig_file from gnmi_utils import generate_gnmi_cert, apply_gnmi_cert, recover_gnmi_cert, apply_gnmi_file from dash_acl import AclGroup, DEFAULT_ACL_GROUP, WAIT_AFTER_CONFIG, DefaultAclRule @@ -50,7 +50,7 @@ def pytest_addoption(parser): parser.addoption( "--vxlan_udp_dport", action="store", - default="random", + default="default", help="The vxlan udp dst port used in the test" ) @@ -134,6 +134,7 @@ def dash_config_info(duthost, config_facts, minigraph_facts, tbinfo): REMOTE_ENI_MAC: "F9:22:83:99:22:A2", LOCAL_ENI_MAC: "F4:93:9F:EF:C4:7E", REMOTE_CA_PREFIX: "20.2.2.0/24", + OUTBOUND_ROUTING_GROUP: "orouting_group1", ACL_GROUP: "group1", ACL_STAGE: 5 } @@ -211,7 +212,7 @@ def _apply_config(config_info): @pytest.fixture(scope="function") def dash_inbound_configs(dash_config_info, use_underlay_route, minigraph_facts): if use_underlay_route: - dash_config_info[LOCAL_PA_IP] = u"30.30.30.30" + dash_config_info[LOCAL_PA_IP] = u"30.30.30.20" dash_config_info[LOCAL_PTF_INTF] = list(minigraph_facts["minigraph_ptf_indices"].values()) else: dash_config_info[LOCAL_PTF_INTF] = [dash_config_info[LOCAL_PTF_INTF]] @@ -222,7 +223,7 @@ def dash_inbound_configs(dash_config_info, use_underlay_route, minigraph_facts): @pytest.fixture(scope="function") def apply_inbound_configs(dash_inbound_configs, apply_config): - dash_inbound_configs[ROUTING_ACTION] = "vnet" + dash_inbound_configs[ROUTING_TYPE] = "vnet" apply_config(dash_inbound_configs) @@ -244,13 +245,14 @@ def dash_outbound_configs(dash_config_info, use_underlay_route, minigraph_facts, @pytest.fixture(scope="function") def apply_vnet_configs(dash_outbound_configs, apply_config): - dash_outbound_configs[ROUTING_ACTION] = "vnet" + dash_outbound_configs[ROUTING_TYPE] = "vnet" + dash_outbound_configs[ROUTING_ACTION_TYPE] = "maprouting" apply_config(dash_outbound_configs) @pytest.fixture(scope="function") def apply_vnet_direct_configs(dash_outbound_configs, apply_config): - dash_outbound_configs[ROUTING_ACTION] = "vnet_direct" + dash_outbound_configs[ROUTING_TYPE] = "vnet_direct" dash_outbound_configs[ROUTING_ACTION_TYPE] = "maprouting" dash_outbound_configs[LOOKUP_OVERLAY_IP] = "1.1.1.1" @@ -259,7 +261,7 @@ def apply_vnet_direct_configs(dash_outbound_configs, apply_config): @pytest.fixture(scope="function") def apply_direct_configs(dash_outbound_configs, apply_config): - dash_outbound_configs[ROUTING_ACTION] = "direct" + dash_outbound_configs[ROUTING_TYPE] = "direct" del dash_outbound_configs[VNET2_NAME] apply_config(dash_outbound_configs) @@ -331,8 +333,9 @@ def vxlan_udp_dport(request, duthost): yield vxlan_udp_dport - logger.info("Restore the VXLAN UDP dst port to 4789") - config_vxlan_udp_dport(duthost, 4789) + if vxlan_udp_dport != 4789: + logger.info("Restore the VXLAN UDP dst port to 4789") + config_vxlan_udp_dport(duthost, 4789) @pytest.fixture(scope="function") diff --git a/tests/dash/constants.py b/tests/dash/constants.py index d5105c1001d..9961bb47e32 100644 --- a/tests/dash/constants.py +++ b/tests/dash/constants.py @@ -22,9 +22,10 @@ REMOTE_PA_PREFIX = "remote_pa_prefix" LOCAL_PTF_INTF = "local_ptf_intf" REMOTE_PTF_INTF = "remote_ptf_intf" -ROUTING_ACTION = "routing_action" +ROUTING_TYPE = "routing_type" ROUTING_ACTION_TYPE = "routing_action_type" LOOKUP_OVERLAY_IP = "lookup_overlay_ip" +OUTBOUND_ROUTING_GROUP = "outbound_routing_group" # For ACL ACL_GROUP = "acl_group" ACL_STAGE = "acl_stage" diff --git a/tests/dash/gnmi_utils.py b/tests/dash/gnmi_utils.py index cf38c8de92d..c4a82d90c2a 100644 --- a/tests/dash/gnmi_utils.py +++ b/tests/dash/gnmi_utils.py @@ -319,7 +319,7 @@ def gnmi_get(duthost, ptfhost, path_list): def apply_gnmi_file(localhost, duthost, ptfhost, dest_path=None, config_json=None, - wait_after_apply=5, max_updates_in_single_cmd=1024): + wait_after_apply=5, max_updates_in_single_cmd=1): """ Apply dash configuration with gnmi client @@ -393,6 +393,8 @@ def _devide_list(operation_list): if delete_list: delete_list_group = _devide_list(delete_list) + # Deletion in reverse order for dependency + delete_list_group.reverse() for delete_list in delete_list_group: gnmi_set(duthost, ptfhost, delete_list, [], []) if update_list: diff --git a/tests/dash/packets.py b/tests/dash/packets.py index dbb5ec606a1..be55f3e0513 100644 --- a/tests/dash/packets.py +++ b/tests/dash/packets.py @@ -70,8 +70,11 @@ def inbound_vnet_packets(dash_config_info, inner_extra_conf={}, inner_packet_typ pa_mismatch_vxlan_packet["IP"].src = str(remote_pa_ip + 1) masked_exp_packet = Mask(expected_packet) + masked_exp_packet.set_do_not_care_scapy(scapy.Ether, "dst") + masked_exp_packet.set_do_not_care_scapy(scapy.Ether, "src") masked_exp_packet.set_do_not_care_scapy(scapy.IP, "id") masked_exp_packet.set_do_not_care_scapy(scapy.IP, "chksum") + masked_exp_packet.set_do_not_care_scapy(scapy.IP, "ttl") masked_exp_packet.set_do_not_care_scapy(scapy.UDP, "sport") masked_exp_packet.set_do_not_care_scapy(scapy.UDP, "chksum") @@ -121,8 +124,11 @@ def outbound_vnet_packets(dash_config_info, inner_extra_conf={}, inner_packet_ty ) masked_exp_packet = Mask(expected_packet) + masked_exp_packet.set_do_not_care_scapy(scapy.Ether, "dst") + masked_exp_packet.set_do_not_care_scapy(scapy.Ether, "src") masked_exp_packet.set_do_not_care_scapy(scapy.IP, "id") masked_exp_packet.set_do_not_care_scapy(scapy.IP, "chksum") + masked_exp_packet.set_do_not_care_scapy(scapy.IP, "ttl") masked_exp_packet.set_do_not_care_scapy(scapy.UDP, "sport") masked_exp_packet.set_do_not_care_scapy(scapy.UDP, "chksum") return inner_packet, vxlan_packet, masked_exp_packet diff --git a/tests/dash/proto_utils.py b/tests/dash/proto_utils.py index 23a6e0b458e..ffad207b355 100644 --- a/tests/dash/proto_utils.py +++ b/tests/dash/proto_utils.py @@ -11,13 +11,15 @@ from dash_api.route_pb2 import Route from dash_api.route_rule_pb2 import RouteRule from dash_api.vnet_mapping_pb2 import VnetMapping -from dash_api.route_type_pb2 import RoutingType, ActionType, RouteType, RouteTypeItem +from dash_api.route_type_pb2 import RoutingType, ActionType, EncapType, RouteType, RouteTypeItem from dash_api.types_pb2 import IpVersion, IpPrefix, ValueOrRange from dash_api.acl_group_pb2 import AclGroup from dash_api.acl_out_pb2 import AclOut from dash_api.acl_in_pb2 import AclIn from dash_api.acl_rule_pb2 import AclRule, Action from dash_api.prefix_tag_pb2 import PrefixTag +from dash_api.route_group_pb2 import RouteGroup +from dash_api.eni_route_pb2 import EniRoute ENABLE_PROTO = True @@ -65,6 +67,14 @@ def eni_from_json(json_obj): pb.qos = json_obj["qos"] return pb +def eni_route_from_json(json_obj): + pb = EniRoute() + pb.group_id = json_obj["group_id"] + return pb + +def route_group_from_json(json_obj): + pb = RouteGroup() + return pb def route_from_json(json_obj): pb = Route() @@ -96,7 +106,11 @@ def routing_type_from_json(json_obj): pb = RouteType() pbi = RouteTypeItem() pbi.action_name = json_obj["name"] - pbi.action_type = ActionType.ACTION_TYPE_MAPROUTING + if json_obj["action_type"] == "staticencap": + pbi.action_type = ActionType.ACTION_TYPE_STATICENCAP + pbi.encap_type = EncapType.ENCAP_TYPE_VXLAN + elif json_obj["action_type"] == "maprouting": + pbi.action_type = ActionType.ACTION_TYPE_MAPROUTING pb.items.append(pbi) return pb @@ -186,7 +200,9 @@ def prefix_tag_from_json(json_obj): "VNET": vnet_from_json, "VNET_MAPPING": vnet_mapping_from_json, "QOS": qos_from_json, + "ROUTE_GROUP": route_group_from_json, "ENI": eni_from_json, + "ENI_ROUTE": eni_route_from_json, "ROUTE": route_from_json, "ROUTE_RULE": route_rule_from_json, "ROUTING_TYPE": routing_type_from_json, diff --git a/tests/dash/templates/dash_basic_config.j2 b/tests/dash/templates/dash_basic_config.j2 index 2aec79db4a5..15767ab69d1 100644 --- a/tests/dash/templates/dash_basic_config.j2 +++ b/tests/dash/templates/dash_basic_config.j2 @@ -6,6 +6,22 @@ }, "OP": "{{ op }}" }, + { + "DASH_ROUTING_TYPE_TABLE:vnet_encap" : { + "name": "action1", + "action_type": "staticencap" + }, + "OP": "{{ op }}" + }, +{%- if routing_action_type is defined -%} + { + "DASH_ROUTING_TYPE_TABLE:{{ routing_type }}" : { + "name": "action1", + "action_type": "{{ routing_action_type }}" + }, + "OP": "{{ op }}" + }, +{%- endif %} {%- if vnet1_name is defined %} { "DASH_VNET_TABLE:{{ vnet1_name }}" : { @@ -33,6 +49,12 @@ "OP": "{{ op }}" }, {%- endif %} + { + "DASH_ROUTE_GROUP_TABLE:{{ outbound_routing_group }}" : { + "disabled":"false" + }, + "OP": "{{ op }}" + }, { "DASH_QOS_TABLE:qos100" : { "qos_id":"100", @@ -54,8 +76,8 @@ "OP": "{{ op }}" }, { - "DASH_ROUTE_TABLE:{{ eni }}:{{ remote_ca_prefix }}" : { - "action_type":"{{ routing_action }}" + "DASH_ROUTE_TABLE:{{ outbound_routing_group }}:{{ remote_ca_prefix }}" : { + "action_type":"{{ routing_type }}" {%- if lookup_overlay_ip is defined -%}, "overlay_ip": "{{ lookup_overlay_ip }}" {%- endif %} @@ -65,18 +87,9 @@ }, "OP": "{{ op }}" } -{%- if routing_action_type is defined -%}, - { - "DASH_ROUTING_TYPE_TABLE:{{ routing_action }}" : { - "name": "action1", - "action_type": "{{ routing_action_type }}" - }, - "OP": "{{ op }}" - } -{%- endif %} {%- if vnet2_name is defined -%}, { - "DASH_ROUTE_RULE_TABLE:{{ eni }}:{{ vnet2_vni }}:{{ remote_pa_prefix }}" : { + "DASH_ROUTE_RULE_TABLE:{{ eni }}:{{ vnet2_vni }}:{{ remote_pa_ip }}" : { "action_type":"decap", "priority":"1", "pa_validation":"true", @@ -85,4 +98,10 @@ "OP": "{{ op }}" } {%- endif %} + ,{ + "DASH_ENI_ROUTE_TABLE:{{ eni }}" : { + "group_id":"{{ outbound_routing_group }}" + }, + "OP": "{{ op }}" + } ]