]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/cephfs/test_admin.py
3 from teuthology
.orchestra
.run
import CommandFailedError
5 from tasks
.cephfs
.cephfs_test_case
import CephFSTestCase
6 from tasks
.cephfs
.fuse_mount
import FuseMount
8 from tasks
.cephfs
.filesystem
import FileLayout
11 class TestAdminCommands(CephFSTestCase
):
13 Tests for administration command.
19 def test_fs_status(self
):
21 That `ceph fs status` command functions.
24 s
= self
.fs
.mon_manager
.raw_cluster_cmd("fs", "status")
25 self
.assertTrue("active" in s
)
27 mdsmap
= json
.loads(self
.fs
.mon_manager
.raw_cluster_cmd("fs", "status", "--format=json-pretty"))["mdsmap"]
28 self
.assertEqual(mdsmap
[0]["state"], "active")
30 mdsmap
= json
.loads(self
.fs
.mon_manager
.raw_cluster_cmd("fs", "status", "--format=json"))["mdsmap"]
31 self
.assertEqual(mdsmap
[0]["state"], "active")
33 def _setup_ec_pools(self
, n
, metadata
=True, overwrites
=True):
35 self
.fs
.mon_manager
.raw_cluster_cmd('osd', 'pool', 'create', n
+"-meta", "8")
36 cmd
= ['osd', 'erasure-code-profile', 'set', n
+"-profile", "m=2", "k=2", "crush-failure-domain=osd"]
37 self
.fs
.mon_manager
.raw_cluster_cmd(*cmd
)
38 self
.fs
.mon_manager
.raw_cluster_cmd('osd', 'pool', 'create', n
+"-data", "8", "erasure", n
+"-profile")
40 self
.fs
.mon_manager
.raw_cluster_cmd('osd', 'pool', 'set', n
+"-data", 'allow_ec_overwrites', 'true')
42 def _check_pool_application_metadata_key_value(self
, pool
, app
, key
, value
):
43 output
= self
.fs
.mon_manager
.raw_cluster_cmd(
44 'osd', 'pool', 'application', 'get', pool
, app
, key
)
45 self
.assertEqual(str(output
.strip()), value
)
47 def test_add_data_pool_root(self
):
49 That a new data pool can be added and used for the root directory.
52 p
= self
.fs
.add_data_pool("foo")
53 self
.fs
.set_dir_layout(self
.mount_a
, ".", FileLayout(pool
=p
))
55 def test_add_data_pool_application_metadata(self
):
57 That the application metadata set on a newly added data pool is as expected.
60 mon_cmd
= self
.fs
.mon_manager
.raw_cluster_cmd
61 mon_cmd('osd', 'pool', 'create', pool_name
, str(self
.fs
.pgs_per_fs_pool
))
62 # Check whether https://tracker.ceph.com/issues/43061 is fixed
63 mon_cmd('osd', 'pool', 'application', 'enable', pool_name
, 'cephfs')
64 self
.fs
.add_data_pool(pool_name
, create
=False)
65 self
._check
_pool
_application
_metadata
_key
_value
(
66 pool_name
, 'cephfs', 'data', self
.fs
.name
)
68 def test_add_data_pool_subdir(self
):
70 That a new data pool can be added and used for a sub-directory.
73 p
= self
.fs
.add_data_pool("foo")
74 self
.mount_a
.run_shell("mkdir subdir")
75 self
.fs
.set_dir_layout(self
.mount_a
, "subdir", FileLayout(pool
=p
))
77 def test_add_data_pool_non_alphamueric_name_as_subdir(self
):
79 That a new data pool with non-alphanumeric name can be added and used for a sub-directory.
81 p
= self
.fs
.add_data_pool("I-am-data_pool00.")
82 self
.mount_a
.run_shell("mkdir subdir")
83 self
.fs
.set_dir_layout(self
.mount_a
, "subdir", FileLayout(pool
=p
))
85 def test_add_data_pool_ec(self
):
87 That a new EC data pool can be added.
90 n
= "test_add_data_pool_ec"
91 self
._setup
_ec
_pools
(n
, metadata
=False)
92 p
= self
.fs
.add_data_pool(n
+"-data", create
=False)
94 def test_new_default_ec(self
):
96 That a new file system warns/fails with an EC default data pool.
99 self
.fs
.delete_all_filesystems()
100 n
= "test_new_default_ec"
101 self
._setup
_ec
_pools
(n
)
103 self
.fs
.mon_manager
.raw_cluster_cmd('fs', 'new', n
, n
+"-meta", n
+"-data")
104 except CommandFailedError
as e
:
105 if e
.exitstatus
== 22:
110 raise RuntimeError("expected failure")
112 def test_new_default_ec_force(self
):
114 That a new file system succeeds with an EC default data pool with --force.
117 self
.fs
.delete_all_filesystems()
118 n
= "test_new_default_ec_force"
119 self
._setup
_ec
_pools
(n
)
120 self
.fs
.mon_manager
.raw_cluster_cmd('fs', 'new', n
, n
+"-meta", n
+"-data", "--force")
122 def test_new_default_ec_no_overwrite(self
):
124 That a new file system fails with an EC default data pool without overwrite.
127 self
.fs
.delete_all_filesystems()
128 n
= "test_new_default_ec_no_overwrite"
129 self
._setup
_ec
_pools
(n
, overwrites
=False)
131 self
.fs
.mon_manager
.raw_cluster_cmd('fs', 'new', n
, n
+"-meta", n
+"-data")
132 except CommandFailedError
as e
:
133 if e
.exitstatus
== 22:
138 raise RuntimeError("expected failure")
139 # and even with --force !
141 self
.fs
.mon_manager
.raw_cluster_cmd('fs', 'new', n
, n
+"-meta", n
+"-data", "--force")
142 except CommandFailedError
as e
:
143 if e
.exitstatus
== 22:
148 raise RuntimeError("expected failure")
150 def test_fs_new_pool_application_metadata(self
):
152 That the application metadata set on the pools of a newly created filesystem are as expected.
154 self
.fs
.delete_all_filesystems()
155 fs_name
= "test_fs_new_pool_application"
156 keys
= ['metadata', 'data']
157 pool_names
= [fs_name
+'-'+key
for key
in keys
]
158 mon_cmd
= self
.fs
.mon_manager
.raw_cluster_cmd
160 mon_cmd('osd', 'pool', 'create', p
, str(self
.fs
.pgs_per_fs_pool
))
161 mon_cmd('osd', 'pool', 'application', 'enable', p
, 'cephfs')
162 mon_cmd('fs', 'new', fs_name
, pool_names
[0], pool_names
[1])
164 self
._check
_pool
_application
_metadata
_key
_value
(
165 pool_names
[i
], 'cephfs', keys
[i
], fs_name
)
168 class TestConfigCommands(CephFSTestCase
):
170 Test that daemons and clients respond to the otherwise rarely-used
171 runtime config modification operations.
177 def test_ceph_config_show(self
):
179 That I can successfully show MDS configuration.
182 names
= self
.fs
.get_rank_names()
184 s
= self
.fs
.mon_manager
.raw_cluster_cmd("config", "show", "mds."+n
)
185 self
.assertTrue("NAME" in s
)
186 self
.assertTrue("mon_host" in s
)
188 def test_client_config(self
):
190 That I can successfully issue asok "config set" commands
195 if not isinstance(self
.mount_a
, FuseMount
):
196 self
.skipTest("Test only applies to FUSE clients")
198 test_key
= "client_cache_size"
200 self
.mount_a
.admin_socket(['config', 'set', test_key
, test_val
])
201 out
= self
.mount_a
.admin_socket(['config', 'get', test_key
])
202 self
.assertEqual(out
[test_key
], test_val
)
204 self
.mount_a
.write_n_mb("file.bin", 1);
206 # Implicitly asserting that things don't have lockdep error in shutdown
207 self
.mount_a
.umount_wait(require_clean
=True)
210 def test_mds_config_asok(self
):
211 test_key
= "mds_max_purge_ops"
213 self
.fs
.mds_asok(['config', 'set', test_key
, test_val
])
214 out
= self
.fs
.mds_asok(['config', 'get', test_key
])
215 self
.assertEqual(out
[test_key
], test_val
)
217 # Implicitly asserting that things don't have lockdep error in shutdown
218 self
.mount_a
.umount_wait(require_clean
=True)
221 def test_mds_config_tell(self
):
222 test_key
= "mds_max_purge_ops"
225 mds_id
= self
.fs
.get_lone_mds_id()
226 self
.fs
.mon_manager
.raw_cluster_cmd("tell", "mds.{0}".format(mds_id
), "injectargs",
227 "--{0}={1}".format(test_key
, test_val
))
229 # Read it back with asok because there is no `tell` equivalent
230 out
= self
.fs
.mds_asok(['config', 'get', test_key
])
231 self
.assertEqual(out
[test_key
], test_val
)
233 # Implicitly asserting that things don't have lockdep error in shutdown
234 self
.mount_a
.umount_wait(require_clean
=True)