sigs.k8s.io/cluster-api-provider-aws@v1.5.5/scripts/ci-e2e-conformance.sh (about) 1 #!/bin/bash 2 3 # Copyright 2020 The Kubernetes Authors. 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 ################################################################################ 18 # usage: e2e.sh 19 # This program runs the e2e tests. 20 # 21 # ENVIRONMENT VARIABLES 22 # JANITOR_ENABLED 23 # Set to 1 to run the aws-janitor command after running the e2e tests. 24 ################################################################################ 25 26 set -o nounset 27 set -o pipefail 28 29 REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. 30 cd "${REPO_ROOT}" || exit 1 31 32 # shellcheck source=../hack/ensure-go.sh 33 source "${REPO_ROOT}/hack/ensure-go.sh" 34 35 # our exit handler (trap) 36 cleanup() { 37 # stop boskos heartbeat 38 [[ -z ${HEART_BEAT_PID:-} ]] || kill -9 "${HEART_BEAT_PID}" 39 } 40 trap cleanup EXIT 41 42 #Install requests module explicitly for HTTP calls 43 python3 -m pip install requests 44 45 # If BOSKOS_HOST is set then acquire an AWS account from Boskos. 46 if [ -n "${BOSKOS_HOST:-}" ]; then 47 # Check out the account from Boskos and store the produced environment 48 # variables in a temporary file. 49 account_env_var_file="$(mktemp)" 50 python3 hack/boskos.py --get 1>"${account_env_var_file}" 51 checkout_account_status="${?}" 52 53 # If the checkout process was a success then load the account's 54 # environment variables into this process. 55 # shellcheck disable=SC1090 56 [ "${checkout_account_status}" = "0" ] && . "${account_env_var_file}" 57 58 # Always remove the account environment variable file. It contains 59 # sensitive information. 60 rm -f "${account_env_var_file}" 61 62 if [ ! "${checkout_account_status}" = "0" ]; then 63 echo "error getting account from boskos" 1>&2 64 exit "${checkout_account_status}" 65 fi 66 67 python3 -u hack/boskos.py --heartbeat >>$ARTIFACTS/boskos.log 2>&1 & 68 HEART_BEAT_PID=$(echo $!) 69 fi 70 71 # Prevent a disallowed AWS key from being used. 72 if grep -iqF "$(echo "${AWS_ACCESS_KEY_ID-}" | 73 { md5sum 2>/dev/null || md5; } | 74 awk '{print $1}')" hack/e2e-aws-disallowed.txt; then 75 echo "The provided AWS key is not allowed" 1>&2 76 exit 1 77 fi 78 79 make test-conformance 80 test_status="${?}" 81 82 # If Boskos is being used then release the AWS account back to Boskos. 83 [ -z "${BOSKOS_HOST:-}" ] || python3 -u hack/boskos.py --release 84 85 # The janitor is typically not run as part of the e2e process, but rather 86 # in a parallel process via a service on the same cluster that runs Prow and 87 # Boskos. 88 # 89 # However, setting JANITOR_ENABLED=1 tells this program to run the janitor 90 # after the e2e test is executed. 91 if [ "${JANITOR_ENABLED:-0}" = "1" ]; then 92 if ! command -v aws-janitor >/dev/null 2>&1; then 93 echo "skipping janitor; aws-janitor not found" 1>&2 94 else 95 aws-janitor -all -v 2 96 fi 97 else 98 echo "skipping janitor; JANITOR_ENABLED=${JANITOR_ENABLED:-0}" 1>&2 99 fi 100 101 exit "${test_status}"