diff --git a/tests/README.md b/tests/README.md index 03f09f14169..0b6ddebf5e1 100644 --- a/tests/README.md +++ b/tests/README.md @@ -70,7 +70,7 @@ AWS_REGION ``` ### 2. Launch the tests -Once the environment variables are set, run `./tests/run.sh`. +Once the environment variables are set, run `./tests/run.sh aws`. ## Or, if you already have a cluster running diff --git a/tests/run.sh b/tests/run.sh index 67b72148d3e..1a51e03d8c3 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -9,13 +9,15 @@ set -e set -eo pipefail +BACKEND="${1}" +LEAVE_RUNNING="${LEAVE_RUNNING:-n}" # do not teardown after successful initialization SMOKE_TEST_OUTPUT="Never executed. Problem with one of previous stages" [ -z ${PULL_SECRET_PATH+x} ] && (echo "Please set PULL_SECRET_PATH"; exit 1) [ -z ${DOMAIN+x} ] && DOMAIN="tectonic-ci.de" [ -z ${JOB_NAME+x} ] && PREFIX="${USER:-test}" || PREFIX="ci-${JOB_NAME#*/}" CLUSTER_NAME=$(echo "${PREFIX}-$(uuidgen -r | cut -c1-5)" | tr '[:upper:]' '[:lower:]') TECTONIC="${PWD}/tectonic-dev/installer/tectonic" -exec &> >(tee -a "$CLUSTER_NAME.log") +exec &> >(tee -ai "$CLUSTER_NAME.log") function destroy() { echo -e "\\e[34m Exiting... Destroying Tectonic...\\e[0m" @@ -24,8 +26,6 @@ function destroy() { echo -e "\\e[34m So Long, and Thanks for All the Fish\\e[0m" } -trap destroy EXIT - echo -e "\\e[36m Starting build process...\\e[0m" bazel build tarball smoke_tests # In future bazel build could be extracted to another job which could be running in docker container like this: @@ -34,6 +34,7 @@ bazel build tarball smoke_tests echo -e "\\e[36m Unpacking artifacts...\\e[0m" tar -zxf bazel-bin/tectonic-dev.tar.gz cp bazel-bin/tests/smoke/linux_amd64_pure_stripped/go_default_test tectonic-dev/smoke +chmod 755 tectonic-dev/smoke cd tectonic-dev ### HANDLE SSH KEY ### @@ -42,25 +43,36 @@ if [ ! -f ~/.ssh/id_rsa.pub ]; then ssh-keygen -qb 2048 -t rsa -f ~/.ssh/id_rsa -N "" &2; exit 1) + ;; +*) + echo "unrecognized backend: ${BACKEND}" >&2 + echo "Use ${0} BACKEND, where BACKEND is aws or libvirt" >&2 + exit 1 +esac echo -e "\\e[36m Creating Tectonic configuration...\\e[0m" python <<-EOF >"${CLUSTER_NAME}.yaml" @@ -70,7 +82,7 @@ python <<-EOF >"${CLUSTER_NAME}.yaml" import yaml - with open('examples/tectonic.aws.yaml') as f: + with open('examples/tectonic.${BACKEND}.yaml') as f: config = yaml.load(f) config['name'] = '${CLUSTER_NAME}' with open(os.path.expanduser(os.path.join('~', '.ssh', 'id_rsa.pub'))) as f: @@ -78,26 +90,42 @@ python <<-EOF >"${CLUSTER_NAME}.yaml" config['baseDomain'] = '${DOMAIN}' with open('${PULL_SECRET_PATH}') as f: config['pullSecret'] = f.read() - config['aws']['region'] = '${AWS_REGION}' - config['aws']['extraTags'] = { - 'expirationDate': ( - datetime.datetime.utcnow() + datetime.timedelta(hours=4) - ).strftime('%Y-%m-%dT%H:%M+0000'), - } - if ${CONFIGURE_AWS_ROLES:-False}: - config['aws']['master']['iamRoleName'] = 'tf-tectonic-master-node' - config['aws']['worker']['iamRoleName'] = 'tf-tectonic-worker-node' + if '${BACKEND}' == 'aws': + config['aws']['region'] = '${AWS_REGION}' + config['aws']['extraTags'] = { + 'expirationDate': ( + datetime.datetime.utcnow() + datetime.timedelta(hours=4) + ).strftime('%Y-%m-%dT%H:%M+0000'), + } + if ${CONFIGURE_AWS_ROLES:-False}: + config['aws']['master']['iamRoleName'] = 'tf-tectonic-master-node' + config['aws']['worker']['iamRoleName'] = 'tf-tectonic-worker-node' + elif '${BACKEND}' == 'libvirt': + config['libvirt']['imagePath'] = '${IMAGE_PATH}' yaml.safe_dump(config, sys.stdout) EOF echo -e "\\e[36m Initializing Tectonic...\\e[0m" "${TECTONIC}" init --config="${CLUSTER_NAME}".yaml +trap destroy EXIT + echo -e "\\e[36m Deploying Tectonic...\\e[0m" "${TECTONIC}" install --dir="${CLUSTER_NAME}" echo -e "\\e[36m Running smoke test...\\e[0m" export SMOKE_KUBECONFIG="${PWD}/${CLUSTER_NAME}/generated/auth/kubeconfig" -export SMOKE_NODE_COUNT="5" # Sum of all nodes (master + worker) export SMOKE_MANIFEST_PATHS="${PWD}/${CLUSTER_NAME}/generated" +case "${BACKEND}" in +aws) + export SMOKE_NODE_COUNT=5 # Sum of all nodes (boostrap + master + worker) + ;; +libvirt) + export SMOKE_NODE_COUNT=4 + ;; +esac exec 5>&1 -SMOKE_TEST_OUTPUT=$(./smoke -test.v --cluster | tee >(cat - >&5)) +if test "${LEAVE_RUNNING}" = y; then + echo "leaving running; tear down manually with: cd ${PWD} && installer/tectonic destroy --dir=${CLUSTER_NAME}" + trap - EXIT +fi +SMOKE_TEST_OUTPUT=$(./smoke -test.v --cluster | tee -i >(cat - >&5))