]> git.proxmox.com Git - ceph.git/blame - ceph/qa/tasks/cephfs/test_exports.py
update sources to v12.1.3
[ceph.git] / ceph / qa / tasks / cephfs / test_exports.py
CommitLineData
7c673cae
FG
1import logging
2import time
3from tasks.cephfs.fuse_mount import FuseMount
4from tasks.cephfs.cephfs_test_case import CephFSTestCase
5
6log = logging.getLogger(__name__)
7
8class TestExports(CephFSTestCase):
31f18b77
FG
9 MDSS_REQUIRED = 2
10
7c673cae
FG
11 def _wait_subtrees(self, status, rank, test):
12 timeout = 30
13 pause = 2
14 test = sorted(test)
15 for i in range(timeout/pause):
16 subtrees = self.fs.mds_asok(["get", "subtrees"], mds_id=status.get_rank(self.fs.id, rank)['name'])
17 subtrees = filter(lambda s: s['dir']['path'].startswith('/'), subtrees)
7c673cae 18 filtered = sorted([(s['dir']['path'], s['auth_first']) for s in subtrees])
31f18b77 19 log.info("%s =?= %s", filtered, test)
7c673cae 20 if filtered == test:
d2e6a577
FG
21 # Confirm export_pin in output is correct:
22 for s in subtrees:
23 self.assertTrue(s['export_pin'] == s['auth_first'])
7c673cae
FG
24 return subtrees
25 time.sleep(pause)
26 raise RuntimeError("rank {0} failed to reach desired subtree state", rank)
27
28 def test_export_pin(self):
7c673cae 29 self.fs.set_max_mds(2)
224ce89b 30 self.fs.wait_for_daemons()
7c673cae
FG
31
32 status = self.fs.status()
33
34 self.mount_a.run_shell(["mkdir", "-p", "1/2/3"])
35 self._wait_subtrees(status, 0, [])
36
37 # NOP
31f18b77 38 self.mount_a.setfattr("1", "ceph.dir.pin", "-1")
7c673cae
FG
39 self._wait_subtrees(status, 0, [])
40
41 # NOP (rank < -1)
31f18b77 42 self.mount_a.setfattr("1", "ceph.dir.pin", "-2341")
7c673cae
FG
43 self._wait_subtrees(status, 0, [])
44
45 # pin /1 to rank 1
31f18b77 46 self.mount_a.setfattr("1", "ceph.dir.pin", "1")
7c673cae
FG
47 self._wait_subtrees(status, 1, [('/1', 1)])
48
49 # Check export_targets is set properly
50 status = self.fs.status()
51 log.info(status)
52 r0 = status.get_rank(self.fs.id, 0)
53 self.assertTrue(sorted(r0['export_targets']) == [1])
54
55 # redundant pin /1/2 to rank 1
31f18b77 56 self.mount_a.setfattr("1/2", "ceph.dir.pin", "1")
7c673cae
FG
57 self._wait_subtrees(status, 1, [('/1', 1), ('/1/2', 1)])
58
59 # change pin /1/2 to rank 0
31f18b77 60 self.mount_a.setfattr("1/2", "ceph.dir.pin", "0")
7c673cae
FG
61 self._wait_subtrees(status, 1, [('/1', 1), ('/1/2', 0)])
62 self._wait_subtrees(status, 0, [('/1', 1), ('/1/2', 0)])
63
64 # change pin /1/2/3 to (presently) non-existent rank 2
31f18b77 65 self.mount_a.setfattr("1/2/3", "ceph.dir.pin", "2")
7c673cae
FG
66 self._wait_subtrees(status, 0, [('/1', 1), ('/1/2', 0)])
67 self._wait_subtrees(status, 1, [('/1', 1), ('/1/2', 0)])
68
69 # change pin /1/2 back to rank 1
31f18b77 70 self.mount_a.setfattr("1/2", "ceph.dir.pin", "1")
7c673cae
FG
71 self._wait_subtrees(status, 1, [('/1', 1), ('/1/2', 1)])
72
73 # add another directory pinned to 1
74 self.mount_a.run_shell(["mkdir", "-p", "1/4/5"])
31f18b77 75 self.mount_a.setfattr("1/4/5", "ceph.dir.pin", "1")
7c673cae
FG
76 self._wait_subtrees(status, 1, [('/1', 1), ('/1/2', 1), ('/1/4/5', 1)])
77
78 # change pin /1 to 0
31f18b77 79 self.mount_a.setfattr("1", "ceph.dir.pin", "0")
7c673cae
FG
80 self._wait_subtrees(status, 0, [('/1', 0), ('/1/2', 1), ('/1/4/5', 1)])
81
82 # change pin /1/2 to default (-1); does the subtree root properly respect it's parent pin?
31f18b77 83 self.mount_a.setfattr("1/2", "ceph.dir.pin", "-1")
7c673cae
FG
84 self._wait_subtrees(status, 0, [('/1', 0), ('/1/4/5', 1)])
85
86 if len(list(status.get_standbys())):
87 self.fs.set_max_mds(3)
88 self.fs.wait_for_state('up:active', rank=2)
89 self._wait_subtrees(status, 0, [('/1', 0), ('/1/4/5', 1), ('/1/2/3', 2)])
90
91 # Check export_targets is set properly
92 status = self.fs.status()
93 log.info(status)
94 r0 = status.get_rank(self.fs.id, 0)
95 self.assertTrue(sorted(r0['export_targets']) == [1,2])
96 r1 = status.get_rank(self.fs.id, 1)
97 self.assertTrue(sorted(r1['export_targets']) == [0])
98 r2 = status.get_rank(self.fs.id, 2)
99 self.assertTrue(sorted(r2['export_targets']) == [])
100
101 # Test rename
102 self.mount_a.run_shell(["mkdir", "-p", "a/b", "aa/bb"])
31f18b77
FG
103 self.mount_a.setfattr("a", "ceph.dir.pin", "1")
104 self.mount_a.setfattr("aa/bb", "ceph.dir.pin", "0")
7c673cae
FG
105 self._wait_subtrees(status, 0, [('/1', 0), ('/1/4/5', 1), ('/1/2/3', 2), ('/a', 1), ('/aa/bb', 0)])
106 self.mount_a.run_shell(["mv", "aa", "a/b/"])
107 self._wait_subtrees(status, 0, [('/1', 0), ('/1/4/5', 1), ('/1/2/3', 2), ('/a', 1), ('/a/b/aa/bb', 0)])