diff options
author | Prasanna Kumar Kalever <prasanna.kalever@redhat.com> | 2015-08-11 13:45:26 +0530 |
---|---|---|
committer | Raghavendra Talur <rtalur@redhat.com> | 2015-08-13 12:16:43 -0700 |
commit | db4e3a371c66c400b3cb95d4e7701625bef4ac95 (patch) | |
tree | d4425de0cf6f62e297007eef9378340895fa9067 | |
parent | 0ad26041fbf65ab36856a0ad178c32e51bf87319 (diff) |
tests: call cleanup on receiving external signals INT, TERM and HUP
problem:
when executing testcases manually, some time we may want to terminate the
testcase execution in between due to various reasons.
Existing testcase flow has no mechanism to call cleanup before they terminate
abnormally, hence we endup with volume setups and mount points uncleaned.
Solution:
This patch traps such kind of abnormal terminations and calls 'cleanup'
function soon after they are caught and then terminates the testcases
with appropriate status..
$ ./tests/basic/mount-nfs-auth.t
1..87
=========================
TEST 1 (line 8): glusterd
ok 1
RESULT 1: 0
=========================
TEST 2 (line 9): pidof glusterd
ok 2
RESULT 2: 0
=========================
TEST 3 (line 10): gluster -mode=script --wignore volume info
No volumes present
ok 3
RESULT 3: 0
^C
received external signal --INT--, calling 'cleanup' ...
$ glusterd && gluster vol status
No volumes present
Change-Id: Ia51a850c356e599b8b789cec22b9bb5e87e1548a
BUG: 1252374
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-on: http://review.gluster.org/11882
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Raghavendra Talur <rtalur@redhat.com>
-rw-r--r-- | tests/include.rc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/include.rc b/tests/include.rc index bf480c22bdb..1d084c03357 100644 --- a/tests/include.rc +++ b/tests/include.rc @@ -525,6 +525,16 @@ function cleanup() return 0 } +function force_terminate () { + local ret=$?; + >&2 echo -e "\nreceived external"\ + "signal --`kill -l $ret`--, calling 'cleanup' ...\n"; + cleanup; + exit $ret; +} + +trap force_terminate INT TERM HUP + function volinfo_field() { local vol=$1; |