]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Fix tests on btrfs: leftover subvolumes removed 2869/head
authorFederico Gimenez <fgimenez@coit.es>
Wed, 5 Nov 2014 14:58:36 +0000 (15:58 +0100)
committerFederico Gimenez Nieto <fgimenez@coit.es>
Thu, 6 Nov 2014 12:59:01 +0000 (13:59 +0100)
Signed-off-by: Federico Gimenez <fgimenez@coit.es>
src/test/ceph-disk.sh
src/test/mon/mon-test-helpers.sh
src/test/test_btrfs_common.sh [new file with mode: 0644]

index 3bfbbf45c7abe4fd59d32a9edaa43a7bee225c6d..3ea3c4b54c0a8aec923c513f1b2791b823399685 100755 (executable)
@@ -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
 }
 
index b37780e42d1b15b56f9f08b2d30f2a7669dc8c39..79de8deaba88f88cef2ea8704e4894d3aaa5eebe 100644 (file)
@@ -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 (file)
index 0000000..c406104
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/bash 
+#
+# Author: Federico Gimenez <fgimenez@coit.es>
+#
+# 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
+}