]> git.proxmox.com Git - ceph.git/blame - ceph/qa/tasks/cephfs/test_cap_flush.py
import 15.2.0 Octopus source
[ceph.git] / ceph / qa / tasks / cephfs / test_cap_flush.py
CommitLineData
7c673cae
FG
1
2import os
3import time
4from textwrap import dedent
7c673cae
FG
5from tasks.cephfs.fuse_mount import FuseMount
6from tasks.cephfs.cephfs_test_case import CephFSTestCase, for_teuthology
7
8class TestCapFlush(CephFSTestCase):
9 @for_teuthology
10 def test_replay_create(self):
11 """
12 MDS starts to handle client caps when it enters clientreplay stage.
13 When handling a client cap in clientreplay stage, it's possible that
14 corresponding inode does not exist because the client request which
15 creates inode hasn't been replayed.
16 """
17
18 if not isinstance(self.mount_a, FuseMount):
9f95a23c 19 self.skipTest("Require FUSE client to inject client release failure")
7c673cae
FG
20
21 dir_path = os.path.join(self.mount_a.mountpoint, "testdir")
22 py_script = dedent("""
23 import os
24 os.mkdir("{0}")
25 fd = os.open("{0}", os.O_RDONLY)
9f95a23c 26 os.fchmod(fd, 0o777)
7c673cae
FG
27 os.fsync(fd)
28 """).format(dir_path)
29 self.mount_a.run_python(py_script)
30
31 self.fs.mds_asok(["flush", "journal"])
32
33 # client will only get unsafe replay
34 self.fs.mds_asok(["config", "set", "mds_log_pause", "1"])
35
36 file_name = "testfile"
37 file_path = dir_path + "/" + file_name
38
39 # Create a file and modify its mode. ceph-fuse will mark Ax cap dirty
40 py_script = dedent("""
41 import os
42 os.chdir("{0}")
43 os.setgid(65534)
44 os.setuid(65534)
9f95a23c
TL
45 fd = os.open("{1}", os.O_CREAT | os.O_RDWR, 0o644)
46 os.fchmod(fd, 0o640)
7c673cae
FG
47 """).format(dir_path, file_name)
48 self.mount_a.run_python(py_script)
49
50 # Modify file mode by different user. ceph-fuse will send a setattr request
51 self.mount_a.run_shell(["chmod", "600", file_path], wait=False)
52
53 time.sleep(10)
54
55 # Restart mds. Client will re-send the unsafe request and cap flush
56 self.fs.mds_stop()
57 self.fs.mds_fail_restart()
58 self.fs.wait_for_daemons()
59
60 mode = self.mount_a.run_shell(['stat', '-c' '%a', file_path]).stdout.getvalue().strip()
61 # If the cap flush get dropped, mode should be 0644.
62 # (Ax cap stays in dirty state, which prevents setattr reply from updating file mode)
63 self.assertEqual(mode, "600")