Skip to content

Commit d563d80

Browse files
[CI] add minikubekvm integration test in prow
1 parent 5ca02f9 commit d563d80

24 files changed

+2008
-1
lines changed

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,3 +1126,9 @@ get-dependency-version:
11261126
.PHONY: _update-all
11271127
_update-all:
11281128
@(cd hack && go run update/update_all/update_all.go)
1129+
1130+
1131+
1132+
# targets for tests on prow
1133+
include ./hack/prow/prow.mk
1134+

hack/prow/common.sh

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
#!/bin/bash
2+
3+
# Copyright 2025 The Kubernetes Authors All rights reserved.
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+
# The script expects the following env variables:
18+
# OS: The operating system
19+
# ARCH: The architecture
20+
# DRIVER: the driver to use for the test
21+
# CONTAINER_RUNTIME: the container runtime to use for the test
22+
# EXTRA_START_ARGS: additional flags to pass into minikube start
23+
# EXTRA_TEST_ARGS: additional flags to pass into go test
24+
# JOB_NAME: the name of the logfile and check name to update on github
25+
26+
function print_test_info() {
27+
echo ">> Starting at $(date)"
28+
echo ""
29+
echo "user: $(whoami)"
30+
echo "arch: ${OS_ARCH}"
31+
echo "build: ${MINIKUBE_LOCATION}"
32+
echo "driver: ${DRIVER}"
33+
echo "runtime: ${CONTAINER_RUNTIME}"
34+
echo "job: ${JOB_NAME}"
35+
echo "test home: ${TEST_HOME}"
36+
echo "kernel: $(uname -v)"
37+
echo "uptime: $(uptime)"
38+
# Setting KUBECONFIG prevents the version check from erroring out due to permission issues
39+
echo "kubectl: $(env KUBECONFIG=${TEST_HOME} kubectl version --client)"
40+
echo "docker: $(docker version --format '{{ .Client.Version }}')"
41+
echo "podman: $(sudo podman version --format '{{.Version}}' || true)"
42+
echo "go: $(go version || true)"
43+
44+
case "${DRIVER}" in
45+
kvm2)
46+
echo "virsh: $(virsh --version)"
47+
;;
48+
virtualbox)
49+
echo "vbox: $(vboxmanage --version)"
50+
;;
51+
vfkit)
52+
echo "vfkit: $(vfkit --version)"
53+
;;
54+
krunkit)
55+
echo "krunkit: $(krunkit --version)"
56+
;;
57+
esac
58+
59+
echo ""
60+
}
61+
62+
function install_dependencies() {
63+
# We need pstree for the restart cronjobs
64+
if [ "$(uname)" != "Darwin" ]; then
65+
sudo apt-get -y install lsof psmisc dnsutils
66+
else
67+
brew install pstree coreutils pidof
68+
ln -s /usr/local/bin/gtimeout /usr/local/bin/timeout || true
69+
fi
70+
# install golang if not present
71+
sudo hack/prow/installer/check_install_golang.sh /usr/local 1.24.5 || true
72+
# install gotestsum if not present
73+
GOROOT="/usr/local/go" hack/prow/installer/check_install_gotestsum.sh || true
74+
# install gopogh
75+
hack/prow/installer/check_install_gopogh.sh || true
76+
77+
# install jq
78+
if ! type "jq" >/dev/null; then
79+
echo ">> Installing jq"
80+
if [ "${ARCH}" == "arm64" && "${OS}" == "linux" ]; then
81+
sudo apt-get install jq -y
82+
elif [ "${ARCH}" == "arm64" ]; then
83+
echo "Unable to install 'jq' automatically for arm64 on Darwin, please install 'jq' manually."
84+
exit 5
85+
elif [ "${OS}" != "darwin" ]; then
86+
curl -LO https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 && sudo install jq-linux64 /usr/local/bin/jq
87+
else
88+
curl -LO https://github.com/stedolan/jq/releases/download/jq-1.6/jq-osx-amd64 && sudo install jq-osx-amd64 /usr/local/bin/jq
89+
fi
90+
fi
91+
92+
}
93+
94+
function docker_setup() {
95+
96+
# clean all docker artifacts up
97+
docker system prune -a --volumes -f || true
98+
docker system df || true
99+
docker rm -f -v $(docker ps -aq) >/dev/null 2>&1 || true
100+
101+
# read only token, never expires
102+
#todo: do we need this token
103+
# docker login -u minikubebot -p "$DOCKERHUB_READONLY_TOKEN"
104+
}
105+
106+
function gvisor_image_build() {
107+
# Build the gvisor image so that we can integration test changes to pkg/gvisor
108+
chmod +x testdata/gvisor-addon
109+
# skipping gvisor mac because ofg https://github.com/kubernetes/minikube/issues/5137
110+
if [ "$(uname)" != "Darwin" ]; then
111+
# Should match GVISOR_IMAGE_VERSION in Makefile
112+
docker build -t gcr.io/k8s-minikube/gvisor-addon:2 -f testdata/gvisor-addon-Dockerfile ./testdata
113+
fi
114+
}
115+
116+
function run_gopogh() {
117+
# todo: currently we do not save to gopogh db
118+
echo "Not saving to DB"
119+
gopogh -in "${JSON_OUT}" -out_html "${HTML_OUT}" -out_summary "${SUMMARY_OUT}" -name "${JOB_NAME}" -pr "${MINIKUBE_LOCATION}" -repo github.com/kubernetes/minikube/ -details "${COMMIT}:$(date +%Y-%m-%d)"
120+
121+
}
122+
123+
# this is where the script starts
124+
readonly OS_ARCH="${OS}-${ARCH}"
125+
readonly TEST_ROOT="${HOME}/minikube-integration"
126+
readonly TEST_HOME="${TEST_ROOT}/${MINIKUBE_LOCATION}-$$"
127+
128+
export GOPATH="$HOME/go"
129+
export KUBECONFIG="${TEST_HOME}/kubeconfig"
130+
export PATH=$PATH:"/usr/local/bin/:/usr/local/go/bin/:$GOPATH/bin"
131+
export MINIKUBE_SUPPRESS_DOCKER_PERFORMANCE=true
132+
133+
readonly TIMEOUT=120m
134+
135+
cp -r test/integration/testdata .
136+
cp out/gvisor-addon testdata/
137+
ls testdata
138+
139+
# Add the out/ directory to the PATH, for using new drivers.
140+
export PATH="$(pwd)/out/":$PATH
141+
mkdir -p "${TEST_ROOT}"
142+
mkdir -p "${TEST_HOME}"
143+
export MINIKUBE_HOME="${TEST_HOME}/.minikube"
144+
export MINIKUBE_BIN="out/minikube-${OS_ARCH}"
145+
export E2E_BIN="out/e2e-${OS_ARCH}"
146+
147+
install_dependencies
148+
docker_setup
149+
print_test_info
150+
gvisor_image_build
151+
152+
readonly TEST_OUT="${TEST_HOME}/testout.txt"
153+
readonly JSON_OUT="${TEST_HOME}/test.json"
154+
readonly JUNIT_OUT="${TEST_HOME}/junit-unit.xml"
155+
readonly HTML_OUT="${TEST_HOME}/test.html"
156+
readonly SUMMARY_OUT="${TEST_HOME}/test_summary.json"
157+
158+
touch "${TEST_OUT}"
159+
touch "${JSON_OUT}"
160+
touch "${JUNIT_OUT}"
161+
touch "${HTML_OUT}"
162+
touch "${SUMMARY_OUT}"
163+
164+
e2e_start_time="$(date -u +%s)"
165+
echo ""
166+
echo ">> Starting ${E2E_BIN} at $(date)"
167+
set -x
168+
169+
EXTRA_START_ARGS="${EXTRA_START_ARGS} --container-runtime=${CONTAINER_RUNTIME}"
170+
echo $PATH
171+
gotestsum --jsonfile "${JSON_OUT}" --junitfile="${JUNIT_OUT}" -f standard-verbose --raw-command -- \
172+
go tool test2json -t \
173+
${E2E_BIN} \
174+
-minikube-start-args="--driver=${DRIVER} ${EXTRA_START_ARGS}" \
175+
-test.timeout=${TIMEOUT} -test.v \
176+
${EXTRA_TEST_ARGS} \
177+
-binary="${MINIKUBE_BIN}" 2>&1 |
178+
tee "${TEST_OUT}"
179+
180+
result=${PIPESTATUS[0]} # capture the exit code of the first cmd in pipe.
181+
set +x
182+
echo ">> ${E2E_BIN} exited with ${result} at $(date)"
183+
echo ""
184+
185+
# calculate the time took to finish running e2e binary test.
186+
e2e_end_time="$(date -u +%s)"
187+
elapsed=$(($e2e_end_time - $e2e_start_time))
188+
min=$(($elapsed / 60))
189+
sec=$(tail -c 3 <<<$((${elapsed}00 / 60)))
190+
elapsed=$min.$sec
191+
192+
#todo: currently we skip gopogh upload , we shall add it back
193+
run_gopogh
194+
195+
# according to prow's requirement, upload the test report to $ARTIFACTS
196+
cp ${TEST_OUT} .
197+
cp ${JSON_OUT} .
198+
cp ${JUNIT_OUT} .
199+
cp ${HTML_OUT} .
200+
cp ${SUMMARY_OUT} .
201+
if [[ $result -eq 0 ]]; then
202+
echo "minikube: SUCCESS"
203+
else
204+
echo "minikube: FAIL"
205+
fi
206+
207+
exit "$result"

hack/prow/docker.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"Image": "debian"
3+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
# Copyright 2016 The Kubernetes Authors All rights reserved.
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 -eux -o pipefail
18+
19+
ARCH=${ARCH:=amd64}
20+
21+
22+
echo "Installing latest docker"
23+
curl -fsSL https://get.docker.com -o get-docker.sh
24+
sudo sh get-docker.sh
25+
rm get-docker.sh
26+
27+
sudo usermod -aG docker minitest || true
28+
29+
echo "Installing latest kubectl"
30+
curl -LO "https://dl.k8s.io/release/$(curl -sL https://dl.k8s.io/release/stable.txt)/bin/linux/${ARCH}/kubectl"
31+
sudo install ./kubectl /usr/local/bin/kubectl
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#!/bin/bash
2+
3+
# Copyright 2025 The Kubernetes Authors All rights reserved.
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+
# This script requires two parameters:
18+
# $1. INSTALL_PATH: The path to install the golang binary
19+
# $2. GO_VERSION: The version of golang to install
20+
21+
22+
23+
set -eux -o pipefail
24+
25+
if (($# < 2)); then
26+
echo "ERROR: given ! ($#) parameters but expected 2."
27+
echo "USAGE: ./check_install_golang.sh INSTALL_PATH GO_VERSION"
28+
exit 1
29+
fi
30+
31+
VERSION_TO_INSTALL=${2}
32+
INSTALL_PATH=${1}
33+
34+
function current_arch() {
35+
case $(arch) in
36+
"x86_64" | "i386")
37+
echo "amd64"
38+
;;
39+
"aarch64" | "arm64")
40+
echo "arm64"
41+
;;
42+
*)
43+
echo "unexpected arch: $(arch). use amd64" 1>&2
44+
echo "amd64"
45+
;;
46+
esac
47+
}
48+
49+
ARCH=${ARCH:=$(current_arch)}
50+
51+
# installs or updates golang if right version doesn't exists
52+
function check_and_install_golang() {
53+
if ! go version &>/dev/null; then
54+
echo "WARNING: No golang installation found in your environment."
55+
install_golang "$VERSION_TO_INSTALL" "$INSTALL_PATH"
56+
return
57+
fi
58+
59+
sudo chown -R $USER:$USER "$INSTALL_PATH"/go
60+
61+
# golang has been installed and check its version
62+
if [[ $(go version | cut -d' ' -f 3) =~ go(([0-9]+)\.([0-9]+).([0-9]+)*) ]]; then
63+
HOST_VERSION=${BASH_REMATCH[1]}
64+
if [ $HOST_VERSION == $VERSION_TO_INSTALL ]; then
65+
echo "go version on the host looks good : $HOST_VERSION"
66+
else
67+
echo "WARNING: expected go version to be $VERSION_TO_INSTALL but got $HOST_VERSION"
68+
install_golang "$VERSION_TO_INSTALL" "$INSTALL_PATH"
69+
fi
70+
else
71+
echo "ERROR: Failed to parse golang version: $(go version)"
72+
return
73+
fi
74+
}
75+
76+
# install_golang takes two parameters version and path to install.
77+
function install_golang() {
78+
local -r GO_VER="$1"
79+
local -r GO_DIR="$2/go"
80+
echo "Installing golang version: $GO_VER in $GO_DIR"
81+
82+
INSTALLOS=linux
83+
if [[ "$OSTYPE" == "darwin"* ]]; then
84+
INSTALLOS=darwin
85+
fi
86+
87+
local -r GO_TGZ="go${GO_VER}.${INSTALLOS}-${ARCH}.tar.gz"
88+
pushd /tmp
89+
90+
# using sudo because previously installed versions might have been installed by a different user.
91+
sudo rm -rf "$GO_TGZ"
92+
curl -qL -O "https://storage.googleapis.com/golang/$GO_TGZ"
93+
sudo rm -rf "$GO_DIR"
94+
sudo mkdir -p "$GO_DIR"
95+
sudo tar -C "$GO_DIR" --strip-components=1 -xzf "$GO_TGZ"
96+
97+
popd >/dev/null
98+
echo "installed in $GO_DIR: $($GO_DIR/bin/go version)"
99+
}
100+
101+
check_and_install_golang
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
# Copyright 2025 The Kubernetes Authors All rights reserved.
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+
# this script requires golang to be installed
18+
19+
set -eux -o pipefail
20+
21+
go install github.com/medyagh/gopogh/cmd/gopogh@v0.29.0

0 commit comments

Comments
 (0)