k8s.io/kubernetes@v1.29.3/test/conformance/image/run_e2e.sh (about) 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 16 set -o errexit 17 set -o nounset 18 set -o pipefail 19 20 # Shutdown the tests gracefully then save the results 21 shutdown () { 22 E2E_SUITE_PID=$(pgrep e2e.test) 23 echo "sending TERM to ${E2E_SUITE_PID}" 24 kill -s TERM "${E2E_SUITE_PID}" 25 26 # Kind of a hack to wait for this pid to finish. 27 # Since it's not a child of this shell we cannot use wait. 28 tail --pid "${E2E_SUITE_PID}" -f /dev/null 29 saveResults 30 } 31 32 saveResults() { 33 cd "${RESULTS_DIR}" || exit 34 tar -czf e2e.tar.gz ./* 35 # mark the done file as a termination notice. 36 echo -n "${RESULTS_DIR}/e2e.tar.gz" > "${RESULTS_DIR}/done" 37 } 38 39 # Optional Golang runner alternative to the bash script. 40 # Entry provided via env var to simplify invocation. 41 if [[ -n ${E2E_USE_GO_RUNNER:-} ]]; then 42 set -x 43 /gorunner && ret=0 || ret=$? 44 exit ${ret} 45 fi 46 47 # We get the TERM from kubernetes and handle it gracefully 48 trap shutdown TERM 49 50 ginkgo_args=() 51 if [[ -n ${E2E_DRYRUN:-} ]]; then 52 ginkgo_args+=("--dryRun=true") 53 fi 54 55 # NOTE: Ginkgo's default timeout has been reduced from 24h to 1h in V2, set it manually here as "24h" 56 # for backward compatibility purpose. 57 ginkgo_args+=("--timeout=24h") 58 59 case ${E2E_PARALLEL} in 60 'y'|'Y'|'true') 61 # The flag '--p' will automatically detect the optimal number of ginkgo nodes. 62 ginkgo_args+=("--p") 63 # Skip serial tests if parallel mode is enabled. 64 E2E_SKIP="\\[Serial\\]|${E2E_SKIP}" ;; 65 esac 66 67 ginkgo_args+=( 68 "--focus=${E2E_FOCUS}" 69 "--skip=${E2E_SKIP}" 70 "--no-color=true" 71 ) 72 73 set -x 74 /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=$? 75 set +x 76 saveResults 77 exit ${ret}