ginkgo-e2e.sh 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #!/bin/bash
  2. # Copyright 2014 The Kubernetes Authors.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. set -o errexit
  16. set -o nounset
  17. set -o pipefail
  18. KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
  19. source "${KUBE_ROOT}/cluster/common.sh"
  20. source "${KUBE_ROOT}/hack/lib/init.sh"
  21. # Find the ginkgo binary build as part of the release.
  22. ginkgo=$(kube::util::find-binary "ginkgo")
  23. e2e_test=$(kube::util::find-binary "e2e.test")
  24. # --- Setup some env vars.
  25. GINKGO_PARALLEL=${GINKGO_PARALLEL:-n} # set to 'y' to run tests in parallel
  26. # If 'y', will rerun failed tests once to give them a second chance.
  27. GINKGO_TOLERATE_FLAKES=${GINKGO_TOLERATE_FLAKES:-n}
  28. # The number of tests that can run in parallel depends on what tests
  29. # are running and on the size of the cluster. Too many, and tests will
  30. # fail due to resource contention. 25 is a reasonable default for a
  31. # 3-node (n1-standard-1) cluster running all fast, non-disruptive tests.
  32. GINKGO_PARALLELISM=${GINKGO_PARALLELISM:-25}
  33. : ${KUBECTL:="${KUBE_ROOT}/cluster/kubectl.sh"}
  34. : ${KUBE_CONFIG_FILE:="config-test.sh"}
  35. export KUBECTL KUBE_CONFIG_FILE
  36. source "${KUBE_ROOT}/cluster/kube-util.sh"
  37. # ---- Do cloud-provider-specific setup
  38. if [[ -n "${KUBERNETES_CONFORMANCE_TEST:-}" ]]; then
  39. echo "Conformance test: not doing test setup."
  40. KUBERNETES_PROVIDER="skeleton"
  41. detect-master-from-kubeconfig
  42. auth_config=(
  43. "--kubeconfig=${KUBECONFIG}"
  44. )
  45. else
  46. echo "Setting up for KUBERNETES_PROVIDER=\"${KUBERNETES_PROVIDER}\"."
  47. prepare-e2e
  48. detect-master >/dev/null
  49. KUBE_MASTER_URL="${KUBE_MASTER_URL:-https://${KUBE_MASTER_IP:-}}"
  50. auth_config=(
  51. "--kubeconfig=${KUBECONFIG:-$DEFAULT_KUBECONFIG}"
  52. )
  53. fi
  54. if [[ -n "${NODE_INSTANCE_PREFIX:-}" ]]; then
  55. NODE_INSTANCE_GROUP="${NODE_INSTANCE_PREFIX}-group"
  56. else
  57. NODE_INSTANCE_GROUP=""
  58. fi
  59. if [[ "${KUBERNETES_PROVIDER}" == "gce" ]]; then
  60. set_num_migs
  61. NODE_INSTANCE_GROUP=""
  62. for ((i=1; i<=${NUM_MIGS}; i++)); do
  63. if [[ $i == ${NUM_MIGS} ]]; then
  64. # We are assigning the same mig names as create-nodes function from cluster/gce/util.sh.
  65. NODE_INSTANCE_GROUP="${NODE_INSTANCE_GROUP}${NODE_INSTANCE_PREFIX}-group"
  66. else
  67. NODE_INSTANCE_GROUP="${NODE_INSTANCE_GROUP}${NODE_INSTANCE_PREFIX}-group-${i},"
  68. fi
  69. done
  70. fi
  71. if [[ "${KUBERNETES_PROVIDER}" == "gke" ]]; then
  72. detect-node-instance-groups
  73. NODE_INSTANCE_GROUP=$(kube::util::join , "${NODE_INSTANCE_GROUPS[@]}")
  74. fi
  75. ginkgo_args=()
  76. if [[ -n "${CONFORMANCE_TEST_SKIP_REGEX:-}" ]]; then
  77. ginkgo_args+=("--skip=${CONFORMANCE_TEST_SKIP_REGEX}")
  78. ginkgo_args+=("--seed=1436380640")
  79. fi
  80. if [[ -n "${GINKGO_PARALLEL_NODES:-}" ]]; then
  81. ginkgo_args+=("--nodes=${GINKGO_PARALLEL_NODES}")
  82. elif [[ ${GINKGO_PARALLEL} =~ ^[yY]$ ]]; then
  83. ginkgo_args+=("--nodes=25")
  84. fi
  85. FLAKE_ATTEMPTS=1
  86. if [[ "${GINKGO_TOLERATE_FLAKES}" == "y" ]]; then
  87. FLAKE_ATTEMPTS=2
  88. fi
  89. # The --host setting is used only when providing --auth_config
  90. # If --kubeconfig is used, the host to use is retrieved from the .kubeconfig
  91. # file and the one provided with --host is ignored.
  92. # Add path for things like running kubectl binary.
  93. export PATH=$(dirname "${e2e_test}"):"${PATH}"
  94. "${ginkgo}" "${ginkgo_args[@]:+${ginkgo_args[@]}}" "${e2e_test}" -- \
  95. "${auth_config[@]:+${auth_config[@]}}" \
  96. --ginkgo.flakeAttempts="${FLAKE_ATTEMPTS}" \
  97. --host="${KUBE_MASTER_URL}" \
  98. --provider="${KUBERNETES_PROVIDER}" \
  99. --gce-project="${PROJECT:-}" \
  100. --gce-zone="${ZONE:-}" \
  101. --gke-cluster="${CLUSTER_NAME:-}" \
  102. --kube-master="${KUBE_MASTER:-}" \
  103. --cluster-tag="${CLUSTER_ID:-}" \
  104. --repo-root="${KUBE_ROOT}" \
  105. --node-instance-group="${NODE_INSTANCE_GROUP:-}" \
  106. --prefix="${KUBE_GCE_INSTANCE_PREFIX:-e2e}" \
  107. --network="${KUBE_GCE_NETWORK:-${KUBE_GKE_NETWORK:-e2e}}" \
  108. ${KUBE_CONTAINER_RUNTIME:+"--container-runtime=${KUBE_CONTAINER_RUNTIME}"} \
  109. ${MASTER_OS_DISTRIBUTION:+"--master-os-distro=${MASTER_OS_DISTRIBUTION}"} \
  110. ${NODE_OS_DISTRIBUTION:+"--node-os-distro=${NODE_OS_DISTRIBUTION}"} \
  111. ${NUM_NODES:+"--num-nodes=${NUM_NODES}"} \
  112. ${E2E_CLEAN_START:+"--clean-start=true"} \
  113. ${E2E_MIN_STARTUP_PODS:+"--minStartupPods=${E2E_MIN_STARTUP_PODS}"} \
  114. ${E2E_REPORT_DIR:+"--report-dir=${E2E_REPORT_DIR}"} \
  115. ${E2E_REPORT_PREFIX:+"--report-prefix=${E2E_REPORT_PREFIX}"} \
  116. "${@:-}"