1 from tasks.cephfs.cephfs_test_case import CephFSTestCase
5 class TestDumpTree(CephFSTestCase):
6 def get_paths_to_ino(self):
8 p = self.mount_a.run_shell(["find", "./"])
9 paths = p.stdout.getvalue().strip().split()
11 inos[path] = self.mount_a.path_to_ino(path, False)
16 self.mount_a.run_shell(["git", "clone",
17 "https://github.com/ceph/ceph-qa-suite"])
20 self.mount_a.run_shell(["mkdir", "parent"])
21 self.mount_a.run_shell(["mkdir", "parent/child"])
22 self.mount_a.run_shell(["touch", "parent/child/file"])
23 self.mount_a.run_shell(["mkdir", "parent/child/grandchild"])
24 self.mount_a.run_shell(["touch", "parent/child/grandchild/file"])
26 inos = self.get_paths_to_ino()
27 tree = self.fs.mds_asok(["dump", "tree", "/parent/child", "1"])
29 target_inos = [inos["./parent/child"], inos["./parent/child/file"],
30 inos["./parent/child/grandchild"]]
33 del target_inos[target_inos.index(ino['ino'])] # don't catch!
35 assert(len(target_inos) == 0)
37 def test_random(self):
41 inos = self.get_paths_to_ino()
42 target = random.choice(inos.keys())
45 target = os.path.dirname(target)
47 subtree = [path for path in inos.keys() if path.startswith(target)]
48 target_inos = [inos[path] for path in subtree]
49 tree = self.fs.mds_asok(["dump", "tree", target[1:]])
52 del target_inos[target_inos.index(ino['ino'])] # don't catch!
54 assert(len(target_inos) == 0)
56 target_depth = target.count('/')
57 maxdepth = max([path.count('/') for path in subtree]) - target_depth
58 depth = random.randint(0, maxdepth)
59 target_inos = [inos[path] for path in subtree \
60 if path.count('/') <= depth + target_depth]
61 tree = self.fs.mds_asok(["dump", "tree", target[1:], str(depth)])
64 del target_inos[target_inos.index(ino['ino'])] # don't catch!
66 assert(len(target_inos) == 0)