2016-11-23 20:23:50 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Copyright 2016 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.
|
|
|
|
|
|
|
|
|
|
|
|
# This script downloads the test files from the build bucket and makes some executable.
|
|
|
|
|
2016-12-24 04:11:05 +00:00
|
|
|
# The script expects the following env variables:
|
2016-11-23 20:23:50 +00:00
|
|
|
# OS_ARCH: The operating system and the architecture separated by a hyphen '-' (e.g. darwin-amd64, linux-amd64, windows-amd64)
|
2017-01-09 23:17:17 +00:00
|
|
|
# VM_DRIVER: the vm-driver to use for the test
|
2018-11-29 23:43:40 +00:00
|
|
|
# EXTRA_START_ARGS: additional flags to pass into minikube start
|
|
|
|
# EXTRA_ARGS: additional flags to pass into minikube
|
2017-01-09 23:17:17 +00:00
|
|
|
# JOB_NAME: the name of the logfile and check name to update on github
|
2018-11-29 23:43:40 +00:00
|
|
|
#
|
|
|
|
|
2016-11-23 20:23:50 +00:00
|
|
|
|
2018-11-29 23:43:40 +00:00
|
|
|
readonly TEST_ROOT="${HOME}/minikube-integration"
|
|
|
|
readonly TEST_HOME="${TEST_ROOT}/${OS_ARCH}-${VM_DRIVER}-${MINIKUBE_LOCATION}-$$-${COMMIT}"
|
|
|
|
echo ">> Starting at $(date)"
|
|
|
|
echo ""
|
|
|
|
echo "arch: ${OS_ARCH}"
|
|
|
|
echo "build: ${MINIKUBE_LOCATION}"
|
|
|
|
echo "driver: ${VM_DRIVER}"
|
|
|
|
echo "job: ${JOB_NAME}"
|
|
|
|
echo "test home: ${TEST_HOME}"
|
|
|
|
echo "sudo: ${SUDO_PREFIX}"
|
|
|
|
echo "kernel: $(uname -v)"
|
|
|
|
# Setting KUBECONFIG prevents the version ceck from erroring out due to permission issues
|
|
|
|
echo "kubectl: $(env KUBECONFIG=${TEST_HOME} kubectl version --client --short=true)"
|
|
|
|
echo "docker: $(docker version --format '{{ .Client.Version }}')"
|
|
|
|
|
|
|
|
case "${VM_DRIVER}" in
|
|
|
|
kvm2)
|
|
|
|
echo "virsh: $(virsh --version)"
|
|
|
|
;;
|
|
|
|
virtualbox)
|
|
|
|
echo "vbox: $(vboxmanage --version)"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
mkdir -p out/ testdata/ "${TEST_HOME}"
|
2018-09-26 22:37:17 +00:00
|
|
|
|
|
|
|
# Install gsutil if necessary.
|
2018-11-29 23:43:40 +00:00
|
|
|
if ! type -P gsutil >/dev/null; then
|
2018-09-26 22:37:17 +00:00
|
|
|
if [[ ! -x "out/gsutil/gsutil" ]]; then
|
|
|
|
echo "Installing gsutil to $(pwd)/out ..."
|
|
|
|
curl -s https://storage.googleapis.com/pub/gsutil.tar.gz | tar -C out/ -zxf -
|
|
|
|
fi
|
2018-11-29 23:43:40 +00:00
|
|
|
PATH="$(pwd)/out/gsutil:$PATH"
|
2018-09-26 22:37:17 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Add the out/ directory to the PATH, for using new drivers.
|
2018-11-29 23:43:40 +00:00
|
|
|
PATH="$(pwd)/out/":$PATH
|
|
|
|
export PATH
|
2016-11-23 20:23:50 +00:00
|
|
|
|
2018-11-29 23:43:40 +00:00
|
|
|
echo ""
|
|
|
|
echo ">> Downloading test inputs from ${MINIKUBE_LOCATION} ..."
|
|
|
|
gsutil -qm cp \
|
|
|
|
"gs://minikube-builds/${MINIKUBE_LOCATION}/minikube-${OS_ARCH}" \
|
|
|
|
"gs://minikube-builds/${MINIKUBE_LOCATION}/docker-machine-driver"-* \
|
|
|
|
"gs://minikube-builds/${MINIKUBE_LOCATION}/e2e-${OS_ARCH}" out
|
2018-01-10 18:51:19 +00:00
|
|
|
|
2018-11-29 23:43:40 +00:00
|
|
|
gsutil -qm cp "gs://minikube-builds/${MINIKUBE_LOCATION}/testdata"/* testdata/
|
2018-01-10 18:51:19 +00:00
|
|
|
|
2018-11-29 23:43:40 +00:00
|
|
|
# Set the executable bit on the e2e binary and out binary
|
|
|
|
export MINIKUBE_BIN="out/minikube-${OS_ARCH}"
|
|
|
|
export E2E_BIN="out/e2e-${OS_ARCH}"
|
|
|
|
chmod +x "${MINIKUBE_BIN}" "${E2E_BIN}" out/docker-machine-driver-*
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo ">> Cleaning up after previous test runs ..."
|
|
|
|
|
|
|
|
# Cleanup stale test outputs.
|
|
|
|
pgrep minikube && echo "WARNING: other instances of minikube may be running"
|
|
|
|
|
|
|
|
for stale_dir in "${TEST_ROOT}"/*; do
|
|
|
|
echo "* Cleaning stale test: ${stale_dir}"
|
|
|
|
export MINIKUBE_HOME="${stale_dir}/.minikube"
|
|
|
|
export KUBECONFIG="${stale_dir}/kubeconfig"
|
|
|
|
|
|
|
|
if [[ -d "${MINIKUBE_HOME}" ]]; then
|
|
|
|
echo "Shutting down stale minikube instance ..."
|
|
|
|
if [[ -w "${MINIKUBE_HOME}" ]]; then
|
|
|
|
"${MINIKUBE_BIN}" delete || true
|
|
|
|
rm -Rf "${MINIKUBE_HOME}"
|
|
|
|
else
|
|
|
|
sudo -E "${MINIKUBE_BIN}" delete || true
|
|
|
|
sudo rm -Rf "${MINIKUBE_HOME}"
|
|
|
|
fi
|
|
|
|
fi
|
2017-08-20 17:53:01 +00:00
|
|
|
|
2018-11-29 23:43:40 +00:00
|
|
|
if [[ -f "${KUBECONFIG}" ]]; then
|
|
|
|
if [[ -w "${KUBECONFIG}" ]]; then
|
|
|
|
rm -f "${KUBECONFIG}"
|
|
|
|
else
|
|
|
|
sudo rm -f "${KUBECONFIG}" || true
|
|
|
|
fi
|
|
|
|
fi
|
2017-08-15 04:02:55 +00:00
|
|
|
|
2018-11-29 23:43:40 +00:00
|
|
|
rmdir "${stale_dir}" || true
|
|
|
|
done
|
2017-06-09 21:34:19 +00:00
|
|
|
|
2018-11-29 23:43:40 +00:00
|
|
|
if type -P virsh; then
|
|
|
|
virsh -c qemu:///system list --all
|
|
|
|
virsh -c qemu:///system list --all \
|
|
|
|
| grep minikube \
|
|
|
|
| awk '{ print $2 }' \
|
2018-11-30 05:44:20 +00:00
|
|
|
| xargs -I {} sh -c "virsh -c qemu:///system destroy {}; virsh -c qemu:///system undefine {}" \
|
|
|
|
|| true
|
2018-11-29 23:43:40 +00:00
|
|
|
fi
|
2017-06-09 21:34:19 +00:00
|
|
|
|
2018-11-29 23:43:40 +00:00
|
|
|
if type -P vboxmanage; then
|
2018-11-30 05:44:20 +00:00
|
|
|
vboxmanage list vms || true
|
2018-11-29 23:43:40 +00:00
|
|
|
vboxmanage list vms \
|
2018-11-30 05:44:20 +00:00
|
|
|
| grep minikube \
|
2018-11-29 23:43:40 +00:00
|
|
|
| cut -d'"' -f2 \
|
|
|
|
| xargs -I {} sh -c "vboxmanage startvm {} --type emergencystop; vboxmanage unregistervm {} --delete" \
|
|
|
|
|| true
|
|
|
|
fi
|
|
|
|
|
|
|
|
if type -P hdiutil; then
|
2018-11-30 05:44:20 +00:00
|
|
|
hdiutil info | grep -E "/dev/disk[1-9][^s]" || true
|
2018-11-29 23:43:40 +00:00
|
|
|
hdiutil info \
|
|
|
|
| grep -E "/dev/disk[1-9][^s]" \
|
2017-08-28 17:43:32 +00:00
|
|
|
| awk '{print $1}' \
|
2017-06-09 21:34:19 +00:00
|
|
|
| xargs -I {} sh -c "hdiutil detach {}" \
|
|
|
|
|| true
|
2018-11-29 23:43:40 +00:00
|
|
|
fi
|
2017-06-09 21:34:19 +00:00
|
|
|
|
2018-11-29 23:43:40 +00:00
|
|
|
if [[ "${OS_ARCH}" == "Darwin" ]]; then
|
|
|
|
pgrep xhyve | xargs kill || true
|
|
|
|
if [[ -e out/docker-machine-driver-hyperkit ]]; then
|
|
|
|
sudo chown root:wheel out/docker-machine-driver-hyperkit || true
|
|
|
|
sudo chmod u+s out/docker-machine-driver-hyperkit || true
|
|
|
|
fi
|
|
|
|
fi
|
2017-08-15 04:02:55 +00:00
|
|
|
|
2018-11-29 23:43:40 +00:00
|
|
|
if pgrep kubectl; then
|
2018-11-30 00:22:07 +00:00
|
|
|
echo "killing hung kubectl processes ..."
|
2018-11-30 05:44:20 +00:00
|
|
|
pgrep kubectl | xargs kill || true
|
2017-08-15 04:02:55 +00:00
|
|
|
fi
|
2017-01-09 23:17:17 +00:00
|
|
|
|
2018-11-29 23:43:40 +00:00
|
|
|
# Respected by minikube
|
|
|
|
export MINIKUBE_HOME="${TEST_HOME}/.minikube"
|
|
|
|
export MINIKUBE_WANTREPORTERRORPROMPT=False
|
|
|
|
|
|
|
|
# Respected by kubectl
|
|
|
|
export KUBECONFIG="${TEST_HOME}/kubeconfig"
|
2017-02-10 22:43:54 +00:00
|
|
|
|
2018-11-29 23:43:40 +00:00
|
|
|
# Display the default image URL
|
|
|
|
echo ""
|
|
|
|
echo ">> ISO URL"
|
2018-11-30 05:44:20 +00:00
|
|
|
"${MINIKUBE_BIN}" start -h | grep iso-url || true
|
2017-08-16 18:17:25 +00:00
|
|
|
|
2018-11-29 23:43:40 +00:00
|
|
|
echo ""
|
|
|
|
echo ">> Starting ${E2E_BIN} at $(date)"
|
|
|
|
${SUDO_PREFIX}${E2E_BIN} \
|
2018-09-26 22:37:17 +00:00
|
|
|
-minikube-start-args="--vm-driver=${VM_DRIVER} ${EXTRA_START_ARGS}" \
|
|
|
|
-minikube-args="--v=10 --logtostderr ${EXTRA_ARGS}" \
|
2018-11-29 23:43:40 +00:00
|
|
|
-test.v -test.timeout=30m -binary="${MINIKUBE_BIN}" && result=$? || result=$?
|
|
|
|
echo ">> ${E2E_BIN} exited with ${result} at $(date)"
|
|
|
|
echo ""
|
2017-05-15 18:19:11 +00:00
|
|
|
|
2017-01-09 23:17:17 +00:00
|
|
|
if [[ $result -eq 0 ]]; then
|
|
|
|
status="success"
|
2018-11-29 23:43:40 +00:00
|
|
|
echo "minikube: SUCCESS"
|
2017-01-09 23:17:17 +00:00
|
|
|
else
|
|
|
|
status="failure"
|
2018-11-29 23:43:40 +00:00
|
|
|
echo "minikube: FAIL"
|
2017-07-21 23:09:32 +00:00
|
|
|
source print-debug-info.sh
|
2017-01-09 23:17:17 +00:00
|
|
|
fi
|
|
|
|
|
2018-11-29 23:43:40 +00:00
|
|
|
echo ">> Cleaning up after ourselves ..."
|
|
|
|
${SUDO_PREFIX}${MINIKUBE_BIN} delete >/dev/null 2>/dev/null || true
|
2018-11-30 05:44:20 +00:00
|
|
|
|
|
|
|
${SUDO_PREFIX} rm -Rf "${MINIKUBE_HOME}" || true
|
|
|
|
${SUDO_PREFIX} rm -f "${KUBECONFIG}" || true
|
2018-11-29 23:43:40 +00:00
|
|
|
rmdir "${TEST_HOME}"
|
|
|
|
echo ">> ${TEST_HOME} completed at $(date)"
|
|
|
|
|
2018-11-29 23:50:45 +00:00
|
|
|
if [[ "${MINIKUBE_LOCATION}" != "master" ]]; then
|
2018-11-29 23:50:29 +00:00
|
|
|
readonly target_url="https://storage.googleapis.com/minikube-builds/logs/${MINIKUBE_LOCATION}/${JOB_NAME}.txt"
|
2018-11-30 00:22:07 +00:00
|
|
|
curl -s "https://api.github.com/repos/kubernetes/minikube/statuses/${COMMIT}?access_token=$access_token" \
|
2017-01-09 23:17:17 +00:00
|
|
|
-H "Content-Type: application/json" \
|
|
|
|
-X POST \
|
|
|
|
-d "{\"state\": \"$status\", \"description\": \"Jenkins\", \"target_url\": \"$target_url\", \"context\": \"${JOB_NAME}\"}"
|
2018-11-29 23:50:29 +00:00
|
|
|
fi
|
2018-11-29 23:51:41 +00:00
|
|
|
exit $result
|