]> git.proxmox.com Git - ceph.git/blob - ceph/src/test/pybind/test_ceph_argparse.py
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / test / pybind / test_ceph_argparse.py
1 #!/usr/bin/env nosetests
2 # -*- mode:python; tab-width:4; indent-tabs-mode:t; coding:utf-8 -*-
3 # vim: ts=4 sw=4 smarttab expandtab fileencoding=utf-8
4 #
5 # Ceph - scalable distributed file system
6 #
7 # Copyright (C) 2013,2014 Cloudwatt <libre.licensing@cloudwatt.com>
8 # Copyright (C) 2014 Red Hat <contact@redhat.com>
9 #
10 # Author: Loic Dachary <loic@dachary.org>
11 #
12 # This library is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU Lesser General Public
14 # License as published by the Free Software Foundation; either
15 # version 2.1 of the License, or (at your option) any later version.
16 #
17
18 from nose.tools import eq_ as eq
19 from nose.tools import *
20
21 from ceph_argparse import validate_command, parse_json_funcsigs
22
23 import os
24 import re
25 import sys
26 import json
27 try:
28 from StringIO import StringIO
29 except ImportError:
30 from io import StringIO
31
32 def get_command_descriptions(what):
33 CEPH_BIN = os.environ['CEPH_BIN']
34 if CEPH_BIN == "":
35 CEPH_BIN = "."
36 return os.popen(CEPH_BIN + "/get_command_descriptions " + "--" + what).read()
37
38 def test_parse_json_funcsigs():
39 commands = get_command_descriptions("all")
40 cmd_json = parse_json_funcsigs(commands, 'cli')
41
42 # syntax error https://github.com/ceph/ceph/pull/585
43 commands = get_command_descriptions("pull585")
44 assert_raises(TypeError, parse_json_funcsigs, commands, 'cli')
45
46 sigdict = parse_json_funcsigs(get_command_descriptions("all"), 'cli')
47
48
49 class TestArgparse:
50
51 def assert_valid_command(self, args):
52 result = validate_command(sigdict, args)
53 assert_not_in(result, [{}, None])
54
55 def check_1_natural_arg(self, prefix, command):
56 self.assert_valid_command([prefix, command, '1'])
57 assert_equal({}, validate_command(sigdict, [prefix, command]))
58 assert_equal({}, validate_command(sigdict, [prefix, command, '-1']))
59 assert_equal({}, validate_command(sigdict, [prefix, command, '1',
60 '1']))
61
62 def check_0_or_1_natural_arg(self, prefix, command):
63 self.assert_valid_command([prefix, command, '1'])
64 self.assert_valid_command([prefix, command])
65 assert_equal({}, validate_command(sigdict, [prefix, command, '-1']))
66 assert_equal({}, validate_command(sigdict, [prefix, command, '1',
67 '1']))
68
69 def check_1_string_arg(self, prefix, command):
70 assert_equal({}, validate_command(sigdict, [prefix, command]))
71 self.assert_valid_command([prefix, command, 'string'])
72 assert_equal({}, validate_command(sigdict, [prefix,
73 command,
74 'string',
75 'toomany']))
76
77 def check_0_or_1_string_arg(self, prefix, command):
78 self.assert_valid_command([prefix, command, 'string'])
79 self.assert_valid_command([prefix, command])
80 assert_equal({}, validate_command(sigdict, [prefix, command, 'string',
81 'toomany']))
82
83 def check_1_or_more_string_args(self, prefix, command):
84 assert_equal({}, validate_command(sigdict, [prefix,
85 command]))
86 self.assert_valid_command([prefix,
87 command,
88 'string'])
89 self.assert_valid_command([prefix,
90 command,
91 'string',
92 'more string'])
93
94 def check_no_arg(self, prefix, command):
95 self.assert_valid_command([prefix,
96 command])
97 assert_equal({}, validate_command(sigdict, [prefix,
98 command,
99 'toomany']))
100
101 def capture_output(self, args, stdout=None, stderr=None):
102 if stdout:
103 stdout = StringIO()
104 sys.stdout = stdout
105 if stderr:
106 stderr = StringIO()
107 sys.stderr = stderr
108 ret = validate_command(sigdict, args)
109 if stdout:
110 stdout = stdout.getvalue().strip()
111 if stderr:
112 stderr = stderr.getvalue().strip()
113 return ret, stdout, stderr
114
115
116 class TestBasic:
117
118 def test_non_ascii_in_non_options(self):
119 # ArgumentPrefix("no match for {0}".format(s)) is not able to convert
120 # unicode str parameter into str. and validate_command() should not
121 # choke on it.
122 assert_equal({}, validate_command(sigdict, [u'章鱼和鱿鱼']))
123 assert_equal({}, validate_command(sigdict, [u'–w']))
124 # actually we always pass unicode strings to validate_command() in "ceph"
125 # CLI, but we also use bytestrings in our tests, so make sure it does not
126 # break.
127 assert_equal({}, validate_command(sigdict, ['章鱼和鱿鱼']))
128 assert_equal({}, validate_command(sigdict, ['–w']))
129
130
131 class TestPG(TestArgparse):
132
133 def test_stat(self):
134 self.assert_valid_command(['pg', 'stat'])
135
136 def test_getmap(self):
137 self.assert_valid_command(['pg', 'getmap'])
138
139 def test_dump(self):
140 self.assert_valid_command(['pg', 'dump'])
141 self.assert_valid_command(['pg', 'dump',
142 'all',
143 'summary',
144 'sum',
145 'delta',
146 'pools',
147 'osds',
148 'pgs',
149 'pgs_brief'])
150 assert_equal({}, validate_command(sigdict, ['pg', 'dump', 'invalid']))
151
152 def test_dump_json(self):
153 self.assert_valid_command(['pg', 'dump_json'])
154 self.assert_valid_command(['pg', 'dump_json',
155 'all',
156 'summary',
157 'sum',
158 'pools',
159 'osds',
160 'pgs'])
161 assert_equal({}, validate_command(sigdict, ['pg', 'dump_json',
162 'invalid']))
163
164 def test_dump_pools_json(self):
165 self.assert_valid_command(['pg', 'dump_pools_json'])
166
167 def test_dump_pools_stuck(self):
168 self.assert_valid_command(['pg', 'dump_stuck'])
169 self.assert_valid_command(['pg', 'dump_stuck',
170 'inactive',
171 'unclean',
172 'stale'])
173 assert_equal({}, validate_command(sigdict, ['pg', 'dump_stuck',
174 'invalid']))
175 self.assert_valid_command(['pg', 'dump_stuck',
176 'inactive',
177 '1234'])
178
179 def one_pgid(self, command):
180 self.assert_valid_command(['pg', command, '1.1'])
181 assert_equal({}, validate_command(sigdict, ['pg', command]))
182 assert_equal({}, validate_command(sigdict, ['pg', command, '1']))
183
184 def test_map(self):
185 self.one_pgid('map')
186
187 def test_scrub(self):
188 self.one_pgid('scrub')
189
190 def test_deep_scrub(self):
191 self.one_pgid('deep-scrub')
192
193 def test_repair(self):
194 self.one_pgid('repair')
195
196 def test_debug(self):
197 self.assert_valid_command(['pg',
198 'debug',
199 'unfound_objects_exist'])
200 self.assert_valid_command(['pg',
201 'debug',
202 'degraded_pgs_exist'])
203 assert_equal({}, validate_command(sigdict, ['pg', 'debug']))
204 assert_equal({}, validate_command(sigdict, ['pg', 'debug',
205 'invalid']))
206
207 def test_pg_missing_args_output(self):
208 ret, _, stderr = self.capture_output(['pg'], stderr=True)
209 assert_equal({}, ret)
210 assert_regexp_matches(stderr, re.compile('no valid command found.* closest matches'))
211
212 def test_pg_wrong_arg_output(self):
213 ret, _, stderr = self.capture_output(['pg', 'map', 'bad-pgid'],
214 stderr=True)
215 assert_equal({}, ret)
216 assert_in("Invalid command", stderr)
217
218
219 class TestAuth(TestArgparse):
220
221 def test_export(self):
222 self.assert_valid_command(['auth', 'export'])
223 self.assert_valid_command(['auth',
224 'export',
225 'string'])
226 assert_equal({}, validate_command(sigdict, ['auth',
227 'export',
228 'string',
229 'toomany']))
230
231 def test_get(self):
232 self.check_1_string_arg('auth', 'get')
233
234 def test_get_key(self):
235 self.check_1_string_arg('auth', 'get-key')
236
237 def test_print_key(self):
238 self.check_1_string_arg('auth', 'print-key')
239 self.check_1_string_arg('auth', 'print_key')
240
241 def test_list(self):
242 self.check_no_arg('auth', 'list')
243
244 def test_import(self):
245 self.check_no_arg('auth', 'import')
246
247 def test_add(self):
248 self.check_1_or_more_string_args('auth', 'add')
249
250 def test_get_or_create_key(self):
251 self.check_1_or_more_string_args('auth', 'get-or-create-key')
252
253 def test_get_or_create(self):
254 self.check_1_or_more_string_args('auth', 'get-or-create')
255
256 def test_caps(self):
257 assert_equal({}, validate_command(sigdict, ['auth',
258 'caps']))
259 assert_equal({}, validate_command(sigdict, ['auth',
260 'caps',
261 'string']))
262 self.assert_valid_command(['auth',
263 'caps',
264 'string',
265 'more string'])
266
267 def test_del(self):
268 self.check_1_string_arg('auth', 'del')
269
270
271 class TestMonitor(TestArgparse):
272
273 def test_compact(self):
274 self.assert_valid_command(['compact'])
275
276 def test_scrub(self):
277 self.assert_valid_command(['scrub'])
278
279 def test_fsid(self):
280 self.assert_valid_command(['fsid'])
281
282 def test_log(self):
283 assert_equal({}, validate_command(sigdict, ['log']))
284 self.assert_valid_command(['log', 'a logtext'])
285 self.assert_valid_command(['log', 'a logtext', 'and another'])
286
287 def test_injectargs(self):
288 assert_equal({}, validate_command(sigdict, ['injectargs']))
289 self.assert_valid_command(['injectargs', 'one'])
290 self.assert_valid_command(['injectargs', 'one', 'two'])
291
292 def test_status(self):
293 self.assert_valid_command(['status'])
294
295 def test_health(self):
296 self.assert_valid_command(['health'])
297 self.assert_valid_command(['health', 'detail'])
298 assert_equal({}, validate_command(sigdict, ['health', 'invalid']))
299 assert_equal({}, validate_command(sigdict, ['health', 'detail',
300 'toomany']))
301
302 def test_df(self):
303 self.assert_valid_command(['df'])
304 self.assert_valid_command(['df', 'detail'])
305 assert_equal({}, validate_command(sigdict, ['df', 'invalid']))
306 assert_equal({}, validate_command(sigdict, ['df', 'detail',
307 'toomany']))
308
309 def test_report(self):
310 self.assert_valid_command(['report'])
311 self.assert_valid_command(['report', 'tag1'])
312 self.assert_valid_command(['report', 'tag1', 'tag2'])
313
314 def test_quorum_status(self):
315 self.assert_valid_command(['quorum_status'])
316
317 def test_mon_status(self):
318 self.assert_valid_command(['mon_status'])
319
320 def test_sync_force(self):
321 self.assert_valid_command(['sync',
322 'force',
323 '--yes-i-really-mean-it',
324 '--i-know-what-i-am-doing'])
325 self.assert_valid_command(['sync',
326 'force',
327 '--yes-i-really-mean-it'])
328 self.assert_valid_command(['sync',
329 'force'])
330 assert_equal({}, validate_command(sigdict, ['sync']))
331 assert_equal({}, validate_command(sigdict, ['sync',
332 'force',
333 '--yes-i-really-mean-it',
334 '--i-know-what-i-am-doing',
335 'toomany']))
336
337 def test_heap(self):
338 assert_equal({}, validate_command(sigdict, ['heap']))
339 assert_equal({}, validate_command(sigdict, ['heap', 'invalid']))
340 self.assert_valid_command(['heap', 'dump'])
341 self.assert_valid_command(['heap', 'start_profiler'])
342 self.assert_valid_command(['heap', 'stop_profiler'])
343 self.assert_valid_command(['heap', 'release'])
344 self.assert_valid_command(['heap', 'stats'])
345
346 def test_quorum(self):
347 assert_equal({}, validate_command(sigdict, ['quorum']))
348 assert_equal({}, validate_command(sigdict, ['quorum', 'invalid']))
349 self.assert_valid_command(['quorum', 'enter'])
350 self.assert_valid_command(['quorum', 'exit'])
351 assert_equal({}, validate_command(sigdict, ['quorum',
352 'enter',
353 'toomany']))
354
355 def test_tell(self):
356 assert_equal({}, validate_command(sigdict, ['tell']))
357 assert_equal({}, validate_command(sigdict, ['tell', 'invalid']))
358 for name in ('osd', 'mon', 'client', 'mds'):
359 assert_equal({}, validate_command(sigdict, ['tell', name]))
360 assert_equal({}, validate_command(sigdict, ['tell',
361 name + ".42"]))
362 self.assert_valid_command(['tell', name + ".42", 'something'])
363 self.assert_valid_command(['tell', name + ".42",
364 'something',
365 'something else'])
366
367
368 class TestMDS(TestArgparse):
369
370 def test_stat(self):
371 self.check_no_arg('mds', 'stat')
372
373 def test_compat_show(self):
374 self.assert_valid_command(['mds', 'compat', 'show'])
375 assert_equal({}, validate_command(sigdict, ['mds', 'compat']))
376 assert_equal({}, validate_command(sigdict, ['mds', 'compat',
377 'show', 'toomany']))
378
379 def test_set_state(self):
380 self.assert_valid_command(['mds', 'set_state', '1', '2'])
381 assert_equal({}, validate_command(sigdict, ['mds', 'set_state']))
382 assert_equal({}, validate_command(sigdict, ['mds', 'set_state', '-1']))
383 assert_equal({}, validate_command(sigdict, ['mds', 'set_state',
384 '1', '-1']))
385 assert_equal({}, validate_command(sigdict, ['mds', 'set_state',
386 '1', '21']))
387
388 def test_fail(self):
389 self.check_1_string_arg('mds', 'fail')
390
391 def test_rm(self):
392 # Valid: single GID argument present
393 self.assert_valid_command(['mds', 'rm', '1'])
394
395 # Missing GID arg: invalid
396 assert_equal({}, validate_command(sigdict, ['mds', 'rm']))
397 # Extra arg: invalid
398 assert_equal({}, validate_command(sigdict, ['mds', 'rm', '1', 'mds.42']))
399
400 def test_rmfailed(self):
401 self.assert_valid_command(['mds', 'rmfailed', '0'])
402 self.assert_valid_command(['mds', 'rmfailed', '0', '--yes-i-really-mean-it'])
403 assert_equal({}, validate_command(sigdict, ['mds', 'rmfailed', '0',
404 '--yes-i-really-mean-it',
405 'toomany']))
406
407 def test_compat_rm_compat(self):
408 self.assert_valid_command(['mds', 'compat', 'rm_compat', '1'])
409 assert_equal({}, validate_command(sigdict, ['mds',
410 'compat',
411 'rm_compat']))
412 assert_equal({}, validate_command(sigdict, ['mds',
413 'compat',
414 'rm_compat', '-1']))
415 assert_equal({}, validate_command(sigdict, ['mds',
416 'compat',
417 'rm_compat', '1', '1']))
418
419 def test_incompat_rm_incompat(self):
420 self.assert_valid_command(['mds', 'compat', 'rm_incompat', '1'])
421 assert_equal({}, validate_command(sigdict, ['mds',
422 'compat',
423 'rm_incompat']))
424 assert_equal({}, validate_command(sigdict, ['mds',
425 'compat',
426 'rm_incompat', '-1']))
427 assert_equal({}, validate_command(sigdict, ['mds',
428 'compat',
429 'rm_incompat', '1', '1']))
430
431
432 class TestFS(TestArgparse):
433
434 def test_dump(self):
435 self.check_0_or_1_natural_arg('fs', 'dump')
436
437 def test_fs_new(self):
438 self.assert_valid_command(['fs', 'new', 'default', 'metadata', 'data'])
439
440 def test_fs_set_max_mds(self):
441 self.assert_valid_command(['fs', 'set', 'default', 'max_mds', '1'])
442 self.assert_valid_command(['fs', 'set', 'default', 'max_mds', '2'])
443
444 def test_fs_set_cluster_down(self):
445 self.assert_valid_command(['fs', 'set', 'default', 'down', 'true'])
446
447 def test_fs_set_cluster_up(self):
448 self.assert_valid_command(['fs', 'set', 'default', 'down', 'false'])
449
450 def test_fs_set_cluster_joinable(self):
451 self.assert_valid_command(['fs', 'set', 'default', 'joinable', 'true'])
452
453 def test_fs_set_cluster_not_joinable(self):
454 self.assert_valid_command(['fs', 'set', 'default', 'joinable', 'false'])
455
456 def test_fs_set(self):
457 self.assert_valid_command(['fs', 'set', 'default', 'max_file_size', '2'])
458 self.assert_valid_command(['fs', 'set', 'default', 'allow_new_snaps', 'no'])
459 assert_equal({}, validate_command(sigdict, ['fs',
460 'set',
461 'invalid']))
462
463 def test_fs_add_data_pool(self):
464 self.assert_valid_command(['fs', 'add_data_pool', 'default', '1'])
465 self.assert_valid_command(['fs', 'add_data_pool', 'default', 'foo'])
466
467 def test_fs_remove_data_pool(self):
468 self.assert_valid_command(['fs', 'rm_data_pool', 'default', '1'])
469 self.assert_valid_command(['fs', 'rm_data_pool', 'default', 'foo'])
470
471 def test_fs_rm(self):
472 self.assert_valid_command(['fs', 'rm', 'default'])
473 self.assert_valid_command(['fs', 'rm', 'default', '--yes-i-really-mean-it'])
474 assert_equal({}, validate_command(sigdict, ['fs', 'rm', 'default', '--yes-i-really-mean-it', 'toomany']))
475
476 def test_fs_ls(self):
477 self.assert_valid_command(['fs', 'ls'])
478 assert_equal({}, validate_command(sigdict, ['fs', 'ls', 'toomany']))
479
480 def test_fs_set_default(self):
481 self.assert_valid_command(['fs', 'set-default', 'cephfs'])
482 assert_equal({}, validate_command(sigdict, ['fs', 'set-default']))
483 assert_equal({}, validate_command(sigdict, ['fs', 'set-default', 'cephfs', 'toomany']))
484
485
486 class TestMon(TestArgparse):
487
488 def test_dump(self):
489 self.check_0_or_1_natural_arg('mon', 'dump')
490
491 def test_stat(self):
492 self.check_no_arg('mon', 'stat')
493
494 def test_getmap(self):
495 self.check_0_or_1_natural_arg('mon', 'getmap')
496
497 def test_add(self):
498 self.assert_valid_command(['mon', 'add', 'name', '1.2.3.4:1234'])
499 assert_equal({}, validate_command(sigdict, ['mon', 'add']))
500 assert_equal({}, validate_command(sigdict, ['mon', 'add', 'name']))
501 assert_equal({}, validate_command(sigdict, ['mon', 'add',
502 'name',
503 '400.500.600.700']))
504 assert_equal({}, validate_command(sigdict, ['mon', 'add', 'name',
505 '1.2.3.4:1234',
506 'toomany']))
507
508 def test_remove(self):
509 self.assert_valid_command(['mon', 'remove', 'name'])
510 assert_equal({}, validate_command(sigdict, ['mon', 'remove']))
511 assert_equal({}, validate_command(sigdict, ['mon', 'remove',
512 'name', 'toomany']))
513
514
515 class TestOSD(TestArgparse):
516
517 def test_stat(self):
518 self.check_no_arg('osd', 'stat')
519
520 def test_dump(self):
521 self.check_0_or_1_natural_arg('osd', 'dump')
522
523 def test_osd_tree(self):
524 self.check_0_or_1_natural_arg('osd', 'tree')
525
526 def test_osd_ls(self):
527 self.check_0_or_1_natural_arg('osd', 'ls')
528
529 def test_osd_getmap(self):
530 self.check_0_or_1_natural_arg('osd', 'getmap')
531
532 def test_osd_getcrushmap(self):
533 self.check_0_or_1_natural_arg('osd', 'getcrushmap')
534
535 def test_perf(self):
536 self.check_no_arg('osd', 'perf')
537
538 def test_getmaxosd(self):
539 self.check_no_arg('osd', 'getmaxosd')
540
541 def test_find(self):
542 self.check_1_natural_arg('osd', 'find')
543
544 def test_map(self):
545 self.assert_valid_command(['osd', 'map', 'poolname', 'objectname'])
546 self.assert_valid_command(['osd', 'map', 'poolname', 'objectname', 'nspace'])
547 assert_equal({}, validate_command(sigdict, ['osd', 'map']))
548 assert_equal({}, validate_command(sigdict, ['osd', 'map', 'poolname']))
549 assert_equal({}, validate_command(sigdict, ['osd', 'map',
550 'poolname', 'objectname', 'nspace',
551 'toomany']))
552
553 def test_metadata(self):
554 self.check_0_or_1_natural_arg('osd', 'metadata')
555
556 def test_scrub(self):
557 self.check_1_string_arg('osd', 'scrub')
558
559 def test_deep_scrub(self):
560 self.check_1_string_arg('osd', 'deep-scrub')
561
562 def test_repair(self):
563 self.check_1_string_arg('osd', 'repair')
564
565 def test_lspools(self):
566 self.assert_valid_command(['osd', 'lspools'])
567 assert_equal({}, validate_command(sigdict, ['osd', 'lspools',
568 'toomany']))
569
570 def test_blacklist_ls(self):
571 self.assert_valid_command(['osd', 'blacklist', 'ls'])
572 assert_equal({}, validate_command(sigdict, ['osd', 'blacklist']))
573 assert_equal({}, validate_command(sigdict, ['osd', 'blacklist',
574 'ls', 'toomany']))
575
576 def test_crush_rule(self):
577 assert_equal({}, validate_command(sigdict, ['osd', 'crush']))
578 assert_equal({}, validate_command(sigdict, ['osd', 'crush', 'rule']))
579 for subcommand in ('list', 'ls'):
580 self.assert_valid_command(['osd', 'crush', 'rule', subcommand])
581 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
582 'rule', subcommand,
583 'toomany']))
584
585 def test_crush_rule_dump(self):
586 self.assert_valid_command(['osd', 'crush', 'rule', 'dump'])
587 self.assert_valid_command(['osd', 'crush', 'rule', 'dump', 'RULE'])
588 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
589 'rule', 'dump',
590 'RULE',
591 'toomany']))
592
593 def test_crush_dump(self):
594 self.assert_valid_command(['osd', 'crush', 'dump'])
595 assert_equal({}, validate_command(sigdict, ['osd', 'crush']))
596 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
597 'dump',
598 'toomany']))
599
600 def test_setcrushmap(self):
601 self.check_no_arg('osd', 'setcrushmap')
602
603 def test_crush_add_bucket(self):
604 self.assert_valid_command(['osd', 'crush', 'add-bucket',
605 'name', 'type'])
606 self.assert_valid_command(['osd', 'crush', 'add-bucket',
607 'name', 'type', 'root=foo-root', 'host=foo-host'])
608 assert_equal({}, validate_command(sigdict, ['osd', 'crush']))
609 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
610 'add-bucket']))
611 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
612 'add-bucket', '^^^',
613 'type']))
614
615 def test_crush_rename_bucket(self):
616 self.assert_valid_command(['osd', 'crush', 'rename-bucket',
617 'srcname', 'dstname'])
618 assert_equal({}, validate_command(sigdict, ['osd', 'crush']))
619 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
620 'rename-bucket']))
621 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
622 'rename-bucket',
623 'srcname']))
624 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
625 'rename-bucket', 'srcname',
626 'dstname',
627 'toomany']))
628 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
629 'rename-bucket', '^^^',
630 'dstname']))
631 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
632 'rename-bucket', 'srcname',
633 '^^^^']))
634
635 def check_crush_setter(self, setter):
636 self.assert_valid_command(['osd', 'crush', setter,
637 '*', '2.3', 'AZaz09-_.='])
638 self.assert_valid_command(['osd', 'crush', setter,
639 'osd.0', '2.3', 'AZaz09-_.='])
640 self.assert_valid_command(['osd', 'crush', setter,
641 '0', '2.3', 'AZaz09-_.='])
642 self.assert_valid_command(['osd', 'crush', setter,
643 '0', '2.3', 'AZaz09-_.=', 'AZaz09-_.='])
644 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
645 setter,
646 'osd.0']))
647 ret = validate_command(sigdict, ['osd', 'crush',
648 setter,
649 'osd.0',
650 '-1.0'])
651 assert ret in [None, {}]
652 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
653 setter,
654 'osd.0',
655 '1.0',
656 '^^^']))
657
658 def test_crush_set(self):
659 assert_equal({}, validate_command(sigdict, ['osd', 'crush']))
660 self.check_crush_setter('set')
661
662 def test_crush_add(self):
663 assert_equal({}, validate_command(sigdict, ['osd', 'crush']))
664 self.check_crush_setter('add')
665
666 def test_crush_create_or_move(self):
667 assert_equal({}, validate_command(sigdict, ['osd', 'crush']))
668 self.check_crush_setter('create-or-move')
669
670 def test_crush_move(self):
671 self.assert_valid_command(['osd', 'crush', 'move',
672 'AZaz09-_.', 'AZaz09-_.='])
673 self.assert_valid_command(['osd', 'crush', 'move',
674 '0', 'AZaz09-_.=', 'AZaz09-_.='])
675 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
676 'move']))
677 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
678 'move', 'AZaz09-_.']))
679 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
680 'move', '^^^',
681 'AZaz09-_.=']))
682 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
683 'move', 'AZaz09-_.',
684 '^^^']))
685
686 def test_crush_link(self):
687 self.assert_valid_command(['osd', 'crush', 'link',
688 'name', 'AZaz09-_.='])
689 self.assert_valid_command(['osd', 'crush', 'link',
690 'name', 'AZaz09-_.=', 'AZaz09-_.='])
691 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
692 'link']))
693 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
694 'link',
695 'name']))
696
697 def test_crush_rm(self):
698 for alias in ('rm', 'remove', 'unlink'):
699 self.assert_valid_command(['osd', 'crush', alias, 'AZaz09-_.'])
700 self.assert_valid_command(['osd', 'crush', alias,
701 'AZaz09-_.', 'AZaz09-_.'])
702 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
703 alias]))
704 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
705 alias,
706 'AZaz09-_.',
707 'AZaz09-_.',
708 'toomany']))
709
710 def test_crush_reweight(self):
711 self.assert_valid_command(['osd', 'crush', 'reweight',
712 'AZaz09-_.', '2.3'])
713 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
714 'reweight']))
715 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
716 'reweight',
717 'AZaz09-_.']))
718 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
719 'reweight',
720 'AZaz09-_.',
721 '-1.0']))
722 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
723 'reweight',
724 '^^^',
725 '2.3']))
726
727 def test_crush_tunables(self):
728 for tunable in ('legacy', 'argonaut', 'bobtail', 'firefly',
729 'optimal', 'default'):
730 self.assert_valid_command(['osd', 'crush', 'tunables',
731 tunable])
732 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
733 'tunables']))
734 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
735 'tunables',
736 'default', 'toomany']))
737
738 def test_crush_rule_create_simple(self):
739 self.assert_valid_command(['osd', 'crush', 'rule', 'create-simple',
740 'AZaz09-_.', 'AZaz09-_.', 'AZaz09-_.'])
741 assert_equal({}, validate_command(sigdict, ['osd', 'crush', 'rule',
742 'create-simple']))
743 assert_equal({}, validate_command(sigdict, ['osd', 'crush', 'rule',
744 'create-simple',
745 'AZaz09-_.']))
746 assert_equal({}, validate_command(sigdict, ['osd', 'crush', 'rule',
747 'create-simple',
748 'AZaz09-_.',
749 'AZaz09-_.']))
750 assert_equal({}, validate_command(sigdict, ['osd', 'crush', 'rule',
751 'create-simple',
752 '^^^',
753 'AZaz09-_.',
754 'AZaz09-_.']))
755 assert_equal({}, validate_command(sigdict, ['osd', 'crush', 'rule',
756 'create-simple',
757 'AZaz09-_.',
758 '|||',
759 'AZaz09-_.']))
760 assert_equal({}, validate_command(sigdict, ['osd', 'crush', 'rule',
761 'create-simple',
762 'AZaz09-_.',
763 'AZaz09-_.',
764 '+++']))
765 assert_equal({}, validate_command(sigdict, ['osd', 'crush', 'rule',
766 'create-simple',
767 'AZaz09-_.',
768 'AZaz09-_.',
769 'AZaz09-_.',
770 'toomany']))
771
772 def test_crush_rule_create_erasure(self):
773 self.assert_valid_command(['osd', 'crush', 'rule', 'create-erasure',
774 'AZaz09-_.'])
775 self.assert_valid_command(['osd', 'crush', 'rule', 'create-erasure',
776 'AZaz09-_.', 'whatever'])
777 assert_equal({}, validate_command(sigdict, ['osd', 'crush', 'rule',
778 'create-erasure']))
779 assert_equal({}, validate_command(sigdict, ['osd', 'crush', 'rule',
780 'create-erasure',
781 '^^^']))
782 assert_equal({}, validate_command(sigdict, ['osd', 'crush', 'rule',
783 'create-erasure',
784 'name', '^^^']))
785
786 def test_crush_rule_rm(self):
787 self.assert_valid_command(['osd', 'crush', 'rule', 'rm', 'AZaz09-_.'])
788 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
789 'rule', 'rm']))
790 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
791 'rule', 'rm',
792 '^^^^']))
793 assert_equal({}, validate_command(sigdict, ['osd', 'crush',
794 'rule', 'rm',
795 'AZaz09-_.',
796 'toomany']))
797
798 def test_setmaxosd(self):
799 self.check_1_natural_arg('osd', 'setmaxosd')
800
801 def test_pause(self):
802 self.check_no_arg('osd', 'pause')
803
804 def test_unpause(self):
805 self.check_no_arg('osd', 'unpause')
806
807 def test_erasure_code_profile_set(self):
808 self.assert_valid_command(['osd', 'erasure-code-profile', 'set',
809 'name'])
810 self.assert_valid_command(['osd', 'erasure-code-profile', 'set',
811 'name', 'A=B'])
812 self.assert_valid_command(['osd', 'erasure-code-profile', 'set',
813 'name', 'A=B', 'C=D'])
814 assert_equal({}, validate_command(sigdict, ['osd',
815 'erasure-code-profile',
816 'set']))
817 assert_equal({}, validate_command(sigdict, ['osd',
818 'erasure-code-profile',
819 'set',
820 '^^^^']))
821
822 def test_erasure_code_profile_get(self):
823 self.assert_valid_command(['osd', 'erasure-code-profile', 'get',
824 'name'])
825 assert_equal({}, validate_command(sigdict, ['osd',
826 'erasure-code-profile',
827 'get']))
828 assert_equal({}, validate_command(sigdict, ['osd',
829 'erasure-code-profile',
830 'get',
831 '^^^^']))
832
833 def test_erasure_code_profile_rm(self):
834 self.assert_valid_command(['osd', 'erasure-code-profile', 'rm',
835 'name'])
836 assert_equal({}, validate_command(sigdict, ['osd',
837 'erasure-code-profile',
838 'rm']))
839 assert_equal({}, validate_command(sigdict, ['osd',
840 'erasure-code-profile',
841 'rm',
842 '^^^^']))
843
844 def test_erasure_code_profile_ls(self):
845 self.assert_valid_command(['osd', 'erasure-code-profile', 'ls'])
846 assert_equal({}, validate_command(sigdict, ['osd',
847 'erasure-code-profile',
848 'ls',
849 'toomany']))
850
851 def test_set_unset(self):
852 for action in ('set', 'unset'):
853 for flag in ('pause', 'noup', 'nodown', 'noout', 'noin',
854 'nobackfill', 'norecover', 'noscrub', 'nodeep-scrub'):
855 self.assert_valid_command(['osd', action, flag])
856 assert_equal({}, validate_command(sigdict, ['osd', action]))
857 assert_equal({}, validate_command(sigdict, ['osd', action,
858 'invalid']))
859 assert_equal({}, validate_command(sigdict, ['osd', action,
860 'pause', 'toomany']))
861
862 def test_down(self):
863 self.check_1_or_more_string_args('osd', 'down')
864
865 def test_out(self):
866 self.check_1_or_more_string_args('osd', 'out')
867
868 def test_in(self):
869 self.check_1_or_more_string_args('osd', 'in')
870
871 def test_rm(self):
872 self.check_1_or_more_string_args('osd', 'rm')
873
874 def test_reweight(self):
875 self.assert_valid_command(['osd', 'reweight', '1', '0.1'])
876 assert_equal({}, validate_command(sigdict, ['osd', 'reweight']))
877 assert_equal({}, validate_command(sigdict, ['osd', 'reweight',
878 '1']))
879 assert_equal({}, validate_command(sigdict, ['osd', 'reweight',
880 '1', '2.0']))
881 assert_equal({}, validate_command(sigdict, ['osd', 'reweight',
882 '-1', '0.1']))
883 assert_equal({}, validate_command(sigdict, ['osd', 'reweight',
884 '1', '0.1',
885 'toomany']))
886
887 def test_lost(self):
888 self.assert_valid_command(['osd', 'lost', '1',
889 '--yes-i-really-mean-it'])
890 self.assert_valid_command(['osd', 'lost', '1'])
891 assert_equal({}, validate_command(sigdict, ['osd', 'lost']))
892 assert_equal({}, validate_command(sigdict, ['osd', 'lost',
893 '1',
894 'what?']))
895 assert_equal({}, validate_command(sigdict, ['osd', 'lost',
896 '-1',
897 '--yes-i-really-mean-it']))
898 assert_equal({}, validate_command(sigdict, ['osd', 'lost',
899 '1',
900 '--yes-i-really-mean-it',
901 'toomany']))
902
903 def test_create(self):
904 uuid = '12345678123456781234567812345678'
905 self.assert_valid_command(['osd', 'create'])
906 self.assert_valid_command(['osd', 'create',
907 uuid])
908 assert_equal({}, validate_command(sigdict, ['osd', 'create',
909 'invalid']))
910 assert_equal({}, validate_command(sigdict, ['osd', 'create',
911 uuid,
912 'toomany']))
913
914 def test_blacklist(self):
915 for action in ('add', 'rm'):
916 self.assert_valid_command(['osd', 'blacklist', action,
917 '1.2.3.4/567'])
918 self.assert_valid_command(['osd', 'blacklist', action,
919 '1.2.3.4'])
920 self.assert_valid_command(['osd', 'blacklist', action,
921 '1.2.3.4/567', '600.40'])
922 self.assert_valid_command(['osd', 'blacklist', action,
923 '1.2.3.4', '600.40'])
924 assert_equal({}, validate_command(sigdict, ['osd', 'blacklist',
925 action,
926 'invalid',
927 '600.40']))
928 assert_equal({}, validate_command(sigdict, ['osd', 'blacklist',
929 action,
930 '1.2.3.4/567',
931 '-1.0']))
932 assert_equal({}, validate_command(sigdict, ['osd', 'blacklist',
933 action,
934 '1.2.3.4/567',
935 '600.40',
936 'toomany']))
937
938 def test_pool_mksnap(self):
939 self.assert_valid_command(['osd', 'pool', 'mksnap',
940 'poolname', 'snapname'])
941 assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'mksnap']))
942 assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'mksnap',
943 'poolname']))
944 assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'mksnap',
945 'poolname', 'snapname',
946 'toomany']))
947
948 def test_pool_rmsnap(self):
949 self.assert_valid_command(['osd', 'pool', 'rmsnap',
950 'poolname', 'snapname'])
951 assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'rmsnap']))
952 assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'rmsnap',
953 'poolname']))
954 assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'rmsnap',
955 'poolname', 'snapname',
956 'toomany']))
957
958 def test_pool_kwargs(self):
959 """
960 Use the pool creation command to exercise keyword-style arguments
961 since it has lots of parameters
962 """
963 # Simply use a keyword arg instead of a positional arg, in its
964 # normal order (pgp_num after pg_num)
965 assert_equal(
966 {
967 "prefix": "osd pool create",
968 "pool": "foo",
969 "pg_num": 8,
970 "pgp_num": 16
971 }, validate_command(sigdict, [
972 'osd', 'pool', 'create', "foo", "8", "--pgp_num", "16"]))
973
974 # Again, but using the "--foo=bar" style
975 assert_equal(
976 {
977 "prefix": "osd pool create",
978 "pool": "foo",
979 "pg_num": 8,
980 "pgp_num": 16
981 }, validate_command(sigdict, [
982 'osd', 'pool', 'create', "foo", "8", "--pgp_num=16"]))
983
984 # Specify keyword args in a different order than their definitions
985 # (pgp_num after pool_type)
986 assert_equal(
987 {
988 "prefix": "osd pool create",
989 "pool": "foo",
990 "pg_num": 8,
991 "pgp_num": 16,
992 "pool_type": "replicated"
993 }, validate_command(sigdict, [
994 'osd', 'pool', 'create', "foo", "8",
995 "--pool_type", "replicated",
996 "--pgp_num", "16"]))
997
998 # Use a keyword argument that doesn't exist, should fail validation
999 assert_equal({}, validate_command(sigdict,
1000 ['osd', 'pool', 'create', "foo", "8", "--foo=bar"]))
1001
1002 def test_foo(self):
1003 # Long form of a boolean argument (--foo=true)
1004 assert_equal(
1005 {
1006 "prefix": "osd pool delete",
1007 "pool": "foo",
1008 "pool2": "foo",
1009 "yes_i_really_really_mean_it": True
1010 }, validate_command(sigdict, [
1011 'osd', 'pool', 'delete', "foo", "foo",
1012 "--yes-i-really-really-mean-it=true"]))
1013
1014 def test_pool_bool_args(self):
1015 """
1016 Use pool deletion to exercise boolean arguments since it has
1017 the --yes-i-really-really-mean-it flags
1018 """
1019
1020 # Short form of a boolean argument (--foo)
1021 assert_equal(
1022 {
1023 "prefix": "osd pool delete",
1024 "pool": "foo",
1025 "pool2": "foo",
1026 "yes_i_really_really_mean_it": True
1027 }, validate_command(sigdict, [
1028 'osd', 'pool', 'delete', "foo", "foo",
1029 "--yes-i-really-really-mean-it"]))
1030
1031 # Long form of a boolean argument (--foo=true)
1032 assert_equal(
1033 {
1034 "prefix": "osd pool delete",
1035 "pool": "foo",
1036 "pool2": "foo",
1037 "yes_i_really_really_mean_it": True
1038 }, validate_command(sigdict, [
1039 'osd', 'pool', 'delete', "foo", "foo",
1040 "--yes-i-really-really-mean-it=true"]))
1041
1042 # Negative form of a boolean argument (--foo=false)
1043 assert_equal(
1044 {
1045 "prefix": "osd pool delete",
1046 "pool": "foo",
1047 "pool2": "foo",
1048 "yes_i_really_really_mean_it": False
1049 }, validate_command(sigdict, [
1050 'osd', 'pool', 'delete', "foo", "foo",
1051 "--yes-i-really-really-mean-it=false"]))
1052
1053 # Invalid value boolean argument (--foo=somethingelse)
1054 assert_equal({}, validate_command(sigdict, [
1055 'osd', 'pool', 'delete', "foo", "foo",
1056 "--yes-i-really-really-mean-it=rhubarb"]))
1057
1058 def test_pool_create(self):
1059 self.assert_valid_command(['osd', 'pool', 'create',
1060 'poolname', '128'])
1061 self.assert_valid_command(['osd', 'pool', 'create',
1062 'poolname', '128', '128'])
1063 self.assert_valid_command(['osd', 'pool', 'create',
1064 'poolname', '128', '128',
1065 'replicated'])
1066 self.assert_valid_command(['osd', 'pool', 'create',
1067 'poolname', '128', '128',
1068 'erasure', 'A-Za-z0-9-_.', 'ruleset^^'])
1069 assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'create']))
1070 assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'create',
1071 'poolname']))
1072 assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'create',
1073 'poolname', '-1']))
1074 assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'create',
1075 'poolname',
1076 '128', '128',
1077 'erasure', '^^^',
1078 'ruleset']))
1079 assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'create',
1080 'poolname',
1081 '128', '128',
1082 'erasure', 'profile',
1083 'ruleset',
1084 'toomany']))
1085 assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'create',
1086 'poolname',
1087 '128', '128',
1088 'INVALID', 'profile',
1089 'ruleset']))
1090
1091 def test_pool_delete(self):
1092 self.assert_valid_command(['osd', 'pool', 'delete',
1093 'poolname', 'poolname',
1094 '--yes-i-really-really-mean-it'])
1095 self.assert_valid_command(['osd', 'pool', 'delete',
1096 'poolname', 'poolname'])
1097 self.assert_valid_command(['osd', 'pool', 'delete',
1098 'poolname'])
1099 assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'delete']))
1100 assert_equal({}, validate_command(sigdict,
1101 ['osd', 'pool', 'delete',
1102 'poolname', 'poolname',
1103 '--yes-i-really-really-mean-it',
1104 'toomany']))
1105
1106 def test_pool_rename(self):
1107 self.assert_valid_command(['osd', 'pool', 'rename',
1108 'poolname', 'othername'])
1109 assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'rename']))
1110 assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'rename',
1111 'poolname']))
1112 assert_equal({}, validate_command(sigdict, ['osd', 'pool', 'rename',
1113 'poolname', 'othername',
1114 'toomany']))
1115
1116 def test_pool_get(self):
1117 for var in ('size', 'min_size',
1118 'pg_num', 'pgp_num', 'crush_rule', 'fast_read',
1119 'scrub_min_interval', 'scrub_max_interval',
1120 'deep_scrub_interval', 'recovery_priority',
1121 'recovery_op_priority'):
1122 self.assert_valid_command(['osd', 'pool', 'get', 'poolname', var])
1123 assert_equal({}, validate_command(sigdict, ['osd', 'pool']))
1124 assert_equal({}, validate_command(sigdict, ['osd', 'pool',
1125 'get']))
1126 assert_equal({}, validate_command(sigdict, ['osd', 'pool',
1127 'get', 'poolname']))
1128 assert_equal({}, validate_command(sigdict, ['osd', 'pool',
1129 'get', 'poolname',
1130 'size', 'toomany']))
1131 assert_equal({}, validate_command(sigdict, ['osd', 'pool',
1132 'get', 'poolname',
1133 'invalid']))
1134
1135 def test_pool_set(self):
1136 for var in ('size', 'min_size',
1137 'pg_num', 'pgp_num', 'crush_rule',
1138 'hashpspool', 'fast_read',
1139 'scrub_min_interval', 'scrub_max_interval',
1140 'deep_scrub_interval', 'recovery_priority',
1141 'recovery_op_priority'):
1142 self.assert_valid_command(['osd', 'pool',
1143 'set', 'poolname', var, 'value'])
1144 assert_equal({}, validate_command(sigdict, ['osd', 'pool',
1145 'set']))
1146 assert_equal({}, validate_command(sigdict, ['osd', 'pool',
1147 'set', 'poolname']))
1148 assert_equal({}, validate_command(sigdict, ['osd', 'pool',
1149 'set', 'poolname',
1150 'size', 'value',
1151 'toomany']))
1152
1153 def test_pool_set_quota(self):
1154 for field in ('max_objects', 'max_bytes'):
1155 self.assert_valid_command(['osd', 'pool', 'set-quota',
1156 'poolname', field, '10K'])
1157 assert_equal({}, validate_command(sigdict, ['osd', 'pool',
1158 'set-quota']))
1159 assert_equal({}, validate_command(sigdict, ['osd', 'pool',
1160 'set-quota',
1161 'poolname']))
1162 assert_equal({}, validate_command(sigdict, ['osd', 'pool',
1163 'set-quota',
1164 'poolname',
1165 'max_objects']))
1166 assert_equal({}, validate_command(sigdict, ['osd', 'pool',
1167 'set-quota',
1168 'poolname',
1169 'invalid',
1170 '10K']))
1171 assert_equal({}, validate_command(sigdict, ['osd', 'pool',
1172 'set-quota',
1173 'poolname',
1174 'max_objects',
1175 '10K',
1176 'toomany']))
1177
1178 def test_reweight_by_utilization(self):
1179 self.assert_valid_command(['osd', 'reweight-by-utilization'])
1180 self.assert_valid_command(['osd', 'reweight-by-utilization', '100'])
1181 self.assert_valid_command(['osd', 'reweight-by-utilization', '100', '.1'])
1182 assert_equal({}, validate_command(sigdict, ['osd',
1183 'reweight-by-utilization',
1184 '100',
1185 'toomany']))
1186
1187 def test_tier_op(self):
1188 for op in ('add', 'remove', 'set-overlay'):
1189 self.assert_valid_command(['osd', 'tier', op,
1190 'poolname', 'othername'])
1191 assert_equal({}, validate_command(sigdict, ['osd', 'tier', op]))
1192 assert_equal({}, validate_command(sigdict, ['osd', 'tier', op,
1193 'poolname']))
1194 assert_equal({}, validate_command(sigdict, ['osd', 'tier', op,
1195 'poolname',
1196 'othername',
1197 'toomany']))
1198
1199 def test_tier_cache_mode(self):
1200 for mode in ('none', 'writeback', 'forward', 'readonly', 'readforward', 'readproxy'):
1201 self.assert_valid_command(['osd', 'tier', 'cache-mode',
1202 'poolname', mode])
1203 assert_equal({}, validate_command(sigdict, ['osd', 'tier',
1204 'cache-mode']))
1205 assert_equal({}, validate_command(sigdict, ['osd', 'tier',
1206 'cache-mode',
1207 'invalid']))
1208
1209 def test_tier_remove_overlay(self):
1210 self.assert_valid_command(['osd', 'tier', 'remove-overlay',
1211 'poolname'])
1212 assert_equal({}, validate_command(sigdict, ['osd', 'tier',
1213 'remove-overlay']))
1214 assert_equal({}, validate_command(sigdict, ['osd', 'tier',
1215 'remove-overlay',
1216 'poolname',
1217 'toomany']))
1218
1219 def set_ratio(self, command):
1220 self.assert_valid_command(['osd',
1221 command,
1222 '0.0'])
1223 assert_equal({}, validate_command(sigdict, ['osd', command]))
1224 assert_equal({}, validate_command(sigdict, ['osd',
1225 command,
1226 '2.0']))
1227
1228 def test_set_full_ratio(self):
1229 self.set_ratio('set-full-ratio')
1230
1231 def test_set_backfillfull_ratio(self):
1232 self.set_ratio('set-backfillfull-ratio')
1233
1234 def test_set_nearfull_ratio(self):
1235 self.set_ratio('set-nearfull-ratio')
1236
1237
1238 class TestConfigKey(TestArgparse):
1239
1240 def test_get(self):
1241 self.check_1_string_arg('config-key', 'get')
1242
1243 def test_put(self):
1244 self.assert_valid_command(['config-key', 'put',
1245 'key'])
1246 self.assert_valid_command(['config-key', 'put',
1247 'key', 'value'])
1248 assert_equal({}, validate_command(sigdict, ['config-key', 'put']))
1249 assert_equal({}, validate_command(sigdict, ['config-key', 'put',
1250 'key', 'value',
1251 'toomany']))
1252
1253 def test_del(self):
1254 self.check_1_string_arg('config-key', 'del')
1255
1256 def test_exists(self):
1257 self.check_1_string_arg('config-key', 'exists')
1258
1259 def test_dump(self):
1260 self.check_0_or_1_string_arg('config-key', 'dump')
1261
1262 def test_list(self):
1263 self.check_no_arg('config-key', 'list')
1264 # Local Variables:
1265 # compile-command: "cd ../.. ; make -j4 &&
1266 # PYTHONPATH=pybind nosetests --stop \
1267 # test/pybind/test_ceph_argparse.py # test_ceph_argparse.py:TestOSD.test_rm"
1268 # End: