-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[dash] Add Privatelink traffic test #14757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 11 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
2831abe
[dash]: Initial changes to run dash tests on smartswitch
prabhataravind ee6190d
Add privatelink configs
theasianpianist 52870fd
Add privatelink outbound test
theasianpianist c9fdb12
improve config formatting
theasianpianist dd59d33
remove unused config
theasianpianist a0f8d14
address review comments
theasianpianist b99c57f
Inbound PL traffic test
theasianpianist 2c049fb
Add GRE outbound test; cleanup routes on NPU
theasianpianist ffc915b
Separate VXLAN and GRE test cases
theasianpianist 6afc030
Merge branch 'master' of github.com:sonic-net/sonic-mgmt into dash-pl
theasianpianist a2f22cd
Update inner MAC addresses for PL test
theasianpianist ad590d8
fix inbound DPU to VM inner MAC
theasianpianist 0645b7f
Merge branch 'master' of github.com:sonic-net/sonic-mgmt into dash-pl
theasianpianist 85d25c0
specify sonic-mgmt image tag
theasianpianist 8aa3fb8
skip DASH tests on KVM
theasianpianist File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| from dash_api.eni_pb2 import State | ||
| from dash_api.route_type_pb2 import ActionType, EncapType, RoutingType | ||
|
|
||
| VNET = "vnet" | ||
| VNET_ENCAP = "vnet_encap" | ||
| VNET_DIRECT = "vnet_direct" | ||
| PRIVATELINK = "privatelink" | ||
| DECAP = "decap" | ||
|
|
||
| APPLIANCE_VIP = "10.1.0.5" | ||
| VM1_PA = "25.1.1.1" # VM host physical address | ||
| VM1_CA = "10.0.0.11" # VM customer address | ||
| VM_CA_SUBNET = "10.0.0.0/16" | ||
| PE_PA = "101.1.2.3" # private endpoint physical address | ||
| PE_CA = "10.2.0.100" # private endpoint customer address | ||
| PE_CA_SUBNET = "10.2.0.0/16" | ||
| PL_ENCODING_IP = "::56b2:0:ff71:0:0" | ||
| PL_ENCODING_MASK = "::ffff:ffff:ffff:0:0" | ||
| PL_OVERLAY_SIP = "fd41:108:20:abc:abc::0" | ||
| PL_OVERLAY_SIP_MASK = "ffff:ffff:ffff:ffff:ffff:ffff::" | ||
| PL_OVERLAY_DIP = "2603:10e1:100:2::3401:203" | ||
| PL_OVERLAY_DIP_MASK = "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" | ||
|
|
||
| APPLIANCE_ID = "100" | ||
| VM_VNI = "4321" | ||
| ENCAP_VNI = 100 | ||
| VNET1 = "Vnet1" | ||
| VNET1_VNI = "45654" | ||
| VNET1_GUID = "559c6ce8-26ab-4193-b946-ccc6e8f930b2" | ||
| ENI_MAC = "F4:93:9F:EF:C4:7E" | ||
| ENI_MAC_STRING = ENI_MAC.replace(":", "") | ||
| REMOTE_MAC = "43:BE:65:25:FA:67" | ||
| REMOTE_MAC_STRING = REMOTE_MAC.replace(":", "") | ||
| ENI_ID = "497f23d7-f0ac-4c99-a98f-59b470e8c7bd" | ||
| ROUTE_GROUP1 = "RouteGroup1" | ||
| ROUTE_GROUP2 = "RouteGroup2" | ||
| ROUTE_GROUP1_GUID = "48af6ce8-26cc-4293-bfa6-0126e8fcdeb2" | ||
| ROUTE_GROUP2_GUID = "58cf62e0-22cc-4693-baa6-012358fcdec9" | ||
|
|
||
|
|
||
| APPLIANCE_CONFIG = { | ||
| f"DASH_APPLIANCE_TABLE:{APPLIANCE_ID}": { | ||
| "sip": APPLIANCE_VIP, | ||
| "vm_vni": VM_VNI | ||
| } | ||
| } | ||
|
|
||
| VNET_CONFIG = { | ||
| f"DASH_VNET_TABLE:{VNET1}": { | ||
| "vni": VNET1_VNI, | ||
| "guid": VNET1_GUID | ||
| } | ||
| } | ||
|
|
||
| ENI_CONFIG = { | ||
| f"DASH_ENI_TABLE:{ENI_ID}": { | ||
| "vnet": VNET1, | ||
| "underlay_ip": VM1_PA, | ||
| "mac_address": ENI_MAC, | ||
| "eni_id": ENI_ID, | ||
| "admin_state": State.STATE_ENABLED, | ||
| "pl_underlay_sip": APPLIANCE_VIP, | ||
| "pl_sip_encoding": f"{PL_ENCODING_IP}/{PL_ENCODING_MASK}" | ||
| } | ||
| } | ||
|
|
||
| PE_VNET_MAPPING_CONFIG = { | ||
| f"DASH_VNET_MAPPING_TABLE:{VNET1}:{PE_CA}": { | ||
| "routing_type": RoutingType.ROUTING_TYPE_PRIVATELINK, | ||
| "underlay_ip": PE_PA, | ||
| "overlay_sip_prefix": f"{PL_OVERLAY_SIP}/{PL_OVERLAY_SIP_MASK}", | ||
| "overlay_dip_prefix": f"{PL_OVERLAY_DIP}/{PL_OVERLAY_DIP_MASK}", | ||
| } | ||
| } | ||
|
|
||
| VM1_VNET_MAPPING_CONFIG = { | ||
| f"DASH_VNET_MAPPING_TABLE:{VNET1}:{VM1_CA}": { | ||
| "routing_type": RoutingType.ROUTING_TYPE_VNET, | ||
| "underlay_ip": VM1_PA, | ||
| } | ||
| } | ||
|
|
||
| PE_SUBNET_ROUTE_CONFIG = { | ||
| f"DASH_ROUTE_TABLE:{ROUTE_GROUP1}:{PE_CA_SUBNET}": { | ||
| "routing_type": RoutingType.ROUTING_TYPE_VNET, | ||
| "vnet": VNET1, | ||
| } | ||
| } | ||
|
|
||
| VM_SUBNET_ROUTE_CONFIG = { | ||
| f"DASH_ROUTE_TABLE:{ROUTE_GROUP1}:{VM_CA_SUBNET}": { | ||
| "routing_type": RoutingType.ROUTING_TYPE_VNET, | ||
| "vnet": VNET1, | ||
| } | ||
| } | ||
|
|
||
| ROUTING_TYPE_VNET_CONFIG = { | ||
| f"DASH_ROUTING_TYPE_TABLE:{VNET}": { | ||
| "items": [ | ||
| { | ||
| "action_name": "action1", | ||
| "action_type": ActionType.ACTION_TYPE_STATICENCAP, | ||
| "encap_type": EncapType.ENCAP_TYPE_VXLAN, | ||
| }, | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| ROUTING_TYPE_PL_CONFIG = { | ||
| f"DASH_ROUTING_TYPE_TABLE:{PRIVATELINK}": { | ||
| "items": [ | ||
| { | ||
| "action_name": "action1", | ||
| "action_type": ActionType.ACTION_TYPE_4_to_6 | ||
| }, | ||
| { | ||
| "action_name": "action2", | ||
| "action_type": ActionType.ACTION_TYPE_STATICENCAP, | ||
| "encap_type": EncapType.ENCAP_TYPE_NVGRE, | ||
| "vni": ENCAP_VNI | ||
| } | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| ROUTE_GROUP1_CONFIG = { | ||
| f"DASH_ROUTE_GROUP_TABLE:{ROUTE_GROUP1}": { | ||
| "guid": ROUTE_GROUP1_GUID, | ||
| "version": "rg_version" | ||
| } | ||
| } | ||
|
|
||
| ENI_ROUTE_GROUP1_CONFIG = { | ||
| f"DASH_ENI_ROUTE_TABLE:{ENI_ID}": { | ||
| "group_id": ROUTE_GROUP1 | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| import logging | ||
| import json | ||
| import logging | ||
| import math | ||
| import time | ||
| import uuid | ||
| import math | ||
| from functools import lru_cache | ||
| import pytest | ||
|
|
||
| import proto_utils | ||
| import pytest | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
@@ -23,7 +23,8 @@ def __init__(self, duthost): | |
| self.gnmi_client_cert = "gnmiclient.crt" | ||
| self.gnmi_client_key = "gnmiclient.key" | ||
| self.gnmi_server_start_wait_time = 30 | ||
| self.enable_zmq = duthost.shell("netstat -na | grep -w 8100", module_ignore_errors=True)['rc'] == 0 | ||
| # self.enable_zmq = duthost.shell("netstat -na | grep -w 8100", module_ignore_errors=True)['rc'] == 0 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @theasianpianist , why change dash test case always enable ZMQ on GNMI? |
||
| self.enable_zmq = True | ||
| cmd = "docker images | grep -w sonic-gnmi" | ||
| if duthost.shell(cmd, module_ignore_errors=True)['rc'] == 0: | ||
| cmd = "docker ps | grep -w gnmi" | ||
|
|
@@ -267,6 +268,7 @@ def gnmi_set(duthost, ptfhost, delete_list, update_list, replace_list): | |
| cmd += '--xpath ' + xpath | ||
| cmd += ' ' | ||
| cmd += '--value ' + xvalue | ||
| logger.info(f"PTF GNMI command: {cmd}") | ||
| output = ptfhost.shell(cmd, module_ignore_errors=True) | ||
| error = "GRPC error\n" | ||
| if error in output['stdout']: | ||
|
|
@@ -324,6 +326,41 @@ def gnmi_get(duthost, ptfhost, path_list): | |
| raise Exception("error:" + msg) | ||
|
|
||
|
|
||
| def apply_messages( | ||
| localhost, | ||
| duthost, | ||
| ptfhost, | ||
| messages, | ||
| dpu_index, | ||
| set_db=True, | ||
| wait_after_apply=5, | ||
| max_updates_in_single_cmd=1024, | ||
| ): | ||
| env = GNMIEnvironment(duthost) | ||
| update_list = [] | ||
| delete_list = [] | ||
| for i, (key, config_dict) in enumerate(messages.items()): | ||
| message = proto_utils.parse_dash_proto(key, config_dict) | ||
| keys = key.split(":", 1) | ||
| gnmi_key = keys[0] + "[key=" + keys[1] + "]" | ||
| filename = f"update{i}" | ||
|
|
||
| if set_db: | ||
| if proto_utils.ENABLE_PROTO: | ||
| path = f"/APPL_DB/dpu{dpu_index}/{gnmi_key}:$/root/{filename}" | ||
| else: | ||
| path = f"/APPL_DB/dpu{dpu_index}/{gnmi_key}:@/root/{filename}" | ||
|
theasianpianist marked this conversation as resolved.
|
||
| with open(env.work_dir + filename, "wb") as file: | ||
| file.write(message.SerializeToString()) | ||
| update_list.append(path) | ||
| else: | ||
| path = f"/APPL_DB/dpu{dpu_index}/{gnmi_key}" | ||
| delete_list.append(path) | ||
|
|
||
| write_gnmi_files(localhost, duthost, ptfhost, env, delete_list, update_list, max_updates_in_single_cmd) | ||
| time.sleep(wait_after_apply) | ||
|
|
||
|
|
||
| def apply_gnmi_file(localhost, duthost, ptfhost, dest_path=None, config_json=None, | ||
| wait_after_apply=5, max_updates_in_single_cmd=1024): | ||
| """ | ||
|
|
@@ -371,20 +408,25 @@ def apply_gnmi_file(localhost, duthost, ptfhost, dest_path=None, config_json=Non | |
| keys = k.split(":", 1) | ||
| k = keys[0] + "[key=" + keys[1] + "]" | ||
| if proto_utils.ENABLE_PROTO: | ||
| path = "/APPL_DB/localhost/%s:$/root/%s" % (k, filename) | ||
| path = "/APPL_DB/dpu1/%s:$/root/%s" % (k, filename) | ||
| else: | ||
| path = "/APPL_DB/localhost/%s:@/root/%s" % (k, filename) | ||
| path = "/APPL_DB/dpu1/%s:@/root/%s" % (k, filename) | ||
|
theasianpianist marked this conversation as resolved.
|
||
| update_list.append(path) | ||
| elif operation["OP"] == "DEL": | ||
| for k, v in operation.items(): | ||
| if k == "OP": | ||
| continue | ||
| keys = k.split(":", 1) | ||
| k = keys[0] + "[key=" + keys[1] + "]" | ||
| path = "/APPL_DB/localhost/%s" % (k) | ||
| path = "/APPL_DB/dpu1/%s" % (k) | ||
| delete_list.append(path) | ||
| else: | ||
| logger.info("Invalid operation %s" % operation["OP"]) | ||
| write_gnmi_files(localhost, duthost, ptfhost, env, delete_list, update_list, max_updates_in_single_cmd) | ||
| time.sleep(wait_after_apply) | ||
|
|
||
|
|
||
| def write_gnmi_files(localhost, duthost, ptfhost, env, delete_list, update_list, max_updates_in_single_cmd): | ||
| localhost.shell(f'tar -zcvf /tmp/updates.tar.gz -C {env.work_dir} .') | ||
| ptfhost.copy(src='/tmp/updates.tar.gz', dest='~') | ||
| ptfhost.shell('tar -xf updates.tar.gz') | ||
|
|
@@ -410,4 +452,3 @@ def _devide_list(operation_list): | |
| ptfhost.shell('rm -f updates.tar.gz') | ||
| localhost.shell(f'rm -f {env.work_dir}update*') | ||
| ptfhost.shell('rm -f update*') | ||
| time.sleep(wait_after_apply) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to add smartswitch-t1 topo as well here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll do this later. Ok to merge for now.