]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/cephfs/test_auto_repair.py
3 Exercise the MDS's auto repair functions
9 from teuthology
.exceptions
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
.wait_for_daemons()
42 # remove testdir1's backtrace
43 self
.fs
.radosm(["rmxattr", dir_objname
, "parent"])
45 # readdir (fetch dirfrag) should fix testdir1's backtrace
46 self
.mount_a
.mount_wait()
47 self
.mount_a
.run_shell(["ls", "testdir1"])
49 # flush journal entries to dirfrag objects
50 self
.fs
.mds_asok(['flush', 'journal'])
52 # check if backtrace exists
53 self
.fs
.radosm(["getxattr", dir_objname
, "parent"])
55 def test_mds_readonly(self
):
57 test if MDS behave correct when it's readonly
59 # operation should successd when MDS is not readonly
60 self
.mount_a
.run_shell(["touch", "test_file1"])
61 writer
= self
.mount_a
.write_background(loop
=True)
64 self
.assertFalse(writer
.finished
)
66 # force MDS to read-only mode
67 self
.fs
.mds_asok(['force_readonly'])
70 # touching test file should fail
72 self
.mount_a
.run_shell(["touch", "test_file1"])
73 except CommandFailedError
:
76 self
.assertTrue(False)
78 # background writer also should fail
79 self
.assertTrue(writer
.finished
)
81 # The MDS should report its readonly health state to the mon
82 self
.wait_for_health("MDS_READ_ONLY", timeout
=30)
84 # restart mds to make it writable
85 self
.fs
.mds_fail_restart()
86 self
.fs
.wait_for_daemons()
88 self
.wait_for_health_clear(timeout
=30)