From 945f4b396680a24a0b5ccb6d14012b3f7b008012 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 22 Oct 2015 12:41:32 +0000 Subject: fix exit codes on error --- leap-platform-test | 51 +++++++++++++++++++++++---------------------------- 1 file 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 -- cgit v1.2.3