]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_argparse: unit tests for validate_command pg
authorLoic Dachary <loic@dachary.org>
Sun, 15 Sep 2013 15:32:34 +0000 (17:32 +0200)
committerLoic Dachary <loic@dachary.org>
Mon, 23 Sep 2013 21:46:44 +0000 (23:46 +0200)
http://tracker.ceph.com/issues/6274 refs #6274

Reviewed-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Joao Eduardo Luis <joao.luis@inktank.com>
Signed-off-by: Loic Dachary <loic@dachary.org>
src/test/pybind/test_ceph_argparse.py

index b5261f61a1f37a580d9fb59bc16e65b2acaaf75a..43724b09a8ef260ba0bc224beba8dd43fcc460c4 100755 (executable)
@@ -84,6 +84,104 @@ class TestArgparse:
         assert_equal({}, validate_command(sigdict, [prefix,
                                                     command,
                                                     'toomany']))
+
+
+class TestPG(TestArgparse):
+
+    def test_stat(self):
+        self.assert_valid_command(['pg', 'stat'])
+
+    def test_getmap(self):
+        self.assert_valid_command(['pg', 'getmap'])
+
+    def test_send_pg_creates(self):
+        self.assert_valid_command(['pg', 'send_pg_creates'])
+
+    def test_dump(self):
+        self.assert_valid_command(['pg', 'dump'])
+        self.assert_valid_command(['pg', 'dump',
+                                   'all',
+                                   'summary',
+                                   'sum',
+                                   'delta',
+                                   'pools',
+                                   'osds',
+                                   'pgs',
+                                   'pgs_brief'])
+        assert_equal({}, validate_command(sigdict, ['pg', 'dump', 'invalid']))
+
+    def test_dump_json(self):
+        self.assert_valid_command(['pg', 'dump_json'])
+        self.assert_valid_command(['pg', 'dump_json',
+                                   'all',
+                                   'summary',
+                                   'sum',
+                                   'pools',
+                                   'osds',
+                                   'pgs'])
+        assert_equal({}, validate_command(sigdict, ['pg', 'dump_json',
+                                                    'invalid']))
+
+    def test_dump_pools_json(self):
+        self.assert_valid_command(['pg', 'dump_pools_json'])
+
+    def test_dump_pools_stuck(self):
+        self.assert_valid_command(['pg', 'dump_stuck'])
+        self.assert_valid_command(['pg', 'dump_stuck',
+                                   'inactive',
+                                   'unclean',
+                                   'stale'])
+        assert_equal({}, validate_command(sigdict, ['pg', 'dump_stuck',
+                                                    'invalid']))
+        self.assert_valid_command(['pg', 'dump_stuck',
+                                   'inactive',
+                                   '1234'])
+
+    def one_pgid(self, command):
+        self.assert_valid_command(['pg', command, '1.1'])
+        assert_equal({}, validate_command(sigdict, ['pg', command]))
+        assert_equal({}, validate_command(sigdict, ['pg', command, '1']))
+
+    def test_map(self):
+        self.one_pgid('map')
+
+    def test_scrub(self):
+        self.one_pgid('scrub')
+
+    def test_deep_scrub(self):
+        self.one_pgid('deep-scrub')
+
+    def test_repair(self):
+        self.one_pgid('repair')
+
+    def test_debug(self):
+        self.assert_valid_command(['pg',
+                                   'debug',
+                                   'unfound_objects_exist'])
+        self.assert_valid_command(['pg',
+                                   'debug',
+                                   'degraded_pgs_exist'])
+        assert_equal({}, validate_command(sigdict, ['pg', 'debug']))
+        assert_equal({}, validate_command(sigdict, ['pg', 'debug',
+                                                    'invalid']))
+
+    def test_force_create_pg(self):
+        self.one_pgid('force_create_pg')
+
+    def set_ratio(self, command):
+        self.assert_valid_command(['pg',
+                                   command,
+                                   '0.0'])
+        assert_equal({}, validate_command(sigdict, ['pg', command]))
+        assert_equal({}, validate_command(sigdict, ['pg',
+                                                    command,
+                                                    '2.0']))
+
+    def test_set_full_ratio(self):
+        self.set_ratio('set_full_ratio')
+
+    def test_set_nearfull_ratio(self):
+        self.set_ratio('set_nearfull_ratio')
 # Local Variables:
 # compile-command: "cd ../.. ; make -j4 && 
 #  PYTHONPATH=pybind nosetests --stop \