sigs.k8s.io/cluster-api-provider-aws@v1.5.5/scripts/ci-conformance.sh (about) 1 #!/bin/bash 2 3 # Copyright 2019 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: ci-conformance.sh 19 # This program runs the clusterctl conformance 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 # our exit handler (trap) 33 cleanup() { 34 # stop boskos heartbeat 35 [[ -z ${HEART_BEAT_PID:-} ]] || kill -9 "${HEART_BEAT_PID}" 36 } 37 trap cleanup EXIT 38 39 #Install requests module explicitly for HTTP calls 40 python3 -m pip install requests 41 42 # If BOSKOS_HOST is set then acquire an AWS account from Boskos. 43 if [ -n "${BOSKOS_HOST:-}" ]; then 44 # Check out the account from Boskos and store the produced environment 45 # variables in a temporary file. 46 account_env_var_file="$(mktemp)" 47 python3 hack/boskos.py --get 1>"${account_env_var_file}" 48 checkout_account_status="${?}" 49 50 # If the checkout process was a success then load the account's 51 # environment variables into this process. 52 # shellcheck disable=SC1090 53 [ "${checkout_account_status}" = "0" ] && . "${account_env_var_file}" 54 55 # Always remove the account environment variable file. It contains 56 # sensitive information. 57 rm -f "${account_env_var_file}" 58 59 if [ ! "${checkout_account_status}" = "0" ]; then 60 echo "error getting account from boskos" 1>&2 61 exit "${checkout_account_status}" 62 fi 63 64 python3 -u hack/boskos.py --heartbeat >>$ARTIFACTS/boskos.log 2>&1 & 65 HEART_BEAT_PID=$(echo $!) 66 fi 67 68 # Prevent a disallowed AWS key from being used. 69 if grep -iqF "$(echo "${AWS_ACCESS_KEY_ID-}" | 70 { md5sum 2>/dev/null || md5; } | 71 awk '{print $1}')" hack/e2e-aws-disallowed.txt; then 72 echo "The provided AWS key is not allowed" 1>&2 73 exit 1 74 fi 75 76 make test-conformance 77 test_status="${?}" 78 79 # If Boskos is being used then release the AWS account back to Boskos. 80 [ -z "${BOSKOS_HOST:-}" ] || python3 -u hack/boskos.py --release 81 82 # The janitor is typically not run as part of the e2e process, but rather 83 # in a parallel process via a service on the same cluster that runs Prow and 84 # Boskos. 85 # 86 # However, setting JANITOR_ENABLED=1 tells this program to run the janitor 87 # after the e2e test is executed. 88 if [ "${JANITOR_ENABLED:-0}" = "1" ]; then 89 if ! command -v aws-janitor >/dev/null 2>&1; then 90 echo "skipping janitor; aws-janitor not found" 1>&2 91 else 92 aws-janitor -all -v 2 93 fi 94 else 95 echo "skipping janitor; JANITOR_ENABLED=${JANITOR_ENABLED:-0}" 1>&2 96 fi 97 98 exit "${test_status}"