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

test: migrate tests to HostProcess pods #274

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 27 additions & 0 deletions scripts/integration-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: v1
kind: Pod
metadata:
name: integration-test
labels:
app: integration-test
spec:
nodeName: windows_node # to be replaced by sed
securityContext:
windowsOptions:
hostProcess: true
runAsUserName: "NT AUTHORITY\\SYSTEM"
mauriciopoppe marked this conversation as resolved.
Show resolved Hide resolved
hostNetwork: true
containers:
- name: agnhost
image: mcr.microsoft.com/windows/nanoserver:ltsc2019
command: ['powershell', '-command', 'Start-Sleep 100000']
volumeMounts:
- mountPath: /integration-test
name: integration-test-volume
nodeSelector:
kubernetes.io/os: windows
volumes:
- name: integration-test-volume
hostPath:
path: /
type: DirectoryOrCreate
19 changes: 12 additions & 7 deletions scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if ! [ -z "${GCP_ZONE:-}" ]; then
fi

sync_file_to_vm() {
gcloud compute scp $@ $windows_node:"C:\\Users\\${current_account}"
gcloud compute scp $@ $windows_node:"C:\\"
}

compile_csi_proxy_integration_tests() {
Expand All @@ -25,6 +25,10 @@ compile_csi_proxy_integration_tests() {
}

sync_csi_proxy_integration_tests() {
# delete the pod that is potentially using the old file
# if there is a pod accessing the existing file, this command would hang
kubectl delete -f $pkgdir/scripts/integration-test.yaml --ignore-not-found=true

echo "Sync the integrationtests.exe binary"
local integration_bin_path="$pkgdir/bin/integrationtests.test.exe"
sync_file_to_vm $integration_bin_path
Expand All @@ -33,12 +37,13 @@ sync_csi_proxy_integration_tests() {
run_csi_proxy_integration_tests() {
echo "Run integration tests"
local ps1=$(cat << 'EOF'
"& {
$ErrorActionPreference = \"Stop\";
.\integrationtests.test.exe --test.v
}"
$ErrorActionPreference = "Stop";
mauriciopoppe marked this conversation as resolved.
Show resolved Hide resolved
.$Env:CONTAINER_SANDBOX_MOUNT_POINT\integration-test\integrationtests.test.exe --test.v
EOF
);

gcloud compute ssh $windows_node --command="powershell -c $(echo $ps1 | tr '\n' ' ')"
kubectl delete -f $pkgdir/scripts/integration-test.yaml --ignore-not-found=true
sed "s/windows_node/$windows_node/g" < <(cat $pkgdir/scripts/integration-test.yaml) | kubectl create -f -
kubectl wait --for=condition=ready pod -l app=integration-test --timeout=600s
kubectl exec pods/integration-test -- powershell -c $(echo $ps1 | tr '\n' ' ')
}