diff options
-rwxr-xr-x | leap-platform-test | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/leap-platform-test b/leap-platform-test index 8894c18..994ec57 100755 --- a/leap-platform-test +++ b/leap-platform-test @@ -90,6 +90,17 @@ check_for_running_instances() { exit 1 fi + if [ -f $lock ] + then + subj="WARNING: CI lock found - previous deploy tests failed !" + msg="CI lock found, and --lock in use. This means that leap test failed on the previous run.\n Please investigate and then remove $LOCKFILE\n\n" + if [ "$MAIL_TO" != '' ]; then + echo "$subj Sending mail to $MAIL_TO:" + sendemail -f "$MAIL_FROM" -t "$MAIL_TO" -o tls=no -m "${msg}" -u "${subj}" + fi + exit 1 + fi + } create_provider() { @@ -382,8 +393,12 @@ run_tests () { if [ "$test_failure" -ne 0 ] then echo 'WARNING - "leap test" failed !' | tee -a "$TEST_LOG1" "$TEST_LOG2" + if $lock ; then + touch $LOCKFILE + fi else echo 'OK - "leap test" is all green !' | tee -a "$TEST_LOG1" "$TEST_LOG2" + rm -f $LOCKFILE fi return "$test_failure" @@ -450,7 +465,7 @@ IP_PREFIX='10.5.5' deploy_failure="/tmp/deploy_failure" [ -e $deploy_failure ] && rm $deploy_failure -if ! options=$(getopt -o avVc:h -l all,verbose,versions,config:,help -- "$@") +if ! options=$(getopt -o avVlc:h -l all,lock,verbose,versions,config:,help -- "$@") then # something went wrong, getopt will put out an error message for us usage @@ -462,9 +477,10 @@ eval set -- "$options" while [ $# -gt 0 ] do case $1 in - -h|--help) usage; exit 1;; - -c|--config) config=$2; shift ;; -a|--all) all=true;; + -c|--config) config=$2; shift ;; + -h|--help) usage; exit 1;; + -l|--lock) lock=true;; -V|--versions) print_versions=true;; (--) shift; break;; (-*) echo "$0: error - unrecognized option $1" 1>&2; exit 1;; @@ -499,6 +515,7 @@ date=$( date +"%F-%H%M%S" ) TEST_LOG1="$LOGDIR/test.log" TEST_LOG2="$LOGDIR/test-$date.log" +LOCKFILE=/var/log/leap_ci_deploy_lock [ -e "$PROVIDERDIR" ] && cd "$PROVIDERDIR" |