2015-01-12 21:46:10 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2015-05-01 16:19:44 +00:00
|
|
|
# Copyright 2015 The Kubernetes Authors All rights reserved.
|
2015-01-12 21:46:10 +00:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
|
|
|
# kubernetes-e2e-{gce, gke, gke-ci} jobs: This script is triggered by
|
|
|
|
# the kubernetes-build job, or runs every half hour. We abort this job
|
|
|
|
# if it takes more than 75m. As of initial commit, it typically runs
|
|
|
|
# in about half an hour.
|
|
|
|
#
|
|
|
|
# The "Workspace Cleanup Plugin" is installed and in use for this job,
|
|
|
|
# so the ${WORKSPACE} directory (the current directory) is currently
|
|
|
|
# empty.
|
|
|
|
|
|
|
|
set -o errexit
|
|
|
|
set -o nounset
|
|
|
|
set -o pipefail
|
|
|
|
set -o xtrace
|
|
|
|
|
2015-02-11 17:45:27 +00:00
|
|
|
if [[ "${CIRCLECI:-}" == "true" ]]; then
|
|
|
|
JOB_NAME="circleci-${CIRCLE_PROJECT_USERNAME}-${CIRCLE_PROJECT_REPONAME}"
|
|
|
|
BUILD_NUMBER=${CIRCLE_BUILD_NUM}
|
|
|
|
WORKSPACE=`pwd`
|
|
|
|
else
|
|
|
|
# Jenkins?
|
2015-05-08 20:40:47 +00:00
|
|
|
# Copy GCE keys so we don't keep cycling them.
|
|
|
|
# To set this up, you must know the <project>, <zone>, and <instance> that
|
|
|
|
# on which your jenkins jobs are running. Then do:
|
|
|
|
#
|
|
|
|
# # Get into the instance.
|
|
|
|
# $ gcloud compute ssh --project="<prj>" ssh --zone="<zone>" <instance>
|
|
|
|
#
|
|
|
|
# # Generate a key by ssh'ing into itself, then exit.
|
|
|
|
# $ gcloud compute ssh --project="<prj>" ssh --zone="<zone>" <instance>
|
|
|
|
# $ ^D
|
|
|
|
#
|
|
|
|
# # Copy the keys to the desired location, e.g. /var/lib/jenkins/gce_keys/
|
|
|
|
# $ sudo mkdir -p /var/lib/jenkins/gce_keys/
|
|
|
|
# $ sudo cp ~/.ssh/google_compute_engine /var/lib/jenkins/gce_keys/
|
|
|
|
# $ sudo cp ~/.ssh/google_compute_engine.pub /var/lib/jenkins/gce_keys/
|
|
|
|
#
|
|
|
|
# Move the permissions to jenkins.
|
|
|
|
# $ sudo chown -R jenkins /var/lib/jenkins/gce_keys/
|
|
|
|
# $ sudo chgrp -R jenkins /var/lib/jenkins/gce_keys/
|
|
|
|
mkdir -p ${WORKSPACE}/.ssh/
|
|
|
|
cp /var/lib/jenkins/gce_keys/google_compute_engine ${WORKSPACE}/.ssh/
|
|
|
|
cp /var/lib/jenkins/gce_keys/google_compute_engine.pub ${WORKSPACE}/.ssh/
|
|
|
|
|
2015-02-11 17:45:27 +00:00
|
|
|
export HOME=${WORKSPACE} # Nothing should want Jenkins $HOME
|
2015-01-12 21:46:10 +00:00
|
|
|
fi
|
|
|
|
|
2015-04-13 09:33:43 +00:00
|
|
|
# Additional parameters that are passed to ginkgo runner.
|
|
|
|
GINKGO_TEST_ARGS=""
|
|
|
|
|
2015-04-14 11:41:48 +00:00
|
|
|
if [[ "${PERFORMANCE:-}" == "true" ]]; then
|
2015-04-13 15:28:24 +00:00
|
|
|
if [[ "${KUBERNETES_PROVIDER}" == "aws" ]]; then
|
|
|
|
export MASTER_SIZE="m3.xlarge"
|
|
|
|
else
|
|
|
|
export MASTER_SIZE="n1-standard-4"
|
|
|
|
fi
|
2015-04-15 07:25:35 +00:00
|
|
|
export NUM_MINIONS="100"
|
2015-04-14 11:41:48 +00:00
|
|
|
GINKGO_TEST_ARGS="--ginkgo.focus=\[Performance suite\] "
|
2015-04-13 09:33:43 +00:00
|
|
|
else
|
2015-04-13 15:28:24 +00:00
|
|
|
if [[ "${KUBERNETES_PROVIDER}" == "aws" ]]; then
|
|
|
|
export MASTER_SIZE="t2.small"
|
|
|
|
else
|
|
|
|
export MASTER_SIZE="g1-small"
|
|
|
|
fi
|
2015-04-13 09:33:43 +00:00
|
|
|
export NUM_MINIONS="2"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2015-01-12 21:46:10 +00:00
|
|
|
# Unlike the kubernetes-build script, we expect some environment
|
|
|
|
# variables to be set. We echo these immediately and presume "set -o
|
|
|
|
# nounset" will force the caller to set them: (The first several are
|
|
|
|
# Jenkins variables.)
|
|
|
|
|
|
|
|
echo "JOB_NAME: ${JOB_NAME}"
|
|
|
|
echo "BUILD_NUMBER: ${BUILD_NUMBER}"
|
|
|
|
echo "WORKSPACE: ${WORKSPACE}"
|
|
|
|
echo "KUBERNETES_PROVIDER: ${KUBERNETES_PROVIDER}" # Cloud provider
|
|
|
|
echo "E2E_CLUSTER_NAME: ${E2E_CLUSTER_NAME}" # Name of the cluster (e.g. "e2e-test-jenkins")
|
|
|
|
echo "E2E_NETWORK: ${E2E_NETWORK}" # Name of the network (e.g. "e2e")
|
|
|
|
echo "E2E_ZONE: ${E2E_ZONE}" # Name of the GCE zone (e.g. "us-central1-f")
|
|
|
|
echo "E2E_OPT: ${E2E_OPT}" # hack/e2e.go options
|
2015-01-13 00:52:34 +00:00
|
|
|
echo "E2E_SET_CLUSTER_API_VERSION: ${E2E_SET_CLUSTER_API_VERSION:-<not set>}" # optional, for GKE, set CLUSTER_API_VERSION to git hash
|
2015-01-12 21:46:10 +00:00
|
|
|
echo "--------------------------------------------------------------------------------"
|
|
|
|
|
2015-02-11 17:45:27 +00:00
|
|
|
# AWS variables
|
|
|
|
export KUBE_AWS_INSTANCE_PREFIX=${E2E_CLUSTER_NAME}
|
|
|
|
export KUBE_AWS_ZONE=${E2E_ZONE}
|
|
|
|
|
2015-01-12 21:46:10 +00:00
|
|
|
# GCE variables
|
|
|
|
export INSTANCE_PREFIX=${E2E_CLUSTER_NAME}
|
|
|
|
export KUBE_GCE_ZONE=${E2E_ZONE}
|
|
|
|
export KUBE_GCE_NETWORK=${E2E_NETWORK}
|
|
|
|
|
|
|
|
# GKE variables
|
|
|
|
export CLUSTER_NAME=${E2E_CLUSTER_NAME}
|
|
|
|
export ZONE=${E2E_ZONE}
|
|
|
|
export KUBE_GKE_NETWORK=${E2E_NETWORK}
|
|
|
|
|
|
|
|
export PATH=${PATH}:/usr/local/go/bin
|
|
|
|
export KUBE_SKIP_CONFIRMATIONS=y
|
|
|
|
|
2015-05-07 23:48:54 +00:00
|
|
|
# E2E Control Variables
|
|
|
|
export E2E_UP="${E2E_UP:-true}"
|
|
|
|
export E2E_TEST="${E2E_TEST:-true}"
|
|
|
|
export E2E_DOWN="${E2E_DOWN:-true}"
|
|
|
|
|
2015-02-11 17:45:27 +00:00
|
|
|
if [[ ${KUBE_RUN_FROM_OUTPUT:-} =~ ^[yY]$ ]]; then
|
|
|
|
echo "Found KUBE_RUN_FROM_OUTPUT=y; will use binaries from _output"
|
|
|
|
cp _output/release-tars/kubernetes*.tar.gz .
|
|
|
|
else
|
|
|
|
echo "Pulling binaries from GCS"
|
|
|
|
if [[ $(find . | wc -l) != 1 ]]; then
|
|
|
|
echo $PWD not empty, bailing!
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-04-22 17:06:01 +00:00
|
|
|
# Tell kube-up.sh to skip the update, it doesn't lock. An internal
|
|
|
|
# gcloud bug can cause racing component updates to stomp on each
|
|
|
|
# other.
|
|
|
|
export KUBE_SKIP_UPDATE=y
|
2015-04-17 16:48:27 +00:00
|
|
|
sudo flock -x -n /var/run/lock/gcloud-components.lock -c "gcloud components update -q" || true
|
2015-02-11 17:45:27 +00:00
|
|
|
|
2015-04-21 22:22:36 +00:00
|
|
|
# The "ci" bucket is for builds like "v0.15.0-468-gfa648c1"
|
|
|
|
bucket="ci"
|
|
|
|
# The "latest" version picks the most recent "ci" or "release" build.
|
|
|
|
version_file="latest"
|
|
|
|
if [[ ${JENKINS_USE_RELEASE_TARS:-} =~ ^[yY]$ ]]; then
|
|
|
|
# The "release" bucket is for builds like "v0.15.0"
|
|
|
|
bucket="release"
|
|
|
|
if [[ ${JENKINS_USE_STABLE:-} =~ ^[yY]$ ]]; then
|
|
|
|
# The "stable" version picks the most recent "release" build.
|
|
|
|
version_file="stable"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
githash=$(gsutil cat gs://kubernetes-release/${bucket}/${version_file}.txt)
|
|
|
|
gsutil -m cp gs://kubernetes-release/${bucket}/${githash}/kubernetes.tar.gz gs://kubernetes-release/${bucket}/${githash}/kubernetes-test.tar.gz .
|
2015-02-11 17:45:27 +00:00
|
|
|
fi
|
2015-01-12 21:46:10 +00:00
|
|
|
|
|
|
|
md5sum kubernetes*.tar.gz
|
|
|
|
tar -xzf kubernetes.tar.gz
|
|
|
|
tar -xzf kubernetes-test.tar.gz
|
|
|
|
cd kubernetes
|
|
|
|
|
2015-01-13 00:52:34 +00:00
|
|
|
# Set by GKE-CI to change the CLUSTER_API_VERSION to the git version
|
|
|
|
if [[ ! -z ${E2E_SET_CLUSTER_API_VERSION:-} ]]; then
|
2015-04-21 22:22:36 +00:00
|
|
|
export CLUSTER_API_VERSION=$(echo ${githash} | cut -c 2-)
|
|
|
|
elif [[ ${JENKINS_USE_RELEASE_TARS:-} =~ ^[yY]$ ]]; then
|
|
|
|
release=$(gsutil cat gs://kubernetes-release/release/${version_file}.txt | cut -c 2-)
|
2015-03-30 19:11:23 +00:00
|
|
|
export CLUSTER_API_VERSION=${release}
|
2015-01-13 00:52:34 +00:00
|
|
|
fi
|
2015-01-12 21:46:10 +00:00
|
|
|
|
2015-02-05 18:23:19 +00:00
|
|
|
# Have cmd/e2e run by goe2e.sh generate JUnit report in ${WORKSPACE}/junit*.xml
|
|
|
|
export E2E_REPORT_DIR=${WORKSPACE}
|
|
|
|
|
2015-02-18 00:37:27 +00:00
|
|
|
### Set up ###
|
2015-05-07 23:48:54 +00:00
|
|
|
if [[ "${E2E_UP,,}" == "true" ]]; then
|
|
|
|
go run ./hack/e2e.go ${E2E_OPT} -v --down
|
|
|
|
go run ./hack/e2e.go ${E2E_OPT} -v --up
|
|
|
|
go run ./hack/e2e.go -v --ctl="version --match-server-version=false"
|
|
|
|
fi
|
2015-02-18 00:37:27 +00:00
|
|
|
|
|
|
|
### Run tests ###
|
|
|
|
# Jenkins will look at the junit*.xml files for test failures, so don't exit
|
|
|
|
# with a nonzero error code if it was only tests that failed.
|
2015-05-07 23:48:54 +00:00
|
|
|
if [[ "${E2E_TEST,,}" == "true" ]]; then
|
|
|
|
go run ./hack/e2e.go ${E2E_OPT} -v --test --test_args="${GINKGO_TEST_ARGS}--ginkgo.noColor" || true
|
|
|
|
fi
|
2015-02-18 00:37:27 +00:00
|
|
|
|
|
|
|
### Clean up ###
|
2015-05-07 23:48:54 +00:00
|
|
|
if [[ "${E2E_DOWN,,}" == "true" ]]; then
|
|
|
|
go run ./hack/e2e.go ${E2E_OPT} -v --down
|
|
|
|
fi
|