From c2e6102955948a5a8f650a7330a257052177b521 Mon Sep 17 00:00:00 2001 From: Erwan Velu Date: Thu, 25 Feb 2016 18:06:17 +0100 Subject: [PATCH] test/ceph_objectstore_tool: Deleting btrfs subvolumes before exiting 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 --- src/test/ceph_objectstore_tool.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/ceph_objectstore_tool.py b/src/test/ceph_objectstore_tool.py index 651326e5c47..20a5d308891 100755 --- a/src/test/ceph_objectstore_tool.py +++ b/src/test/ceph_objectstore_tool.py @@ -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)