Skip to content

Commit c112ff0

Browse files
test: migrate tests to HostProcess pods
1 parent cf83608 commit c112ff0

File tree

2 files changed

+39
-7
lines changed

2 files changed

+39
-7
lines changed

scripts/integration-test.yaml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: integration-test
5+
labels:
6+
app: integration-test
7+
spec:
8+
nodeName: windows_node # to be replaced by sed
9+
securityContext:
10+
windowsOptions:
11+
hostProcess: true
12+
runAsUserName: "NT AUTHORITY\\SYSTEM"
13+
hostNetwork: true
14+
containers:
15+
- name: agnhost
16+
image: mcr.microsoft.com/windows/nanoserver:ltsc2019
17+
command: ['powershell', '-command', 'Start-Sleep 100000']
18+
volumeMounts:
19+
- mountPath: /integration-test
20+
name: integration-test-volume
21+
nodeSelector:
22+
kubernetes.io/os: windows
23+
volumes:
24+
- name: integration-test-volume
25+
hostPath:
26+
path: /
27+
type: DirectoryOrCreate

scripts/utils.sh

+12-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if ! [ -z "${GCP_ZONE:-}" ]; then
1616
fi
1717

1818
sync_file_to_vm() {
19-
gcloud compute scp $@ $windows_node:"C:\\Users\\${current_account}"
19+
gcloud compute scp $@ $windows_node:"C:\\"
2020
}
2121

2222
compile_csi_proxy_integration_tests() {
@@ -25,6 +25,10 @@ compile_csi_proxy_integration_tests() {
2525
}
2626

2727
sync_csi_proxy_integration_tests() {
28+
# delete the pod that is potentially using the old file
29+
# if there is a pod accessing the existing file, this command would hang
30+
kubectl delete -f $pkgdir/scripts/integration-test.yaml --ignore-not-found=true
31+
2832
echo "Sync the integrationtests.exe binary"
2933
local integration_bin_path="$pkgdir/bin/integrationtests.test.exe"
3034
sync_file_to_vm $integration_bin_path
@@ -33,12 +37,13 @@ sync_csi_proxy_integration_tests() {
3337
run_csi_proxy_integration_tests() {
3438
echo "Run integration tests"
3539
local ps1=$(cat << 'EOF'
36-
"& {
37-
$ErrorActionPreference = \"Stop\";
38-
.\integrationtests.test.exe --test.v
39-
}"
40+
$ErrorActionPreference = "Stop";
41+
.$Env:CONTAINER_SANDBOX_MOUNT_POINT\integration-test\integrationtests.test.exe --test.v
4042
EOF
4143
);
42-
43-
gcloud compute ssh $windows_node --command="powershell -c $(echo $ps1 | tr '\n' ' ')"
44+
kubectl delete -f $pkgdir/scripts/integration-test.yaml --ignore-not-found=true
45+
sed "s/windows_node/$windows_node/g" < <(cat $pkgdir/scripts/integration-test.yaml) | kubectl create -f -
46+
kubectl wait --for=condition=ready pod -l app=integration-test --timeout=600s
47+
kubectl exec pods/integration-test -- powershell -c $(echo $ps1 | tr '\n' ' ')
4448
}
49+

0 commit comments

Comments
 (0)