From: Federico Gimenez Date: Wed, 5 Nov 2014 14:58:36 +0000 (+0100) Subject: Fix tests on btrfs: leftover subvolumes removed X-Git-Tag: v0.89~47^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5ac05d46e899781d91cc74ffd18635db4e8e9f65;p=ceph.git Fix tests on btrfs: leftover subvolumes removed Signed-off-by: Federico Gimenez --- diff --git a/src/test/ceph-disk.sh b/src/test/ceph-disk.sh index 3bfbbf45c7ab..3ea3c4b54c0a 100755 --- a/src/test/ceph-disk.sh +++ b/src/test/ceph-disk.sh @@ -15,6 +15,9 @@ # GNU Library Public License for more details. # set -xe + +source test/test_btrfs_common.sh + PS4='${FUNCNAME[0]}: $LINENO: ' export PATH=:$PATH # make sure program from sources are prefered @@ -51,6 +54,10 @@ function setup() { function teardown() { kill_daemons + if [ $(stat -f -c '%T' .) == "btrfs" ]; then + rm -fr $DIR/*/*db + teardown_btrfs $DIR + fi rm -fr $DIR } diff --git a/src/test/mon/mon-test-helpers.sh b/src/test/mon/mon-test-helpers.sh index b37780e42d1b..79de8deaba88 100644 --- a/src/test/mon/mon-test-helpers.sh +++ b/src/test/mon/mon-test-helpers.sh @@ -14,6 +14,8 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library Public License for more details. # +source test/test_btrfs_common.sh + function setup() { local dir=$1 teardown $dir @@ -23,6 +25,9 @@ function setup() { function teardown() { local dir=$1 kill_daemons $dir + if [ $(stat -f -c '%T' .) == "btrfs" ]; then + teardown_btrfs $dir + fi rm -fr $dir } diff --git a/src/test/test_btrfs_common.sh b/src/test/test_btrfs_common.sh new file mode 100644 index 000000000000..c4061041a245 --- /dev/null +++ b/src/test/test_btrfs_common.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# +# Author: Federico Gimenez +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library Public License for more details. +# + +# +# Removes btrfs subvolumes under the given directory param +# +function teardown_btrfs() { + local btrfs_base_dir=$1 + + btrfs_dirs=`ls -l $btrfs_base_dir | egrep '^d' | awk '{print $9}'` + for btrfs_dir in $btrfs_dirs + do + btrfs_subdirs=`ls -l $btrfs_base_dir/$btrfs_dir | egrep '^d' | awk '{print $9}'` + for btrfs_subdir in $btrfs_subdirs + do + btrfs subvolume delete $btrfs_base_dir/$btrfs_dir/$btrfs_subdir + done + done +}