summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicah Anderson <micah@riseup.net>2015-04-14 16:22:30 -0400
committerMicah Anderson <micah@riseup.net>2015-04-14 16:22:30 -0400
commit995be44621223498a4ef44a40f0e18202448c76a (patch)
tree19f614109f5650aeee11ad4e38a43c7f312d1104
parent4dd2359d8ea62d68fa76ebef25b060c75c6fe5aa (diff)
add a -l/--lock option to ci test script:
if this option is passed, and the lockfile exists, then deploys will not happen and an email will be generated. If it doesn't exist, a deploy will happen and then tests will be run. If the tests fail, the lockfile is set, and will not be removed unless tests pass, or if it is manually removed. I have set this option on the regular cron test, but not on the push to the repository, this makes it so a push to the repository will still allow deploys to happen, and removes the lockfile if tests succeed, otherwise the regular deploys will not happen (allowing us to investigate)
-rwxr-xr-xleap-platform-test23
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"