]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/cephfs/test_auto_repair.py
c0aa2e4c70fae8e085b28a900cd635e8beb86249
3 Exercise the MDS's auto repair functions
9 from teuthology
.orchestra
.run
import CommandFailedError
10 from tasks
.cephfs
.cephfs_test_case
import CephFSTestCase
13 log
= logging
.getLogger(__name__
)
16 # Arbitrary timeouts for operations involving restarting
17 # an MDS or waiting for it to come up
18 MDS_RESTART_GRACE
= 60
21 class TestMDSAutoRepair(CephFSTestCase
):
22 def test_backtrace_repair(self
):
24 MDS should verify/fix backtrace on fetch dirfrag
27 self
.mount_a
.run_shell(["mkdir", "testdir1"])
28 self
.mount_a
.run_shell(["touch", "testdir1/testfile"])
29 dir_objname
= "{:x}.00000000".format(self
.mount_a
.path_to_ino("testdir1"))
32 self
.mount_a
.umount_wait()
34 # flush journal entries to dirfrag objects, and expire journal
35 self
.fs
.mds_asok(['flush', 'journal'])
37 # Restart the MDS to drop the metadata cache (because we expired the journal,
38 # nothing gets replayed into cache on restart)
40 self
.fs
.mds_fail_restart()
41 self
.fs
.wait_for_daemons()
43 # remove testdir1's backtrace
44 self
.fs
.rados(["rmxattr", dir_objname
, "parent"])
46 # readdir (fetch dirfrag) should fix testdir1's backtrace
48 self
.mount_a
.wait_until_mounted()
49 self
.mount_a
.run_shell(["ls", "testdir1"])
51 # flush journal entries to dirfrag objects
52 self
.fs
.mds_asok(['flush', 'journal'])
54 # check if backtrace exists
55 self
.fs
.rados(["getxattr", dir_objname
, "parent"])
57 def test_mds_readonly(self
):
59 test if MDS behave correct when it's readonly
61 # operation should successd when MDS is not readonly
62 self
.mount_a
.run_shell(["touch", "test_file1"])
63 writer
= self
.mount_a
.write_background(loop
=True)
66 self
.assertFalse(writer
.finished
)
68 # force MDS to read-only mode
69 self
.fs
.mds_asok(['force_readonly'])
72 # touching test file should fail
74 self
.mount_a
.run_shell(["touch", "test_file1"])
75 except CommandFailedError
:
78 self
.assertTrue(False)
80 # background writer also should fail
81 self
.assertTrue(writer
.finished
)
83 # The MDS should report its readonly health state to the mon
84 self
.wait_for_health("MDS_READ_ONLY", timeout
=30)
86 # restart mds to make it writable
87 self
.fs
.mds_fail_restart()
88 self
.fs
.wait_for_daemons()
90 self
.wait_for_health_clear(timeout
=30)