]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/cephfs/test_quota.py
2 from tasks
.cephfs
.cephfs_test_case
import CephFSTestCase
4 from teuthology
.exceptions
import CommandFailedError
6 class TestQuota(CephFSTestCase
):
10 def test_remote_update_getfattr(self
):
12 That quota changes made from one client are visible to another
13 client looking at ceph.quota xattrs
15 self
.mount_a
.run_shell(["mkdir", "subdir"])
18 self
.mount_a
.getfattr("./subdir", "ceph.quota.max_files"),
21 self
.mount_b
.getfattr("./subdir", "ceph.quota.max_files"),
24 self
.mount_a
.setfattr("./subdir", "ceph.quota.max_files", "10")
26 self
.mount_a
.getfattr("./subdir", "ceph.quota.max_files"),
29 # Should be visible as soon as setxattr operation completes on
30 # mds (we get here sooner because setfattr gets an early reply)
31 self
.wait_until_equal(
32 lambda: self
.mount_b
.getfattr("./subdir", "ceph.quota.max_files"),
35 def test_remote_update_df(self
):
37 That when a client modifies the quota on a directory used
38 as another client's root, the other client sees the change
39 reflected in their statfs output.
42 self
.mount_b
.umount_wait()
44 self
.mount_a
.run_shell(["mkdir", "subdir"])
46 size_before
= 1024 * 1024 * 128
47 self
.mount_a
.setfattr("./subdir", "ceph.quota.max_bytes",
50 self
.mount_b
.mount(mount_path
="/subdir")
57 "available": size_before
60 size_after
= 1024 * 1024 * 256
61 self
.mount_a
.setfattr("./subdir", "ceph.quota.max_bytes",
64 # Should be visible as soon as setxattr operation completes on
65 # mds (we get here sooner because setfattr gets an early reply)
66 self
.wait_until_equal(
67 lambda: self
.mount_b
.df(),
71 "available": size_after
76 def test_remote_update_write(self
):
78 That when a client modifies the quota on a directory used
79 as another client's root, the other client sees the effect
80 of the change when writing data.
83 self
.mount_a
.run_shell(["mkdir", "subdir_files"])
84 self
.mount_a
.run_shell(["mkdir", "subdir_data"])
86 # Set some nice high quotas that mount_b's initial operations
88 self
.mount_a
.setfattr("./subdir_files", "ceph.quota.max_files", "100")
89 self
.mount_a
.setfattr("./subdir_data", "ceph.quota.max_bytes", "104857600")
91 # Do some writes within my quota
92 self
.mount_b
.create_n_files("subdir_files/file", 20)
93 self
.mount_b
.write_n_mb("subdir_data/file", 20)
95 # Set quotas lower than what mount_b already wrote, it should
96 # refuse to write more once it's seen them
97 self
.mount_a
.setfattr("./subdir_files", "ceph.quota.max_files", "10")
98 self
.mount_a
.setfattr("./subdir_data", "ceph.quota.max_bytes", "1048576")
100 # Do some writes that would have been okay within the old quota,
101 # but are forbidden under the new quota
102 with self
.assertRaises(CommandFailedError
):
103 self
.mount_b
.create_n_files("subdir_files/file", 40)
104 with self
.assertRaises(CommandFailedError
):
105 self
.mount_b
.write_n_mb("subdir_data/file", 40)