2018-04-16 16:31:44 +00:00
|
|
|
#!/usr/bin/env bash
|
2014-10-23 23:13:46 +00:00
|
|
|
|
2016-06-03 00:25:58 +00:00
|
|
|
# Copyright 2014 The Kubernetes Authors.
|
2014-10-23 23:13:46 +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.
|
|
|
|
|
2015-02-05 08:00:28 +00:00
|
|
|
set -o errexit
|
|
|
|
set -o nounset
|
|
|
|
set -o pipefail
|
|
|
|
|
2015-05-18 19:11:33 +00:00
|
|
|
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
|
2015-04-17 17:19:53 +00:00
|
|
|
source "${KUBE_ROOT}/cluster/common.sh"
|
2015-05-19 16:13:08 +00:00
|
|
|
source "${KUBE_ROOT}/hack/lib/init.sh"
|
2015-02-05 08:00:28 +00:00
|
|
|
|
2015-05-19 16:13:08 +00:00
|
|
|
# Find the ginkgo binary build as part of the release.
|
|
|
|
ginkgo=$(kube::util::find-binary "ginkgo")
|
|
|
|
e2e_test=$(kube::util::find-binary "e2e.test")
|
2014-10-22 23:26:59 +00:00
|
|
|
|
2015-03-05 23:41:52 +00:00
|
|
|
# --- Setup some env vars.
|
|
|
|
|
2016-05-06 04:29:30 +00:00
|
|
|
GINKGO_PARALLEL=${GINKGO_PARALLEL:-n} # set to 'y' to run tests in parallel
|
2017-04-28 12:37:50 +00:00
|
|
|
CLOUD_CONFIG=${CLOUD_CONFIG:-""}
|
2016-05-06 04:29:30 +00:00
|
|
|
|
2017-03-23 08:59:49 +00:00
|
|
|
# If 'y', Ginkgo's reporter will not print out in color when tests are run
|
|
|
|
# in parallel
|
|
|
|
GINKGO_NO_COLOR=${GINKGO_NO_COLOR:-n}
|
|
|
|
|
2016-06-22 20:41:15 +00:00
|
|
|
# If 'y', will rerun failed tests once to give them a second chance.
|
|
|
|
GINKGO_TOLERATE_FLAKES=${GINKGO_TOLERATE_FLAKES:-n}
|
|
|
|
|
2016-02-24 21:08:22 +00:00
|
|
|
: ${KUBECTL:="${KUBE_ROOT}/cluster/kubectl.sh"}
|
2015-03-05 23:41:52 +00:00
|
|
|
: ${KUBE_CONFIG_FILE:="config-test.sh"}
|
|
|
|
|
|
|
|
export KUBECTL KUBE_CONFIG_FILE
|
|
|
|
|
2016-03-09 00:51:20 +00:00
|
|
|
source "${KUBE_ROOT}/cluster/kube-util.sh"
|
2014-10-22 23:26:59 +00:00
|
|
|
|
2018-01-20 05:22:16 +00:00
|
|
|
function detect-master-from-kubeconfig() {
|
|
|
|
export KUBECONFIG=${KUBECONFIG:-$DEFAULT_KUBECONFIG}
|
|
|
|
|
|
|
|
local cc=$("${KUBE_ROOT}/cluster/kubectl.sh" config view -o jsonpath="{.current-context}")
|
|
|
|
if [[ ! -z "${KUBE_CONTEXT:-}" ]]; then
|
|
|
|
cc="${KUBE_CONTEXT}"
|
|
|
|
fi
|
|
|
|
local cluster=$("${KUBE_ROOT}/cluster/kubectl.sh" config view -o jsonpath="{.contexts[?(@.name == \"${cc}\")].context.cluster}")
|
|
|
|
KUBE_MASTER_URL=$("${KUBE_ROOT}/cluster/kubectl.sh" config view -o jsonpath="{.clusters[?(@.name == \"${cluster}\")].cluster.server}")
|
|
|
|
}
|
|
|
|
|
2015-03-05 23:41:52 +00:00
|
|
|
# ---- Do cloud-provider-specific setup
|
2015-06-15 21:00:59 +00:00
|
|
|
if [[ -n "${KUBERNETES_CONFORMANCE_TEST:-}" ]]; then
|
|
|
|
echo "Conformance test: not doing test setup."
|
2016-11-01 20:57:24 +00:00
|
|
|
KUBERNETES_PROVIDER=${KUBERNETES_CONFORMANCE_PROVIDER:-"skeleton"}
|
2015-08-13 05:19:29 +00:00
|
|
|
|
|
|
|
detect-master-from-kubeconfig
|
|
|
|
|
2015-06-24 18:58:07 +00:00
|
|
|
auth_config=(
|
|
|
|
"--kubeconfig=${KUBECONFIG}"
|
|
|
|
)
|
2015-06-15 21:00:59 +00:00
|
|
|
else
|
2015-03-05 23:41:52 +00:00
|
|
|
echo "Setting up for KUBERNETES_PROVIDER=\"${KUBERNETES_PROVIDER}\"."
|
|
|
|
|
|
|
|
prepare-e2e
|
|
|
|
|
|
|
|
detect-master >/dev/null
|
2015-08-13 05:19:29 +00:00
|
|
|
KUBE_MASTER_URL="${KUBE_MASTER_URL:-https://${KUBE_MASTER_IP:-}}"
|
2015-03-05 23:41:52 +00:00
|
|
|
|
2015-06-15 21:00:59 +00:00
|
|
|
auth_config=(
|
2015-06-24 18:58:07 +00:00
|
|
|
"--kubeconfig=${KUBECONFIG:-$DEFAULT_KUBECONFIG}"
|
2015-06-15 21:00:59 +00:00
|
|
|
)
|
2015-03-02 16:13:57 +00:00
|
|
|
fi
|
|
|
|
|
2015-04-23 14:28:16 +00:00
|
|
|
if [[ -n "${NODE_INSTANCE_PREFIX:-}" ]]; then
|
|
|
|
NODE_INSTANCE_GROUP="${NODE_INSTANCE_PREFIX}-group"
|
|
|
|
fi
|
|
|
|
|
2016-05-23 12:10:40 +00:00
|
|
|
if [[ "${KUBERNETES_PROVIDER}" == "gce" ]]; then
|
|
|
|
set_num_migs
|
|
|
|
NODE_INSTANCE_GROUP=""
|
|
|
|
for ((i=1; i<=${NUM_MIGS}; i++)); do
|
2019-01-18 18:17:16 +00:00
|
|
|
if [[ ${i} == ${NUM_MIGS} ]]; then
|
2016-05-23 12:10:40 +00:00
|
|
|
# We are assigning the same mig names as create-nodes function from cluster/gce/util.sh.
|
|
|
|
NODE_INSTANCE_GROUP="${NODE_INSTANCE_GROUP}${NODE_INSTANCE_PREFIX}-group"
|
|
|
|
else
|
|
|
|
NODE_INSTANCE_GROUP="${NODE_INSTANCE_GROUP}${NODE_INSTANCE_PREFIX}-group-${i},"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2017-07-17 18:59:41 +00:00
|
|
|
# TODO(kubernetes/test-infra#3330): Allow NODE_INSTANCE_GROUP to be
|
|
|
|
# set before we get here, which eliminates any cluster/gke use if
|
|
|
|
# KUBERNETES_CONFORMANCE_PROVIDER is set to "gke".
|
|
|
|
if [[ -z "${NODE_INSTANCE_GROUP:-}" ]] && [[ "${KUBERNETES_PROVIDER}" == "gke" ]]; then
|
2016-06-06 22:48:42 +00:00
|
|
|
detect-node-instance-groups
|
2016-06-22 22:29:59 +00:00
|
|
|
NODE_INSTANCE_GROUP=$(kube::util::join , "${NODE_INSTANCE_GROUPS[@]}")
|
2015-06-09 18:49:40 +00:00
|
|
|
fi
|
|
|
|
|
2017-04-28 12:37:50 +00:00
|
|
|
if [[ "${KUBERNETES_PROVIDER}" == "azure" ]]; then
|
|
|
|
if [[ ${CLOUD_CONFIG} == "" ]]; then
|
|
|
|
echo "Missing azure cloud config"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2015-05-19 16:13:08 +00:00
|
|
|
ginkgo_args=()
|
2015-06-24 18:58:07 +00:00
|
|
|
if [[ -n "${CONFORMANCE_TEST_SKIP_REGEX:-}" ]]; then
|
|
|
|
ginkgo_args+=("--skip=${CONFORMANCE_TEST_SKIP_REGEX}")
|
|
|
|
ginkgo_args+=("--seed=1436380640")
|
2015-06-15 21:00:59 +00:00
|
|
|
fi
|
2016-01-13 01:45:23 +00:00
|
|
|
if [[ -n "${GINKGO_PARALLEL_NODES:-}" ]]; then
|
|
|
|
ginkgo_args+=("--nodes=${GINKGO_PARALLEL_NODES}")
|
|
|
|
elif [[ ${GINKGO_PARALLEL} =~ ^[yY]$ ]]; then
|
2016-05-12 21:12:37 +00:00
|
|
|
ginkgo_args+=("--nodes=25")
|
2015-05-19 16:13:08 +00:00
|
|
|
fi
|
|
|
|
|
2017-03-14 02:36:41 +00:00
|
|
|
if [[ "${GINKGO_UNTIL_IT_FAILS:-}" == true ]]; then
|
2017-07-31 22:10:00 +00:00
|
|
|
ginkgo_args+=("--untilItFails=true")
|
2017-03-14 02:36:41 +00:00
|
|
|
fi
|
|
|
|
|
2016-06-22 20:41:15 +00:00
|
|
|
FLAKE_ATTEMPTS=1
|
|
|
|
if [[ "${GINKGO_TOLERATE_FLAKES}" == "y" ]]; then
|
|
|
|
FLAKE_ATTEMPTS=2
|
|
|
|
fi
|
|
|
|
|
2017-03-09 11:24:19 +00:00
|
|
|
if [[ "${GINKGO_NO_COLOR}" == "y" ]]; then
|
|
|
|
ginkgo_args+=("--noColor")
|
|
|
|
fi
|
|
|
|
|
2015-03-19 14:13:35 +00:00
|
|
|
# The --host setting is used only when providing --auth_config
|
|
|
|
# If --kubeconfig is used, the host to use is retrieved from the .kubeconfig
|
|
|
|
# file and the one provided with --host is ignored.
|
2015-05-26 16:27:13 +00:00
|
|
|
# Add path for things like running kubectl binary.
|
|
|
|
export PATH=$(dirname "${e2e_test}"):"${PATH}"
|
2015-05-19 16:13:08 +00:00
|
|
|
"${ginkgo}" "${ginkgo_args[@]:+${ginkgo_args[@]}}" "${e2e_test}" -- \
|
|
|
|
"${auth_config[@]:+${auth_config[@]}}" \
|
2016-06-22 20:41:15 +00:00
|
|
|
--ginkgo.flakeAttempts="${FLAKE_ATTEMPTS}" \
|
2015-08-13 05:19:29 +00:00
|
|
|
--host="${KUBE_MASTER_URL}" \
|
2015-01-28 22:54:08 +00:00
|
|
|
--provider="${KUBERNETES_PROVIDER}" \
|
2015-05-19 16:13:08 +00:00
|
|
|
--gce-project="${PROJECT:-}" \
|
|
|
|
--gce-zone="${ZONE:-}" \
|
2017-07-27 11:09:11 +00:00
|
|
|
--gce-region="${REGION:-}" \
|
2016-11-14 14:29:36 +00:00
|
|
|
--gce-multizone="${MULTIZONE:-false}" \
|
2015-06-19 22:17:28 +00:00
|
|
|
--gke-cluster="${CLUSTER_NAME:-}" \
|
2015-05-19 16:13:08 +00:00
|
|
|
--kube-master="${KUBE_MASTER:-}" \
|
2015-05-23 00:12:53 +00:00
|
|
|
--cluster-tag="${CLUSTER_ID:-}" \
|
2017-04-28 12:37:50 +00:00
|
|
|
--cloud-config-file="${CLOUD_CONFIG:-}" \
|
2016-02-24 21:08:22 +00:00
|
|
|
--repo-root="${KUBE_ROOT}" \
|
2015-04-23 14:28:16 +00:00
|
|
|
--node-instance-group="${NODE_INSTANCE_GROUP:-}" \
|
2015-06-05 20:43:43 +00:00
|
|
|
--prefix="${KUBE_GCE_INSTANCE_PREFIX:-e2e}" \
|
2016-08-26 17:06:00 +00:00
|
|
|
--network="${KUBE_GCE_NETWORK:-${KUBE_GKE_NETWORK:-e2e}}" \
|
2017-06-07 00:27:07 +00:00
|
|
|
--node-tag="${NODE_TAG:-}" \
|
|
|
|
--master-tag="${MASTER_TAG:-}" \
|
2018-04-10 09:22:00 +00:00
|
|
|
--cluster-monitoring-mode="${KUBE_ENABLE_CLUSTER_MONITORING:-standalone}" \
|
2018-04-06 16:24:56 +00:00
|
|
|
--prometheus-monitoring="${KUBE_ENABLE_PROMETHEUS_MONITORING:-false}" \
|
2018-09-24 16:42:34 +00:00
|
|
|
--dns-domain="${KUBE_DNS_DOMAIN:-cluster.local}" \
|
2018-12-31 11:50:01 +00:00
|
|
|
--ginkgo.slowSpecThreshold="${GINKGO_SLOW_SPEC_THRESHOLD:-300}" \
|
2016-06-15 18:49:12 +00:00
|
|
|
${KUBE_CONTAINER_RUNTIME:+"--container-runtime=${KUBE_CONTAINER_RUNTIME}"} \
|
2016-06-23 18:22:04 +00:00
|
|
|
${MASTER_OS_DISTRIBUTION:+"--master-os-distro=${MASTER_OS_DISTRIBUTION}"} \
|
|
|
|
${NODE_OS_DISTRIBUTION:+"--node-os-distro=${NODE_OS_DISTRIBUTION}"} \
|
2016-02-17 15:52:43 +00:00
|
|
|
${NUM_NODES:+"--num-nodes=${NUM_NODES}"} \
|
2015-07-23 22:22:02 +00:00
|
|
|
${E2E_REPORT_DIR:+"--report-dir=${E2E_REPORT_DIR}"} \
|
2016-03-15 00:07:45 +00:00
|
|
|
${E2E_REPORT_PREFIX:+"--report-prefix=${E2E_REPORT_PREFIX}"} \
|
2015-02-11 17:39:06 +00:00
|
|
|
"${@:-}"
|