diff options
author | Varac <varac@leap.se> | 2017-06-29 16:47:54 +0200 |
---|---|---|
committer | Varac <varac@leap.se> | 2017-06-30 17:34:07 +0200 |
commit | 6e7b18f8732e79957aaa2e536b368aef8a9d6ab9 (patch) | |
tree | 81f7d859661a8b0424567aad857487e43c90a367 /tests/platform-ci | |
parent | a3fc434020da4ea8fb447536fd37906ca0a8d890 (diff) |
[CI] Move more commands into functions
Diffstat (limited to 'tests/platform-ci')
-rwxr-xr-x | tests/platform-ci/ci-build.sh | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/tests/platform-ci/ci-build.sh b/tests/platform-ci/ci-build.sh index b554b1d3..abc5fec8 100755 --- a/tests/platform-ci/ci-build.sh +++ b/tests/platform-ci/ci-build.sh @@ -68,6 +68,16 @@ test() { } build_from_scratch() { + # create node(s) with unique id so we can run tests in parallel + NAME="citest${CI_BUILD_ID:-0}" + # when using gitlab-runner locally, CI_BUILD_ID is always 1 which + # will conflict with running/terminating AWS instances in subsequent runs + # therefore we pick a random number in this case + [ "${CI_BUILD_ID:-0}" -eq "1" ] && NAME+="000${RANDOM}" + + TAG='single' + SERVICES='couchdb,soledad,mx,webapp,tor,monitor' + # leap_platform/tests/platform-ci/provider PROVIDERDIR="${ROOTDIR}/provider" /bin/echo "Provider directory: ${PROVIDERDIR}" @@ -130,6 +140,12 @@ run() { test } +cleanup() { + # if everything succeeds, destroy the vm + LEAP_CMD vm rm "${TAG}" + [ -f "nodes/${NAME}.json" ] && /bin/rm "nodes/${NAME}.json" +} + # # Main # @@ -163,21 +179,9 @@ case "$CI_JOB_NAME" in run bitmask ssh://gitolite@leap.se/bitmask ;; *) - # create node(s) with unique id so we can run tests in parallel - NAME="citest${CI_BUILD_ID:-0}" - # when using gitlab-runner locally, CI_BUILD_ID is always 1 which - # will conflict with running/terminating AWS instances in subsequent runs - # therefore we pick a random number in this case - [ "${CI_BUILD_ID:-0}" -eq "1" ] && NAME+="000${RANDOM}" - - TAG='single' - SERVICES='couchdb,soledad,mx,webapp,tor,monitor' build_from_scratch - # Deploy and test deploy test - # if everything succeeds, destroy the vm - LEAP_CMD vm rm "${TAG}" - [ -f "nodes/${NAME}.json" ] && /bin/rm "nodes/${NAME}.json" + cleanup ;; esac |