|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# To implement this command, edit the "Command implementation" section below. |
| 4 | + |
| 5 | +# Usage |
| 6 | +# ----- |
| 7 | + |
| 8 | +# Comments prefixed with `#/` are managed by stubbs. |
| 9 | +# The `command` and `usage` comments describe the command |
| 10 | +# and show its options. |
| 11 | +# |
| 12 | +#/ command: accept:upgrade: "Tests upgrade path for Deis" |
| 13 | +#/ usage: rerun accept:upgrade --provider <vagrant> --from <> [ --to <master>] [ --skip-cleanup <false>] --upgrade-style <graceful> |
| 14 | + |
| 15 | +# Load common functions |
| 16 | +# --------------------- |
| 17 | + |
| 18 | +# Load the function library for this module. |
| 19 | +# This loads rerun functions, too. |
| 20 | +. $RERUN_MODULE_DIR/lib/functions.sh upgrade || { |
| 21 | + echo >&2 "Failed loading function library." ; exit 1 ; |
| 22 | +} |
| 23 | + |
| 24 | +# Error handling |
| 25 | +# --------------- |
| 26 | + |
| 27 | +# This script is designed to _fail-fast_. |
| 28 | + |
| 29 | +# Trap errors and exit. The call to `rerun_die` will print the |
| 30 | +# the error message and exit with the error command exit status. |
| 31 | + |
| 32 | +trap 'rerun_die $? "*** command failed: tests:upgrade. ***"' ERR |
| 33 | + |
| 34 | +# Run [set] `nounset` to treat unset variables as errors. Set [pipefail] |
| 35 | +# so a pipeline return status is the value of the last |
| 36 | +# (rightmost) command to exit with non-zero status. |
| 37 | +# |
| 38 | +# [set]: http://ss64.com/bash/set.html |
| 39 | +# [pipefail]: http://www.gnu.org/software/bash/manual/html_node/Pipelines.html |
| 40 | + |
| 41 | +set -o nounset -o pipefail |
| 42 | + |
| 43 | +# Command variables |
| 44 | +# ----------------- |
| 45 | + |
| 46 | +# This command script can access the following variables |
| 47 | +# declared by `rerun` or by the option parser function. |
| 48 | + |
| 49 | +#/ rerun-variables: RERUN, RERUN_VERSION, RERUN_MODULES, RERUN_MODULE_DIR |
| 50 | +#/ option-variables: PROVIDER FROM TO SKIP_CLEANUP UPGRADE_STYLE |
| 51 | + |
| 52 | +# The `rerun_options_parse` function processes the command line |
| 53 | +# arguments. Each accepted command line flag results in setting |
| 54 | +# one the corresponding option variables. |
| 55 | + |
| 56 | +rerun_options_parse "$@" |
| 57 | + |
| 58 | +trap destroy-cluster EXIT |
| 59 | + |
| 60 | +# Command implementation |
| 61 | +# ---------------------- |
| 62 | + |
| 63 | +function healthcheck { |
| 64 | + rerun_log "Running healthcheck of previously deployed app.." |
| 65 | + |
| 66 | + if ! curl -s "http://testing.${DEIS_TEST_DOMAIN}" | grep -q "Powered by Deis"; then |
| 67 | + rerun_log error "Failed to pass healthcheck." |
| 68 | + return 1 |
| 69 | + else |
| 70 | + rerun_log info "Healthcheck succeeded." |
| 71 | + return 0 |
| 72 | + fi |
| 73 | +} |
| 74 | + |
| 75 | +setup-provider "${PROVIDER}" |
| 76 | +setup-upgrader "${UPGRADE_STYLE}" |
| 77 | + |
| 78 | +setup-provider-dependencies |
| 79 | + |
| 80 | +destroy-cluster |
| 81 | + |
| 82 | +setup-clients "${FROM}" |
| 83 | + |
| 84 | +make discovery-url |
| 85 | + |
| 86 | +create-cluster |
| 87 | + |
| 88 | +deploy-deis "${FROM}" |
| 89 | + |
| 90 | +make test-smoke |
| 91 | + |
| 92 | +upgrade-deis "${FROM}" "${TO}" |
| 93 | + |
| 94 | +healthcheck |
0 commit comments