Skip to content
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

Swiftv2 e2e tests #2626

Merged
merged 50 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
3a62dc5
tmp commit to test whether the cluster can be set up.
csfmomo Mar 5, 2024
1f6ccc4
Resolved merge conflicts.
csfmomo Mar 5, 2024
5d5dd84
Fix the route.
csfmomo Mar 5, 2024
364b1ee
Remove unnecessary dependency.
csfmomo Mar 5, 2024
68fed0a
Modify the cluster creation.
csfmomo Mar 6, 2024
aedd344
Swift v2 e2e test structure.
csfmomo Mar 18, 2024
6f7e24e
Add variables.
csfmomo Mar 19, 2024
84af076
Fix the format and make it a valid yaml.
csfmomo Mar 20, 2024
072dae1
Add datapath tests for swiftv2.
csfmomo Apr 3, 2024
a8450fa
Link the tests with the pipeline steps.
csfmomo Apr 3, 2024
337b281
Update the testing file name.
csfmomo Apr 3, 2024
6e03ae1
Remove unnecessary comment.
csfmomo Apr 4, 2024
816a17f
Fix the pod name
csfmomo Apr 4, 2024
8ab41ad
Sleep before checking the pod.
csfmomo Apr 4, 2024
f4433d2
Check the pni after baking time.
csfmomo Apr 4, 2024
43ec47f
Update the vnet name.
csfmomo Apr 5, 2024
5369685
Update the variables value.
csfmomo Apr 5, 2024
1f27059
Update the sub tests use.
csfmomo Apr 5, 2024
0ea3173
Update the cluster name from mt prefix to mta
csfmomo Apr 5, 2024
aa2b175
Add the vm size.
csfmomo Apr 5, 2024
15bb36d
Update the token.
csfmomo Apr 6, 2024
12c3ab3
Update the dummy cluster's vnet.
csfmomo Apr 8, 2024
fbbad76
Add a connection test.
csfmomo Apr 8, 2024
291cfe1
Update the test file name.
csfmomo Apr 8, 2024
4dff05b
Add one more pod with delegation network.
csfmomo Apr 9, 2024
8bbe74b
Start 2 mtpod.
csfmomo Apr 10, 2024
73f4da3
Add the test for mtpod to mtpod connection.
csfmomo Apr 10, 2024
3a83bf2
Include the commented out code for swiftv2 datapath test.
csfmomo Apr 17, 2024
5945be8
Update the yaml file format.
csfmomo Apr 17, 2024
69ada3c
Update the command to run the swiftv2 tests.
csfmomo Apr 18, 2024
94557b8
Move tests to the code file.
csfmomo Apr 24, 2024
1fb9acf
Update the dummy cluster since the previous one has been auto deleted.
csfmomo Apr 26, 2024
e7611d9
Update the IP of the pod.
csfmomo Apr 26, 2024
c52c5a0
Update the host IP in the test part too.
csfmomo Apr 26, 2024
33588c9
Separate different test stages.
csfmomo Apr 28, 2024
5b1295d
Use mtpnc to grep IP.
csfmomo Apr 29, 2024
7be53c1
Update k to kubectl
csfmomo Apr 29, 2024
6fd12a8
Add mtpnc detailed info.
csfmomo Apr 30, 2024
ff6773b
Remove the wrong comments.
csfmomo Apr 30, 2024
4e5ae36
Use the script to run the test for now.
csfmomo Apr 30, 2024
37e2c14
Remove unnecessary variables.
csfmomo Apr 30, 2024
223e713
Update the cluster creation.
csfmomo May 1, 2024
93d4b31
Update parameters.
csfmomo May 1, 2024
07854b0
Remove unnecessary parameters.
csfmomo May 1, 2024
98b6e42
Update the testing code part to match the script way.
csfmomo May 6, 2024
05ec1c7
Remove unnecessary node part.
csfmomo May 6, 2024
89b910f
Remove the tests from script part.
csfmomo May 6, 2024
e0d94e9
Resolve the lint complaint.
csfmomo May 7, 2024
ef0bfa8
Resume the "Remove AKS Engine storage account usage"
csfmomo May 7, 2024
01a9273
Merge branch 'master' into shchenTest0304
csfmomo May 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .pipelines/multitenancy/swiftv2-e2e-job-template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
parameters:
name: ""
displayName: ""
clusterType: ""
clusterName: ""
vmSize: ""
k8sVersion: ""
dependsOn: ""
nodePoolName: ""

stages:
- stage: ${{ parameters.clusterName }}
displayName: Create Cluster - ${{ parameters.displayName }}
dependsOn:
- ${{ parameters.dependsOn }}
- setup
pool:
name: $(BUILD_POOL_NAME_DEFAULT)
variables:
commitID: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.commitID'] ]
jobs:
- template: ../templates/create-cluster-swiftv2.yaml
parameters:
name: ${{ parameters.name }}
displayName: ${{ parameters.displayName }}
clusterType: ${{ parameters.clusterType }}
clusterName: ${{ parameters.clusterName }}-$(commitID)
vmSize: ${{ parameters.vmSize }}
k8sVersion: ${{ parameters.k8sVersion }}
dependsOn: ${{ parameters.dependsOn }}
region: $(REGION_SWIFTV2_CLUSTER_TEST) # Swiftv2 has a specific region requirements

- stage: ${{ parameters.name }}
# condition: and( succeeded(), not(eq(dependencies.dualstackoverlaye2e.result,'SucceededWithIssues')) ) # Cant use parameters in dependencies
displayName: E2E - ${{ parameters.displayName }}
dependsOn:
- setup
- publish
- ${{ parameters.clusterName }}
variables:
GOPATH: "$(Agent.TempDirectory)/go" # Go workspace path
GOBIN: "$(GOPATH)/bin" # Go binaries path
modulePath: "$(GOPATH)/src/github.com/Azure/azure-container-networking"
commitID: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.commitID'] ]
pool:
name: $(BUILD_POOL_NAME_DEFAULT)
jobs:
- job: ${{ parameters.name }}
displayName: Swiftv2 Multitenancy E2E Test Suite - (${{ parameters.name }})
pool:
name: $(BUILD_POOL_NAME_DEFAULT)
demands:
- agent.os -equals Linux
- Role -equals $(CUSTOM_E2E_ROLE)
steps:
- template: swiftv2-e2e-step-template.yaml
parameters:
name: ${{ parameters.name }}
clusterName: ${{ parameters.clusterName }}-$(commitID)
os: linux

- template: ../cni/k8s-e2e/k8s-e2e-job-template.yaml
parameters:
sub: $(ACN_TEST_SERVICE_CONNECTION)
clusterName: ${{ parameters.clusterName }}-$(commitID)
os: ${{ parameters.os }}
dependsOn: ${{ parameters.name }}
datapath: true
dns: true
portforward: true
hostport: true
service: true

- job: failedE2ELogs
displayName: "Failure Logs"
dependsOn:
- ${{ parameters.name }}
condition: failed()
steps:
- template: ../templates/log-template.yaml
parameters:
clusterName: ${{ parameters.clusterName }}-$(commitID)
os: linux
cni: cniv2
97 changes: 97 additions & 0 deletions .pipelines/multitenancy/swiftv2-e2e-step-template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
parameters:
name: ""
clusterName: ""
cni: cniv2
os: ""

steps:
- bash: |
go version
go env
mkdir -p '$(GOBIN)'
mkdir -p '$(GOPATH)/pkg'
mkdir -p '$(modulePath)'
echo '##vso[task.prependpath]$(GOBIN)'
echo '##vso[task.prependpath]$(GOROOT)/bin'
name: "GoEnv"
displayName: "Set up the Go environment"

- task: KubectlInstaller@0
inputs:
kubectlVersion: latest

- task: AzureCLI@1
inputs:
azureSubscription: $(ACN_TEST_SERVICE_CONNECTION)
scriptLocation: "inlineScript"
scriptType: "bash"
addSpnToEnvironment: true
inlineScript: |
set -e
make -C ./hack/aks set-kubeconf AZCLI=az CLUSTER=${{ parameters.clusterName }}
ls -lah
pwd
kubectl cluster-info
kubectl get po -owide -A
echo "Apply the pod network yaml to start the delegation"
less test/integration/manifests/swiftv2/podnetwork.yaml
envsubst '${SUBNET_TOKEN},${SUBNET_GUID},${SUBNET_RESOURCE_ID},${VNET_GUID}' < test/integration/manifests/swiftv2/podnetwork.yaml | kubectl apply -f -
echo "Check the podnetwork yaml file"
less test/integration/manifests/swiftv2/podnetwork.yaml
kubectl get pn
kubectl describe pn
echo "Apply the pod network instance yaml to reserve IP"
kubectl apply -f test/integration/manifests/swiftv2/pni.yaml
kubectl get pni
kubectl describe pni
export NODE_NAME_0="$(kubectl get nodes -o json | jq -r .items[0].metadata.name)"
echo $NODE_NAME_0
echo "Start the first pod using the reserved IP"
envsubst '$NODE_NAME_0' < test/integration/manifests/swiftv2/mtpod0.yaml | kubectl apply -f -
export NODE_NAME_1="$(kubectl get nodes -o json | jq -r .items[1].metadata.name)"
echo $NODE_NAME_1
echo "Start another pod using the reserved IP"
envsubst '$NODE_NAME_1' < test/integration/manifests/swiftv2/mtpod1.yaml | kubectl apply -f -
sleep 2m
kubectl get pod -o wide -A
sleep 2m
echo "Check pods after 4 minutes"
kubectl get po -owide -A
kubectl describe pni
name: "start_swiftv2_pods"
displayName: "Start Swiftv2 Pods"
env:
SUBNET_TOKEN: $(SUBNET_TOKEN)

- script: |
set -e
kubectl get po -owide -A
echo "Start the connection test"
kubectl exec mtpod0 -it -- ip a
echo "Check mtpnc"
kubectl get mtpnc
kubectl describe mtpnc mtpod0
kubectl describe mtpnc mtpod1
echo "Test the connection to a mtpod in the same delegated network and in another node"
export IP0=`kubectl describe mtpnc mtpod0 | grep "Primary IP" | cut -c 17- | head -c -4`
echo $IP0
kubectl exec mtpod0 -it -- ping -c 3 $IP0
export IP1=`kubectl describe mtpnc mtpod1 | grep "Primary IP" | cut -c 17- | head -c -4`
echo $IP1
kubectl exec mtpod0 -it -- ping -c 3 $IP1
echo "Test the connection to a non-mt pod (172.25.0.7) in the same delegated network and in another cluster"
kubectl exec mtpod0 -it -- ping -c 3 -W 1 172.25.0.7
retryCountOnTaskFailure: 3
name: "Swiftv2_Tests"
displayName: "Swiftv2 Tests through script"

- script: |
set -e
kubectl get po -owide -A
cd test/integration/swiftv2
echo "TestSwiftv2PodToPod and will run it after migration from scripts."
go test -count=1 swiftv2_test.go -timeout 3m -tags swiftv2 -run ^TestSwiftv2PodToPod$ -tags=swiftv2,integration -v
retryCountOnTaskFailure: 3
name: "Swiftv2_Tests_future_version"
displayName: "Swiftv2 Tests through code"

54 changes: 54 additions & 0 deletions .pipelines/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,21 @@ stages:
vmSize: Standard_B2ms
dependsOn: "test"

# Swiftv2 E2E tests with multitenancy cluster start up
- template: multitenancy/swiftv2-e2e-job-template.yaml
parameters:
name: "swiftv2_e2e"
displayName: Swiftv2 Multitenancy
os: linux
clusterType: swiftv2-multitenancy-cluster-up
clusterName: "mtacluster"
nodePoolName: "mtapool"
vmSize: Standard_D4_v2
dependsOn: "test"
dummyClusterName: "swiftv2dummy"
dummyClusterType: "swiftv2-dummy-cluster-up"
dummyClusterDisplayName: Swiftv2 Multitenancy Dummy Cluster

- stage: delete
displayName: Delete Clusters
condition: always()
Expand All @@ -518,6 +533,7 @@ stages:
- aks_windows_22_e2e
- dualstackoverlay_e2e
- cilium_dualstackoverlay_e2e
- swiftv2_e2e
variables:
commitID: $[ stagedependencies.setup.env.outputs['EnvironmentalVariables.commitID'] ]
jobs:
Expand Down Expand Up @@ -566,6 +582,12 @@ stages:
cilium_dualstackoverlay_e2e:
name: cilium_dualstackoverlay_e2e
clusterName: "cildsovere2e"
swiftv2_e2e:
name: swiftv2_e2e
clusterName: "mtcluster"
swiftv2_dummy_e2e:
name: swiftv2_dummy_e2e
clusterName: "swiftv2dummy"
steps:
- template: templates/delete-cluster.yaml
parameters:
Expand All @@ -592,3 +614,35 @@ stages:
echo $TAG
echo $CURRENT_VERSION
echo "Checking if branch is up to date with master"

- stage: cleanup
displayName: Cleanup
dependsOn:
- azure_overlay_e2e
- aks_swift_e2e
- cilium_e2e
- cilium_overlay_e2e
- cilium_h_overlay_e2e
- aks_ubuntu_22_linux_e2e
- aks_windows_22_e2e
- dualstackoverlay_e2e
- cilium_dualstackoverlay_e2e
- swiftv2_e2e
jobs:
- job: delete_remote_artifacts
displayName: Delete remote artifacts
pool:
name: $(BUILD_POOL_NAME_DEFAULT)
demands: agent.os -equals Linux
steps:
- checkout: none
- task: AzureCLI@1
inputs:
azureSubscription: $(BUILD_VALIDATIONS_SERVICE_CONNECTION)
scriptLocation: "inlineScript"
inlineScript: |
BUILD_NUMBER=$(Build.BuildNumber)
BUILD_NUMBER=${BUILD_NUMBER//./-}
echo Deleting storage container with name acn-$BUILD_NUMBER and account name $(STORAGE_ACCOUNT_NAME)
az storage container delete -n acn-$BUILD_NUMBER --account-name $(STORAGE_ACCOUNT_NAME)
displayName: Cleanup remote Azure storage container
34 changes: 34 additions & 0 deletions .pipelines/templates/create-cluster-swiftv2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
parameters:
os: linux

jobs:
- job: ${{ parameters.name }}
displayName: Cluster - ${{ parameters.name }}
steps:
- task: AzureCLI@1
inputs:
azureSubscription: $(ACN_TEST_SERVICE_CONNECTION)
scriptLocation: "inlineScript"
scriptType: "bash"
addSpnToEnvironment: true
inlineScript: |
set -e
echo "Check az version"
az version
if ${{ lower(contains(parameters.clusterType, 'dualstack')) }}
then
echo "Install az cli extension preview"
az extension add --name aks-preview
az extension update --name aks-preview
fi
mkdir -p ~/.kube/
make -C ./hack/aks azcfg AZCLI=az REGION=${{ parameters.region }}

make -C ./hack/aks ${{ parameters.clusterType }} \
AZCLI=az REGION=${{ parameters.region }} SUB=$(SUB_AZURE_NETWORK_AGENT_TEST) \
CLUSTER=${{ parameters.clusterName }} \
VM_SIZE=${{ parameters.vmSize }} OS=${{parameters.os}} \

echo "Cluster successfully created"
displayName: Cluster - ${{ parameters.clusterType }}
continueOnError: ${{ contains(parameters.clusterType, 'dualstack') }}
22 changes: 22 additions & 0 deletions hack/aks/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,28 @@ swift-up: rg-up swift-net-up ## Bring up a SWIFT AzCNI cluster
--yes
@$(MAKE) set-kubeconf

swiftv2-multitenancy-cluster-up: rg-up
$(AZCLI) aks create -n $(CLUSTER) -g $(GROUP) -l $(REGION) \
--network-plugin azure \
--network-plugin-mode overlay \
--kubernetes-version 1.28 \
--nodepool-name "mtapool" \
--node-vm-size Standard_D4_v2 \
csfmomo marked this conversation as resolved.
Show resolved Hide resolved
--node-count 2 \
--nodepool-tags fastpathenabled=true \
--no-ssh-key \
--yes
@$(MAKE) set-kubeconf

swiftv2-dummy-cluster-up: rg-up swift-net-up ## Bring up a SWIFT AzCNI cluster
$(AZCLI) aks create -n $(CLUSTER) -g $(GROUP) -l $(REGION) \
--network-plugin azure \
--vnet-subnet-id /subscriptions/$(SUB)/resourceGroups/$(GROUP)/providers/Microsoft.Network/virtualNetworks/$(VNET)/subnets/nodenet \
--pod-subnet-id /subscriptions/$(SUB)/resourceGroups/$(GROUP)/providers/Microsoft.Network/virtualNetworks/$(VNET)/subnets/podnet \
--no-ssh-key \
--yes
@$(MAKE) set-kubeconf

# The below Vnet Scale clusters are currently only in private preview and available with Kubernetes 1.28
# These AKS clusters can only be created in a limited subscription listed here:
# https://dev.azure.com/msazure/CloudNativeCompute/_git/aks-rp?path=/resourceprovider/server/microsoft.com/containerservice/flags/network_flags.go&version=GBmaster&line=134&lineEnd=135&lineStartColumn=1&lineEndColumn=1&lineStyle=plain&_a=contents
Expand Down
22 changes: 22 additions & 0 deletions test/integration/manifests/swiftv2/mtpod0.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: v1
kind: Pod
metadata:
labels:
kubernetes.azure.com/pod-network: aksswiftvnetv20425
kubernetes.azure.com/pod-network-instance: pni1
name: mtpod0
namespace: default
spec:
containers:
- image: nicolaka/netshoot:latest
imagePullPolicy: Always
name: mtpod0
command: ["/bin/bash"]
args: ["-c", "while true; do ping localhost; sleep 60;done"]
securityContext:
privileged: true
ports:
- containerPort: 80
protocol: TCP
nodeSelector:
kubernetes.io/hostname: $NODE_NAME_0
22 changes: 22 additions & 0 deletions test/integration/manifests/swiftv2/mtpod1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: v1
kind: Pod
metadata:
labels:
kubernetes.azure.com/pod-network: aksswiftvnetv20425
csfmomo marked this conversation as resolved.
Show resolved Hide resolved
kubernetes.azure.com/pod-network-instance: pni1
name: mtpod1
namespace: default
spec:
containers:
- image: nicolaka/netshoot:latest
imagePullPolicy: Always
name: mtpod1
command: ["/bin/bash"]
args: ["-c", "while true; do ping localhost; sleep 60;done"]
securityContext:
privileged: true
ports:
- containerPort: 80
protocol: TCP
nodeSelector:
kubernetes.io/hostname: $NODE_NAME_1
7 changes: 7 additions & 0 deletions test/integration/manifests/swiftv2/pni.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: multitenancy.acn.azure.com/v1alpha1
kind: PodNetworkInstance
metadata:
name: pni1
spec:
podnetwork: aksswiftvnetv20425
podIPReservationSize: 2
10 changes: 10 additions & 0 deletions test/integration/manifests/swiftv2/podnetwork.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: multitenancy.acn.azure.com/v1alpha1
kind: PodNetwork
metadata:
labels:
kubernetes.azure.com/override-subnet-token: $SUBNET_TOKEN
name: aksswiftvnetv20425
spec:
subnetGUID: $SUBNET_GUID
subnetResourceID: $SUBNET_RESOURCE_ID
vnetGUID: $VNET_GUID
Loading
Loading