]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | |
e306af50 | 2 | from tasks.cephfs.cephfs_test_case import CephFSTestCase |
7c673cae FG |
3 | |
4 | from teuthology.exceptions import CommandFailedError | |
5 | ||
6 | class TestQuota(CephFSTestCase): | |
7 | CLIENTS_REQUIRED = 2 | |
8 | MDSS_REQUIRED = 1 | |
9 | ||
10 | def test_remote_update_getfattr(self): | |
11 | """ | |
12 | That quota changes made from one client are visible to another | |
13 | client looking at ceph.quota xattrs | |
14 | """ | |
15 | self.mount_a.run_shell(["mkdir", "subdir"]) | |
16 | ||
17 | self.assertEqual( | |
18 | self.mount_a.getfattr("./subdir", "ceph.quota.max_files"), | |
19 | None) | |
20 | self.assertEqual( | |
21 | self.mount_b.getfattr("./subdir", "ceph.quota.max_files"), | |
22 | None) | |
23 | ||
24 | self.mount_a.setfattr("./subdir", "ceph.quota.max_files", "10") | |
25 | self.assertEqual( | |
26 | self.mount_a.getfattr("./subdir", "ceph.quota.max_files"), | |
27 | "10") | |
28 | ||
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"), | |
33 | "10", timeout=10) | |
34 | ||
35 | def test_remote_update_df(self): | |
36 | """ | |
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. | |
40 | """ | |
41 | ||
42 | self.mount_b.umount_wait() | |
43 | ||
44 | self.mount_a.run_shell(["mkdir", "subdir"]) | |
45 | ||
46 | size_before = 1024 * 1024 * 128 | |
47 | self.mount_a.setfattr("./subdir", "ceph.quota.max_bytes", | |
48 | "%s" % size_before) | |
49 | ||
f67539c2 | 50 | self.mount_b.mount_wait(cephfs_mntpt="/subdir") |
7c673cae FG |
51 | |
52 | self.assertDictEqual( | |
53 | self.mount_b.df(), | |
54 | { | |
55 | "total": size_before, | |
56 | "used": 0, | |
57 | "available": size_before | |
58 | }) | |
59 | ||
60 | size_after = 1024 * 1024 * 256 | |
61 | self.mount_a.setfattr("./subdir", "ceph.quota.max_bytes", | |
62 | "%s" % size_after) | |
63 | ||
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(), | |
68 | { | |
69 | "total": size_after, | |
70 | "used": 0, | |
71 | "available": size_after | |
72 | }, | |
73 | timeout=10 | |
74 | ) | |
75 | ||
76 | def test_remote_update_write(self): | |
77 | """ | |
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. | |
81 | """ | |
82 | ||
83 | self.mount_a.run_shell(["mkdir", "subdir_files"]) | |
84 | self.mount_a.run_shell(["mkdir", "subdir_data"]) | |
85 | ||
86 | # Set some nice high quotas that mount_b's initial operations | |
87 | # will be well within | |
88 | self.mount_a.setfattr("./subdir_files", "ceph.quota.max_files", "100") | |
89 | self.mount_a.setfattr("./subdir_data", "ceph.quota.max_bytes", "104857600") | |
90 | ||
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) | |
94 | ||
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") | |
99 | ||
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) | |
106 |