Merge lp:~heber013/qa-jenkins-jobs/adding-cleanup-function into lp:qa-jenkins-jobs

Proposed by Heber Parrucci
Status: Merged
Approved by: Heber Parrucci
Approved revision: 281
Merged at revision: 280
Proposed branch: lp:~heber013/qa-jenkins-jobs/adding-cleanup-function
Merge into: lp:qa-jenkins-jobs
Diff against target: 36 lines (+14/-2)
1 file modified
scripts/iso-testing/run-iso-test.sh (+14/-2)
To merge this branch: bzr merge lp:~heber013/qa-jenkins-jobs/adding-cleanup-function
Reviewer Review Type Date Requested Status
Joshua Powers (community) Approve
platform-qa-bot continuous-integration Approve
Jean-Baptiste Lallement Needs Fixing
Review via email: mp+328723@code.launchpad.net

Commit message

Adding trap to clean up VM in case of failures

Description of the change

Adding trap to clean up VM in case of failures

To post a comment you must log in.
Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

Thanks. Comments inline

review: Needs Fixing
Revision history for this message
Jean-Baptiste Lallement (jibel) :
281. By Heber Parrucci

Adding trap to clean up VM in case of failures

Revision history for this message
Heber Parrucci (heber013) wrote :

Comment addressed. Thanks

Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Joshua Powers (powersj) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'scripts/iso-testing/run-iso-test.sh'
2--- scripts/iso-testing/run-iso-test.sh 2017-08-04 12:47:19 +0000
3+++ scripts/iso-testing/run-iso-test.sh 2017-08-08 17:16:25 +0000
4@@ -2,6 +2,20 @@
5
6 set +e
7 set -u
8+set -x
9+
10+on_exit() {
11+ # Exit Handler
12+ if [ -z ${RETCODE} ] || [ ${RETCODE} != 0 ]; then
13+ [ ! -z "$machine_name" ] && [ -d "$SHARED_IMG_PATH"/"$machine_name" ] && sudo rm -rf "$SHARED_IMG_PATH"/"$machine_name"
14+ exit "${RETCODE:=1}"
15+ else
16+ echo SUCCESS!!!!
17+ exit 0
18+ fi
19+}
20+
21+trap on_exit EXIT INT QUIT ABRT PIPE TERM
22
23 usage() {
24 # Display script usage
25@@ -99,11 +113,9 @@
26 # results file
27 [ -n "$(find "$LOG_DIR" -name '*.yaml')" ] && mv "$LOG_DIR"/*.yaml "$WORKSPACE"
28 if [ "$RETCODE" -gt "100" ] ; then # utah client had an error, probably a test failure
29- [ ! -z "$machine_name" ] && [ -d "$SHARED_IMG_PATH"/"$machine_name" ] && sudo rm -rf "$SHARED_IMG_PATH"/"$machine_name"
30 exit $RETCODE
31 elif [ "$RETCODE" -eq "0" ] ; then
32 echo "<testsuite><testcase classname=\"utah\" name=\"utah\"></testcase></testsuite>" > "$WORKSPACE"/utah.xml
33 else
34- [ ! -z "$machine_name" ] && [ -d "$SHARED_IMG_PATH"/"$machine_name" ] && sudo rm -rf "$SHARED_IMG_PATH"/"$machine_name"
35 echo "<testsuite><testcase classname=\"utah\" name=\"utah\"><failure>utah exited with status $RETCODE</failure></testcase></testsuite>" > "$WORKSPACE"/utah.xml
36 fi

Subscribers

People subscribed via source and target branches

to all changes: