Skip to content

Commit d5a05ba

Browse files
authored
Merge pull request #214 from t-mialve/t-mialve/integration-testing
Add dalec integration testing
2 parents 68d5ec7 + 0f7a3b1 commit d5a05ba

File tree

4 files changed

+163
-1
lines changed

4 files changed

+163
-1
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module sigs.k8s.io/azurelustre-csi-driver
22

3-
go 1.23.6
3+
go 1.23.8
44

55
require (
66
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
apiVersion: v1
3+
kind: Pod
4+
metadata:
5+
name: azurelustre-integration-dalec
6+
spec:
7+
containers:
8+
- name: integration-dalec
9+
image: ${IMAGE_NAME}
10+
imagePullPolicy: Always
11+
command: ["bash", "/test/run_integration_test.sh"]
12+
env:
13+
- name: MSFT_GOLANG_PKG_VER
14+
value: "${MSFT_GOLANG_PKG_VER}"
15+
volumeMounts:
16+
- name: script-volume
17+
mountPath: /test/run_integration_test.sh
18+
subPath: run_integration_test.sh
19+
readOnly: true
20+
volumes:
21+
- name: script-volume
22+
configMap:
23+
name: integration-dalec-script
24+
restartPolicy: Never
25+
nodeSelector:
26+
kubernetes.io/os: linux
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/bin/bash
2+
3+
# Copyright 2025 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o xtrace
18+
set -o errexit
19+
set -o pipefail
20+
set -o nounset
21+
22+
readonly volname="citest-$(date +%s)"
23+
readonly volsize="2147483648"
24+
readonly endpoint="unix:///csi/csi.sock"
25+
readonly target_path="/tmp/target_path"
26+
readonly lustre_fs_ip=1.2.3.4
27+
28+
mkdir -p $target_path
29+
30+
apt-get update
31+
apt-get install -y --no-install-recommends kmod wget git ca-certificates lsb-release gpg curl
32+
update-ca-certificates
33+
34+
curl -sL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null
35+
echo "deb [arch=amd64,arm64,armhf] https://packages.microsoft.com/ubuntu/22.04/prod jammy main" | tee /etc/apt/sources.list.d/amlfs.list
36+
apt-get update
37+
38+
# This should match the version of Go that is used to build the CSI driver
39+
apt install -y msft-golang=${MSFT_GOLANG_PKG_VER}
40+
41+
go version
42+
43+
lctl network up || true
44+
echo "$(date -u) Enabled Lustre client kernel modules."
45+
46+
echo "$(date -u) Entering Lustre CSI driver"
47+
48+
echo "$(date -u) install csc"
49+
go install github.com/dell/gocsi/csc@latest
50+
export PATH=$PATH:/root/go/bin # add csc to path
51+
52+
mkdir /csi
53+
echo "$(date -u) Exiting Lustre CSI driver"
54+
nohup 2>&1 /app/azurelustreplugin --v=5 \
55+
--endpoint=${endpoint} \
56+
--enable-azurelustre-mock-mount \
57+
--nodeid=integrationtestnode >csi.log &
58+
59+
sleep 5
60+
61+
echo "====: $(date -u) Exiting integration test"
62+
export X_CSI_DEBUG=true
63+
echo "====: $(date -u) Create volume test:"
64+
value="$(csc controller new --endpoint "${endpoint}" \
65+
--cap MULTI_NODE_MULTI_WRITER,mount,,, \
66+
"${volname}" \
67+
--req-bytes "${volsize}" \
68+
--params fs-name=lustrefs,mgs-ip-address="${lustre_fs_ip}")"
69+
sleep 5
70+
71+
volumeid="$(echo "$value" | awk '{print $1}' | sed 's/"//g')"
72+
echo "====: $(date -u) Volume ID is $volumeid"
73+
74+
echo "====: $(date -u) Validate volume capabilities test:"
75+
csc controller validate-volume-capabilities --endpoint "${endpoint}" \
76+
--cap MULTI_NODE_MULTI_WRITER,mount,,, \
77+
"$volumeid"
78+
79+
echo "====: $(date -u) stats test:"
80+
csc node stats --endpoint "${endpoint}" "${volumeid}:${target_path}"
81+
sleep 2
82+
83+
echo "====: $(date -u) Node publish volume test:" # Requires routng to amlfs
84+
csc node publish --endpoint "${endpoint}" \
85+
--cap MULTI_NODE_MULTI_WRITER,mount,,, \
86+
--target-path "${target_path}" \
87+
--vol-context "fs-name=lustrefs,mgs-ip-address=${lustre_fs_ip}" \
88+
"${volumeid}"
89+
sleep 3
90+
91+
echo "====: $(date -u) Node unpublish volume test:" # Requires routng to amlfs
92+
csc node unpublish --endpoint "${endpoint}" \
93+
--target-path "$target_path" \
94+
"$volumeid"
95+
96+
echo "====: $(date -u) Delete volume test:"
97+
csc controller del --endpoint "${endpoint}" "$volumeid"
98+
99+
echo "====: $(date -u) Identity test:"
100+
csc identity plugin-info --endpoint "${endpoint}"
101+
102+
echo "====: $(date -u) Node get info test:"
103+
csc node get-info --endpoint "${endpoint}"
104+
105+
echo "$(date -u) Integration test on aks is completed."
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
set -euox pipefail
4+
5+
# Ensure required variables are set
6+
: "${IMAGE_NAME:?Required variable IMAGE_NAME is not set}" # Ex: upstream.azurecr.io/oss/v2/kubernetes-csi/azurelustre-csi:v0.2.0
7+
: "${MSFT_GOLANG_PKG_VER:?Required variable MSFT_GOLANG_PKG_VER is not set}" # Ex: 1.23.7-ubuntu22.04u1
8+
9+
echo "IMAGE_NAME: ${IMAGE_NAME}"
10+
echo "MSFT_GOLANG_PKG_VER: ${MSFT_GOLANG_PKG_VER}"
11+
12+
# Create a configmap for the integration test script
13+
kubectl delete configmap integration-dalec-script --ignore-not-found
14+
kubectl create configmap integration-dalec-script --from-file=run_integration_test.sh
15+
16+
# Show the filled in template
17+
envsubst < integration_dalec_aks.yaml.template
18+
19+
# Make sure to delete any previous instances of the pod
20+
envsubst < integration_dalec_aks.yaml.template | kubectl delete -f - --ignore-not-found
21+
envsubst < integration_dalec_aks.yaml.template | kubectl apply -f -
22+
23+
# Now running - wait for completion!
24+
pod=azurelustre-integration-dalec
25+
kubectl wait --for=condition=Ready pod/${pod} --timeout=300s
26+
kubectl wait --for=condition=Ready=false pod/${pod} --timeout=300s
27+
# Grab Result.
28+
result=$(kubectl get pod ${pod} -o=jsonpath='{.status.containerStatuses[*].state.*.exitCode}')
29+
kubectl logs ${pod}
30+
echo "Result: ${result}"
31+
exit ${result}

0 commit comments

Comments
 (0)