diff options
author | Raghavendra Talur <rtalur@redhat.com> | 2015-09-02 18:40:32 +0530 |
---|---|---|
committer | Raghavendra Talur <rtalur@redhat.com> | 2015-09-05 05:10:44 -0700 |
commit | 5b49851601ab53450777438268f0732c65795f98 (patch) | |
tree | 8d1494c7d6432e5b83f15df0fb0401c89660653f /tests/include.rc | |
parent | 378b625698fe01ed2c3a6f4f065a699b2d573947 (diff) |
tests: Reorganise cleanup function
Change-Id: Ifbfb4b05230f023c244760a7d57c33c4463ce6d9
BUG: 1251592
Signed-off-by: Raghavendra Talur <rtalur@redhat.com>
Reviewed-on: http://review.gluster.org/12093
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'tests/include.rc')
-rw-r--r-- | tests/include.rc | 93 |
1 files changed, 57 insertions, 36 deletions
diff --git a/tests/include.rc b/tests/include.rc index 754c8d62423..fb3002d945e 100644 --- a/tests/include.rc +++ b/tests/include.rc @@ -408,20 +408,49 @@ stat -c %s /dev/null > /dev/null 2>&1 || { function cleanup() { - # unmount filesystems before killing daemons to avoid deadllocks - MOUNTPOINTS=`mount | grep "$B0/" | awk '{print $3}'` - for m in $MOUNTPOINTS; - do - umount $m - done - killall -15 glusterfs glusterfsd glusterd 2>/dev/null || true; + # Prepare flags for umount + case `uname -s` in + Linux) + flag="-l" + ;; + NetBSD) + flag="-f -R" + ;; + FreeBSD|Darwin) + flag="-f" + ;; + *) + flag="" + ;; + esac + + # Clean up all client mounts for m in `mount | grep fuse.glusterfs | awk '{print $3}'`; do - umount $m + umount $flag $m done + + # Unmount all well known mount points + umount $flag $M0 2>/dev/null || umount -f $M0 2>/dev/null || true; + umount $flag $M1 2>/dev/null || umount -f $M1 2>/dev/null || true; + umount $flag $M2 2>/dev/null || umount -f $M2 2>/dev/null || true; + umount $flag $N0 2>/dev/null || umount -f $N0 2>/dev/null || true; + umount $flag $N1 2>/dev/null || umount -f $N1 2>/dev/null || true; + + + # unmount all stale mounts from /tmp, This is a temporary work around + # till the stale mount in /tmp is found. + umount $flag /tmp/mnt* 2>/dev/null + + + # Kill all gluster processes with SIGTERM + killall -15 glusterfs glusterfsd glusterd 2>/dev/null || true; test x"$OSTYPE" = x"NetBSD" && pkill -15 perfused rpc.statd || true - # allow completion of signal handlers for SIGTERM before issue SIGKILL + + # Wait a second for SIGTERM to work sleep 1 + + # Send SIGKILL to all gluster processes that are still running killall -9 glusterfs glusterfsd glusterd 2>/dev/null || true; test x"$OSTYPE" = x"NetBSD" && pkill -9 perfused rpc.statd || true @@ -437,8 +466,18 @@ function cleanup() ## nfs_acl rpcinfo -d 100227 3 2>/dev/null || true; + # unmount brick filesystems after killing daemons + MOUNTPOINTS=`mount | grep "$B0/" | awk '{print $3}'` + for m in $MOUNTPOINTS; + do + umount $flag $m + done + + # Cleanup lvm type cleanup_lvm &>/dev/null && cleanup_lvm || true; + # Destroy loop devices + # TODO: This should be a function DESTROY_LOOP case `uname -s` in Linux) LOOPDEVICES=`losetup -a | grep "$B0/" | \ @@ -471,34 +510,16 @@ function cleanup() esac # remove contents of "GLUSTERD_WORKDIR" except hooks directory. - find $GLUSTERD_WORKDIR/* -maxdepth 0 -name 'hooks' -prune \ - -o -exec rm -rf '{}' ';' - - rm -rf $B0/* /etc/glusterd/*; - - # unmount all stale mounts from /tmp, This is a temporary work around - # till the stale mount in /tmp is found. - case `uname -s` in - Linux) - flag="-l" - ;; - NetBSD) - flag="-f -R" - ;; - FreeBSD|Darwin) - flag="-f" - ;; - *) - flag="" - ;; - esac - umount $flag /tmp/mnt* 2>/dev/null - umount $flag $M0 2>/dev/null || umount -f $M0 2>/dev/null || true; - umount $flag $M1 2>/dev/null || umount -f $M1 2>/dev/null || true; - umount $flag $M2 2>/dev/null || umount -f $M2 2>/dev/null || true; - umount $flag $N0 2>/dev/null || umount -f $N0 2>/dev/null || true; - umount $flag $N1 2>/dev/null || umount -f $N1 2>/dev/null || true; + if [ -n $GLUSTERD_WORKDIR ] + then + find $GLUSTERD_WORKDIR/* -maxdepth 0 -name 'hooks' -prune \ + -o -exec rm -rf '{}' ';' + else + echo "GLUSTERD_WORKDIR is not set" + fi + # Complete cleanup time + rm -rf "$B0/*" "/etc/glusterd/*"; rm -rf $WORKDIRS leftover="" for d in $WORKDIRS ; do |