From c6d1b9797dd2850cd0b8be7f17a41db525cbe93d Mon Sep 17 00:00:00 2001 From: Jeff Darcy Date: Sun, 10 Apr 2016 10:51:11 -0400 Subject: tests: use trap mechanism to ensure that proper cleanups happen This actually consists of several parts. * Added a generic cleanup-scheduling mechanism. Instead of calling "trap ... EXIT" directly, just call "push_trapfunc ..." instead and your cleanup function will be called along with any others. * Converted a few tests to use push_trapfunc. * Added "push_trapfunc cleanup_lvm" to snapshot.rc to address the particular problem that's driving this - snapshot tests not calling cleanup_lvm on their own and leaving bad state for the next test. Change-Id: I548a97a26328390992fc71ee1f03c0463703f9d7 Signed-off-by: Jeff Darcy Reviewed-on: http://review.gluster.org/13933 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Atin Mukherjee Reviewed-by: Rajesh Joseph --- tests/basic/ec/ec.t | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'tests/basic') diff --git a/tests/basic/ec/ec.t b/tests/basic/ec/ec.t index b07006545b9..f98f2110e8f 100644 --- a/tests/basic/ec/ec.t +++ b/tests/basic/ec/ec.t @@ -1,5 +1,6 @@ #!/bin/bash +. $(dirname $0)/../../traps.rc . $(dirname $0)/../../include.rc . $(dirname $0)/../../volume.rc @@ -155,7 +156,7 @@ function check_perm_file { cleanup TEST useradd -o -M -u ${TEST_UID} ${TEST_USER} -trap "userdel --force ${TEST_USER}" EXIT +push_trapfunc "userdel --force ${TEST_USER}" TEST glusterd TEST pidof glusterd @@ -177,7 +178,7 @@ EXPECT_WITHIN $CHILD_UP_TIMEOUT "10" ec_child_up_count $V0 0 # Create local files for comparisons etc. tmpdir=$(mktemp -d -t ${0##*/}.XXXXXX) -trap "rm -rf $tmpdir" EXIT +push_trapfunc "rm -rf $tmpdir" TEST create_file $tmpdir/create-write 10 TEST create_file $tmpdir/truncate 10 @@ -255,7 +256,4 @@ EXPECT_WITHIN $HEAL_TIMEOUT "Y" check_setxattr $B0/${V0}{0..9} EXPECT_WITHIN $HEAL_TIMEOUT "Y" check_removexattr $B0/${V0}{0..9} EXPECT_WITHIN $HEAL_TIMEOUT "Y" check_perm_file $B0/${V0}{0..9} -TEST rm -rf $tmpdir -TEST userdel --force ${TEST_USER} - cleanup -- cgit