Repository navigation
Expand file tree
/
Copy pathcommon.sh
More file actions
executable file
·214 lines (182 loc) · 6.62 KB
/
Copy pathcommon.sh
File metadata and controls
executable file
·214 lines (182 loc) · 6.62 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#!/bin/bash
# Copyright 2025 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# The script expects the following env variables:
# OS: The operating system
# ARCH: The architecture
# DRIVER: the driver to use for the test
# CONTAINER_RUNTIME: the container runtime to use for the test
# EXTRA_START_ARGS: additional flags to pass into minikube start
# EXTRA_TEST_ARGS: additional flags to pass into go test
# JOB_NAME: the name of the logfile and check name to update on github
# PULL_NUMBER: the PR number, if applicable
function print_test_info() {
echo ">> Starting at $(date)"
echo ""
echo "user: $(whoami)"
echo "arch: ${OS_ARCH}"
echo "pr: ${PULL_NUMBER}"
echo "driver: ${DRIVER}"
echo "runtime: ${CONTAINER_RUNTIME}"
echo "job: ${JOB_NAME}"
echo "test home: ${TEST_HOME}"
echo "kernel: $(uname -v)"
echo "uptime: $(uptime)"
# Setting KUBECONFIG prevents the version check from erroring out due to permission issues
echo "kubectl: $(env KUBECONFIG=${TEST_HOME} kubectl version --client)"
echo "docker: $(docker version --format '{{ .Client.Version }}')"
echo "podman: $(sudo podman version --format '{{.Version}}' || true)"
echo "go: $(go version || true)"
case "${DRIVER}" in
kvm2)
echo "virsh: $(virsh --version)"
;;
virtualbox)
echo "vbox: $(vboxmanage --version)"
;;
vfkit)
echo "vfkit: $(vfkit --version)"
;;
krunkit)
echo "krunkit: $(krunkit --version)"
;;
esac
echo ""
}
function install_dependencies() {
# We need pstree for the restart cronjobs
if [ "$(uname)" != "Darwin" ]; then
sudo apt-get -y install lsof psmisc dnsutils
else
brew install pstree coreutils pidof
ln -s /usr/local/bin/gtimeout /usr/local/bin/timeout || true
fi
# do NOT change manually - only using make update-golang-version
GOLANG_VERSION_TO_INSTALL=1.25.5
# install golang if not present
sudo -E hack/prow/installer/check_install_golang.sh /usr/local $GOLANG_VERSION_TO_INSTALL || true
# install gotestsum if not present
GOROOT="/usr/local/go" hack/prow/installer/check_install_gotestsum.sh || true
# install gopogh
hack/prow/installer/check_install_gopogh.sh || true
# install jq
if ! type "jq" >/dev/null; then
echo ">> Installing jq"
if [ "${ARCH}" == "arm64" && "${OS}" == "linux" ]; then
sudo apt-get install jq -y
elif [ "${ARCH}" == "arm64" ]; then
echo "Unable to install 'jq' automatically for arm64 on Darwin, please install 'jq' manually."
exit 5
elif [ "${OS}" != "darwin" ]; then
curl -LO https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 && sudo install jq-linux64 /usr/local/bin/jq
else
curl -LO https://github.com/stedolan/jq/releases/download/jq-1.6/jq-osx-amd64 && sudo install jq-osx-amd64 /usr/local/bin/jq
fi
fi
}
function docker_setup() {
# clean all docker artifacts up
docker system prune -a --volumes -f || true
docker system df || true
docker rm -f -v $(docker ps -aq) >/dev/null 2>&1 || true
# read only token, never expires
#todo: do we need this token
# docker login -u minikubebot -p "$DOCKERHUB_READONLY_TOKEN"
}
function gvisor_image_build() {
# Build the gvisor image so that we can integration test changes to pkg/gvisor
chmod +x testdata/gvisor-addon
# skipping gvisor mac because ofg https://github.com/kubernetes/minikube/issues/5137
if [ "$(uname)" != "Darwin" ]; then
# Should match GVISOR_IMAGE_VERSION in Makefile
docker build -t gcr.io/k8s-minikube/gvisor-addon:2 -f testdata/gvisor-addon-Dockerfile ./testdata
fi
}
function run_gopogh() {
# todo: currently we do not save to gopogh db
echo "Not saving to DB"
gopogh -in "${JSON_OUT}" -out_html "${HTML_OUT}" -out_summary "${SUMMARY_OUT}" -name "${JOB_NAME}" -pr "${PULL_NUMBER}" -repo github.com/kubernetes/minikube/ -details "${COMMIT}:$(date +%Y-%m-%d)"
}
# this is where the script starts
readonly OS_ARCH="${OS}-${ARCH}"
readonly TEST_ROOT="${HOME}/minikube-integration"
readonly TEST_HOME="${TEST_ROOT}/${MINIKUBE_LOCATION}-$$"
export GOPATH="$HOME/go"
export KUBECONFIG="${TEST_HOME}/kubeconfig"
export PATH=$PATH:"/usr/local/bin/:/usr/local/go/bin/:$GOPATH/bin"
export MINIKUBE_SUPPRESS_DOCKER_PERFORMANCE=true
readonly TIMEOUT=120m
cp -r test/integration/testdata .
# Add the out/ directory to the PATH, for using new drivers.
export PATH="$(pwd)/out/":$PATH
mkdir -p "${TEST_ROOT}"
mkdir -p "${TEST_HOME}"
export MINIKUBE_HOME="${TEST_HOME}/.minikube"
export MINIKUBE_BIN="out/minikube-${OS_ARCH}"
export E2E_BIN="out/e2e-${OS_ARCH}"
install_dependencies
docker_setup
if [ "$CONTAINER_RUNTIME" == "containerd" ]; then
cp out/gvisor-addon testdata/
gvisor_image_build
fi
print_test_info
readonly TEST_OUT="${TEST_HOME}/testout.txt"
readonly JSON_OUT="${TEST_HOME}/test.json"
readonly JUNIT_OUT="${TEST_HOME}/junit-unit.xml"
readonly HTML_OUT="${TEST_HOME}/test.html"
readonly SUMMARY_OUT="${TEST_HOME}/test_summary.json"
touch "${TEST_OUT}"
touch "${JSON_OUT}"
touch "${JUNIT_OUT}"
touch "${HTML_OUT}"
touch "${SUMMARY_OUT}"
e2e_start_time="$(date -u +%s)"
echo ""
echo ">> Starting ${E2E_BIN} at $(date)"
set -x
EXTRA_START_ARGS="${EXTRA_START_ARGS} --container-runtime=${CONTAINER_RUNTIME}"
echo $PATH
gotestsum --jsonfile "${JSON_OUT}" --junitfile="${JUNIT_OUT}" -f standard-verbose --raw-command -- \
go tool test2json -t \
${E2E_BIN} \
-minikube-start-args="--driver=${DRIVER} ${EXTRA_START_ARGS}" \
-test.timeout=${TIMEOUT} -test.v \
${EXTRA_TEST_ARGS} \
-binary="${MINIKUBE_BIN}" 2>&1 |
tee "${TEST_OUT}"
result=${PIPESTATUS[0]} # capture the exit code of the first cmd in pipe.
set +x
echo ">> ${E2E_BIN} exited with ${result} at $(date)"
echo ""
# calculate the time took to finish running e2e binary test.
e2e_end_time="$(date -u +%s)"
elapsed=$(($e2e_end_time - $e2e_start_time))
min=$(($elapsed / 60))
sec=$(tail -c 3 <<<$((${elapsed}00 / 60)))
elapsed=$min.$sec
#todo: currently we skip gopogh upload , we shall add it back
run_gopogh
# according to prow's requirement, upload the test report to $ARTIFACTS
cp ${TEST_OUT} .
cp ${JSON_OUT} .
cp ${JUNIT_OUT} .
cp ${HTML_OUT} .
cp ${SUMMARY_OUT} .
if [[ $result -eq 0 ]]; then
echo "minikube: SUCCESS"
else
echo "minikube: FAIL"
fi
exit "$result"