generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 62
/
utils.sh
70 lines (57 loc) · 2.21 KB
/
utils.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# Importing this library shouldn't have side effects
pkgdir=${GOPATH}/src/github.com/kubernetes-csi/csi-proxy
# current_account is the current user
# in CI, the value is `prow`
current_account=$USER
# windows_node is the id of the GCE Windows instance
windows_node=$(kubectl get nodes -l kubernetes.io/os=windows -o jsonpath='{.items[*].metadata.name}')
# set the default zone for the gcloud sdk
if ! [ -z "${GCP_ZONE:-}" ]; then
export CLOUDSDK_COMPUTE_ZONE="$GCP_ZONE"
fi
sync_file_to_vm() {
gcloud compute scp $@ $windows_node:"C:\\Users\\${current_account}"
}
compile_csi_proxy() {
echo "Compiling CSI Proxy"
make -C $pkgdir build
}
compile_csi_proxy_integration_tests() {
echo "Compiling CSI Proxy integration tests"
GOOS=windows GOARCH=amd64 go test -c $pkgdir/integrationtests -o $pkgdir/bin/integrationtests.test.exe
}
sync_csi_proxy() {
echo "Sync the csi-proxy.exe binary"
local csi_proxy_bin_path="$pkgdir/bin/csi-proxy.exe"
sync_file_to_vm $csi_proxy_bin_path
}
sync_csi_proxy_integration_tests() {
echo "Sync the integrationtests.exe binary"
local integration_bin_path="$pkgdir/bin/integrationtests.test.exe"
sync_file_to_vm $integration_bin_path
}
sync_powershell_utils() {
local utils_psm1="$pkgdir/scripts/utils.psm1"
sync_file_to_vm $utils_psm1
}
restart_csi_proxy() {
echo "Restart csi-proxy service"
gcloud compute ssh $windows_node --command='powershell -c "& { $ErrorActionPreference = \"Stop\"; Import-Module (Resolve-Path(\"utils.psm1\")); Restart-CSIProxy; }"'
}
run_csi_proxy_integration_tests() {
echo "Run integration tests"
local ps1=$(cat << 'EOF'
"& {
$ErrorActionPreference = \"Stop\";
Import-Module (Resolve-Path(\"utils.psm1\"));
Run-CSIProxyIntegrationTests -test_args \"--test.v --test.run TestAPIGroups\";
Run-CSIProxyIntegrationTests -test_args \"--test.v --test.run TestFilesystemAPIGroup\";
Run-CSIProxyIntegrationTests -test_args \"--test.v --test.run TestDiskAPIGroup\";
Run-CSIProxyIntegrationTests -test_args \"--test.v --test.run TestVolumeAPIs\";
Run-CSIProxyIntegrationTests -test_args \"--test.v --test.run TestSmbAPIGroup\";
}"
EOF
);
gcloud compute ssh $windows_node --command="powershell -c $(echo $ps1 | tr '\n' ' ')"
}