]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/cephfs/test_subvolume.py
3 from tasks
.cephfs
.cephfs_test_case
import CephFSTestCase
4 from teuthology
.exceptions
import CommandFailedError
6 log
= logging
.getLogger(__name__
)
9 class TestSubvolume(CephFSTestCase
):
23 self
.mount_a
.run_shell(['mkdir', 'group'])
24 self
.mount_a
.run_shell(['mkdir', 'group/subvol1'])
25 self
.mount_a
.run_shell(['setfattr', '-n', 'ceph.dir.subvolume',
26 '-v', '1', 'group/subvol1'])
27 self
.mount_a
.run_shell(['mv', 'group/subvol1', 'group/subvol2'])
29 def cleanup_test(self
):
30 self
.mount_a
.run_shell(['rm', '-rf', 'group'])
32 def test_subvolume_move_out_file(self
):
34 To verify that file can't be moved out of subvolume
36 self
.mount_a
.run_shell(['touch', 'group/subvol2/file1'])
38 # file can't be moved out of a subvolume
39 with self
.assertRaises(CommandFailedError
):
40 self
.mount_a
.run_shell(['rename', 'group/subvol2/file1',
41 'group/file1', 'group/subvol2/file1'])
44 def test_subvolume_move_in_file(self
):
46 To verify that file can't be moved into subvolume
48 # file can't be moved into a subvolume
49 self
.mount_a
.run_shell(['touch', 'group/file2'])
50 with self
.assertRaises(CommandFailedError
):
51 self
.mount_a
.run_shell(['rename', 'group/file2',
52 'group/subvol2/file2', 'group/file2'])
54 def test_subvolume_hardlink_to_outside(self
):
56 To verify that file can't be hardlinked to outside subvolume
58 self
.mount_a
.run_shell(['touch', 'group/subvol2/file1'])
60 # create hard link within subvolume
61 self
.mount_a
.run_shell(['ln',
62 'group/subvol2/file1', 'group/subvol2/file1_'])
64 # hard link can't be created out of subvolume
65 with self
.assertRaises(CommandFailedError
):
66 self
.mount_a
.run_shell(['ln',
67 'group/subvol2/file1', 'group/file1_'])
69 def test_subvolume_hardlink_to_inside(self
):
71 To verify that file can't be hardlinked to inside subvolume
73 self
.mount_a
.run_shell(['touch', 'group/subvol2/file1'])
75 # create hard link within subvolume
76 self
.mount_a
.run_shell(['ln',
77 'group/subvol2/file1', 'group/subvol2/file1_'])
79 # hard link can't be created inside subvolume
80 self
.mount_a
.run_shell(['touch', 'group/file2'])
81 with self
.assertRaises(CommandFailedError
):
82 self
.mount_a
.run_shell(['ln',
83 'group/file2', 'group/subvol2/file2_'])
85 def test_subvolume_snapshot_inside_subvolume_subdir(self
):
87 To verify that snapshot can't be taken for a subvolume subdir
89 self
.mount_a
.run_shell(['touch', 'group/subvol2/file1'])
91 # create snapshot at subvolume root
92 self
.mount_a
.run_shell(['mkdir', 'group/subvol2/.snap/s1'])
94 # can't create snapshot in a descendent dir of subvolume
95 self
.mount_a
.run_shell(['mkdir', 'group/subvol2/dir'])
96 with self
.assertRaises(CommandFailedError
):
97 self
.mount_a
.run_shell(['mkdir', 'group/subvol2/dir/.snap/s2'])
100 self
.mount_a
.run_shell(['rmdir', 'group/subvol2/.snap/s1'])
102 def test_subvolume_file_move_across_subvolumes(self
):
104 To verify that file can't be moved across subvolumes
106 self
.mount_a
.run_shell(['touch', 'group/subvol2/file1'])
108 # create another subvol
109 self
.mount_a
.run_shell(['mkdir', 'group/subvol3'])
110 self
.mount_a
.run_shell(['setfattr', '-n', 'ceph.dir.subvolume',
111 '-v', '1', 'group/subvol3'])
113 # can't move file across subvolumes
114 with self
.assertRaises(CommandFailedError
):
115 self
.mount_a
.run_shell(['rename', 'group/subvol2/file1',
116 'group/subvol3/file1',
117 'group/subvol2/file1'])
119 def test_subvolume_hardlink_across_subvolumes(self
):
121 To verify that hardlink can't be created across subvolumes
123 self
.mount_a
.run_shell(['touch', 'group/subvol2/file1'])
125 # create another subvol
126 self
.mount_a
.run_shell(['mkdir', 'group/subvol3'])
127 self
.mount_a
.run_shell(['setfattr', '-n', 'ceph.dir.subvolume',
128 '-v', '1', 'group/subvol3'])
130 # can't create hard link across subvolumes
131 with self
.assertRaises(CommandFailedError
):
132 self
.mount_a
.run_shell(['ln', 'group/subvol2/file1',
133 'group/subvol3/file1'])
135 def test_subvolume_create_subvolume_inside_subvolume(self
):
137 To verify that subvolume can't be created inside a subvolume
139 # can't create subvolume inside a subvolume
140 self
.mount_a
.run_shell(['mkdir', 'group/subvol2/dir'])
141 with self
.assertRaises(CommandFailedError
):
142 self
.mount_a
.run_shell(['setfattr', '-n', 'ceph.dir.subvolume',
143 '-v', '1', 'group/subvol2/dir'])
145 def test_subvolume_create_snapshot_inside_new_subvolume_parent(self
):
147 To verify that subvolume can't be created inside a new subvolume parent
149 self
.mount_a
.run_shell(['touch', 'group/subvol2/file1'])
151 # clear subvolume flag
152 self
.mount_a
.run_shell(['setfattr', '-n', 'ceph.dir.subvolume',
153 '-v', '0', 'group/subvol2'])
156 self
.mount_a
.run_shell(['mkdir', 'group/subvol2/dir'])
157 self
.mount_a
.run_shell(['mkdir', 'group/subvol2/dir/.snap/s2'])
159 # override subdir subvolume with parent subvolume
160 self
.mount_a
.run_shell(['setfattr', '-n', 'ceph.dir.subvolume',
161 '-v', '1', 'group/subvol2/dir'])
162 self
.mount_a
.run_shell(['setfattr', '-n', 'ceph.dir.subvolume',
163 '-v', '1', 'group/subvol2'])
165 # can't create a snap in a subdir of a subvol parent
166 with self
.assertRaises(CommandFailedError
):
167 self
.mount_a
.run_shell(['mkdir', 'group/subvol2/dir/.snap/s3'])
170 self
.mount_a
.run_shell(['rmdir', 'group/subvol2/dir/.snap/s2'])