run_e2e.sh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/usr/bin/env bash
  2. # Copyright 2018 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. # Shutdown the tests gracefully then save the results
  19. shutdown () {
  20. E2E_SUITE_PID=$(pgrep e2e.test)
  21. echo "sending TERM to ${E2E_SUITE_PID}"
  22. kill -s TERM "${E2E_SUITE_PID}"
  23. # Kind of a hack to wait for this pid to finish.
  24. # Since it's not a child of this shell we cannot use wait.
  25. tail --pid "${E2E_SUITE_PID}" -f /dev/null
  26. saveResults
  27. }
  28. saveResults() {
  29. cd "${RESULTS_DIR}" || exit
  30. tar -czf e2e.tar.gz ./*
  31. # mark the done file as a termination notice.
  32. echo -n "${RESULTS_DIR}/e2e.tar.gz" > "${RESULTS_DIR}/done"
  33. }
  34. # Optional Golang runner alternative to the bash script.
  35. # Entry provided via env var to simplify invocation.
  36. if [[ -n ${E2E_USE_GO_RUNNER:-} ]]; then
  37. set -x
  38. /gorunner && ret=0 || ret=$?
  39. exit ${ret}
  40. fi
  41. # We get the TERM from kubernetes and handle it gracefully
  42. trap shutdown TERM
  43. ginkgo_args=()
  44. if [[ -n ${E2E_DRYRUN:-} ]]; then
  45. ginkgo_args+=("--dryRun=true")
  46. fi
  47. case ${E2E_PARALLEL} in
  48. 'y'|'Y'|'true')
  49. # The flag '--p' will automatically detect the optimal number of ginkgo nodes.
  50. ginkgo_args+=("--p")
  51. # Skip serial tests if parallel mode is enabled.
  52. E2E_SKIP="\\[Serial\\]|${E2E_SKIP}" ;;
  53. esac
  54. ginkgo_args+=(
  55. "--focus=${E2E_FOCUS}"
  56. "--skip=${E2E_SKIP}"
  57. "--noColor=true"
  58. )
  59. set -x
  60. /usr/local/bin/ginkgo "${ginkgo_args[@]}" /usr/local/bin/e2e.test -- --disable-log-dump --repo-root=/kubernetes --provider="${E2E_PROVIDER}" --report-dir="${RESULTS_DIR}" --kubeconfig="${KUBECONFIG}" -v="${E2E_VERBOSITY}" > >(tee "${RESULTS_DIR}"/e2e.log) && ret=0 || ret=$?
  61. set +x
  62. saveResults
  63. exit ${ret}