summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root@greyhound.leap.se>2015-10-22 12:41:32 +0000
committerroot <root@greyhound.leap.se>2015-10-22 12:41:32 +0000
commit945f4b396680a24a0b5ccb6d14012b3f7b008012 (patch)
tree15f5add49483cc5e6618579a11ecb9ae81b3ea3e
parentb6da29b83b6b3d3a572b13b6744b6bbe9b05b8c5 (diff)
fix exit codes on error
-rwxr-xr-xleap-platform-test51
1 files changed, 23 insertions, 28 deletions
diff --git a/leap-platform-test b/leap-platform-test
index 3f0278f..8024ac7 100755
--- a/leap-platform-test
+++ b/leap-platform-test
@@ -89,7 +89,6 @@ bootstrap_nodes() {
cleanup () {
echo "cleaning up..."
[ -e $LOCKFILE ] && rm $LOCKFILE
- exit
}
@@ -146,6 +145,7 @@ create_provider() {
deploy() {
+ returncode=0
# we need to deploy with verbose level 2, and filter out unwanted stuff
# until puppet errors show up in verbose level 0 +1 (#1750)
FILTER_CLI='= read|= loading|= no change| - executing| = executing| = applying| = ran git| = checking| = synching| = skipping file_path| - cd .*; rsync -| - hiera| = created hiera/| = updated hiera/| = updated secrets.json| - cd /root/| - rolling backexecuting| - files/|\[bin,tests,puppet\] ->|] Hostname updated.| = Updating submodule puppet/modules|Warning: Permanently added.*to the list of known hosts.| = leap command v| = leap platform v| - \[.*\] ok| - \[.*\] STARTING APPLY| - \[.*\] APPLY COMPLETE|net.ssh.authentication.agent.*could not connect to ssh-agent'
@@ -176,6 +176,7 @@ deploy() {
if [ -s "$ERRLOG1" ]
then
touch $FAILURE_LOCKFILE
+ returncode=1
versions=$( versions )
subj="WARNING - \"leap deploy\" of platform $PLATFORM_BRANCH branch on \"$vm\" had errors !"
echo "$( date ): $msg" | tee -a "$LOG1" "$LOG2" "$ERRLOG2"
@@ -198,6 +199,7 @@ deploy() {
rm "$ERRLOG1"
fi
done
+ return $returncode
}
get_ip () {
@@ -303,6 +305,7 @@ init_deploy() {
}
reset_deploy() {
+ returncode=0
# reset_deploy tests that a deploy works after the node has been reset to
# the bootstrap_nodes() state it does not re-run bootstrap_nodes(), so a
# 'leap node init' is not run again, this is usually sufficient. The
@@ -312,8 +315,7 @@ reset_deploy() {
#. reset the nodes to their saved state (saved is after bootstrap_nodes has
# been run)
#. deploy the nodes
- #. run tests
- #. send email
+ #. send email if MAIL_TO is set
local nodes="$*"
@@ -344,14 +346,12 @@ reset_deploy() {
echo "Waiting until last deploy process has finished..."
wait
- # send mail if deployment fails
- deploy_failure_email
-
- # run tests
- run_tests
-
- # send mail if tests fail
- test_failure_email
+ if [ -e "$FAILURE_LOCKFILE" ]
+ then
+ deploy_failure_email
+ returncode=1
+ fi
+ return $returncode
}
destroy_deploy() {
@@ -362,7 +362,6 @@ destroy_deploy() {
#. run bootstrap_nodes (this will: start vm, run init, run a limited tag
# deploy, then reset the node)
#. deploy the nodes
- #. run tests
#. send email
@@ -395,15 +394,12 @@ destroy_deploy() {
echo "Waiting until last deploy process has finished..."
wait
- # send mail if deployment fails
- deploy_failure_email
-
- # run tests
- run_tests
-
- # send mail if tests fail
- test_failure_email
-
+ if [ -e "$FAILURE_LOCKFILE" ]
+ then
+ deploy_failure_email
+ returncode=1
+ fi
+ return $returncode
}
ssh_up () {
@@ -428,8 +424,7 @@ run_tests () {
else
echo 'OK - "leap test" is all green !' | tee -a "$TEST_LOG1" "$TEST_LOG2"
fi
- return "$test_failure"
-
+ return $test_failure
}
update_leap_cli () {
@@ -533,11 +528,6 @@ cmd=$1
shift
nodelist="$*"
-#echo "config: $config"
-#echo "cmd: $cmd"
-#echo "nodelist: $nodelist"
-#echo "all: $all"
-
if [ -z "$config" ]
then
usage
@@ -559,6 +549,7 @@ LOCKFILE_DIR="/var/run/lock/leap_ci/${PLATFORM_BRANCH}"
[ -e $LOCKFILE_DIR ] || mkdir -p $LOCKFILE_DIR
LOCKFILE="${LOCKFILE_DIR}/$(basename $0).lock"
FAILURE_LOCKFILE="${LOCKFILE_DIR}/failure.lock"
+exitcode=0
check_for_running_instances || exit $?
@@ -608,4 +599,8 @@ case $cmd in
(*) usage; echo "Please specify a command."; exit 1;;
esac
+exitcode=$?
+
cleanup
+
+exit $exitcode