]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/ceph_objectstore_tool: Deleting btrfs subvolumes before exiting 7805/head
authorErwan Velu <erwan@redhat.com>
Thu, 25 Feb 2016 17:06:17 +0000 (18:06 +0100)
committerErwan Velu <erwan@redhat.com>
Thu, 25 Feb 2016 17:14:32 +0000 (18:14 +0100)
When running the ceph_objectstore_tool test suite, we shall delete the btrfs
subvolumes that have been created before trying deleting the content unless that will generate a permission denied
issue.

Signed-off-by: Erwan Velu <erwan@redhat.com>
src/test/ceph_objectstore_tool.py

index 651326e5c4785d167604d08d05f3125ad6a4bbc1..20a5d3088918d4925922415044eba2765d1eae8f 100755 (executable)
@@ -1857,11 +1857,27 @@ def main(argv):
         print "TEST FAILED WITH {errcount} ERRORS".format(errcount=ERRORS)
         return 1
 
+
+def remove_btrfs_subvolumes(path):
+    result = subprocess.Popen("stat -f -c '%%T' %s" % path, shell=True, stdout=subprocess.PIPE)
+    filesystem = result.stdout.readlines()[0]
+    if filesystem.rstrip('\n') == "btrfs":
+        result = subprocess.Popen("btrfs subvolume list %s" % path, shell=True, stdout=subprocess.PIPE)
+        for line in result.stdout.readlines():
+            subvolume=line.split()[8]
+            # extracting the relative volume name
+            m = re.search(".*(%s.*)" % path, subvolume)
+            if m:
+                found = m.group(1)
+                call("btrfs subvolume delete %s" % found, shell=True)
+
+
 if __name__ == "__main__":
     status = 1
     try:
         status = main(sys.argv[1:])
     finally:
         kill_daemons()
+        remove_btrfs_subvolumes(CEPH_DIR)
         call("/bin/rm -fr {dir}".format(dir=CEPH_DIR), shell=True)
     sys.exit(status)