]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: Add unit test for fix command
authorBoris Ranto <branto@redhat.com>
Thu, 9 Feb 2017 18:17:12 +0000 (19:17 +0100)
committerBoris Ranto <branto@redhat.com>
Wed, 10 May 2017 16:03:01 +0000 (18:03 +0200)
This will simulate the command* functions to not actually run anything
thus excercising the python code directly. It also checks that the
proper (sub-strings) are in the output.

Signed-off-by: Boris Ranto <branto@redhat.com>
(cherry picked from commit 1ec53dee9a690134936bdc3a09c9a02fecf13a9d)

src/ceph-disk/tests/test_main.py

index d76a5d8b6040c80e9af8a38ea7f561f6cc54f893..3f0e714e90bee6f7f0f158072d719e45469bbb4d 100644 (file)
@@ -1292,6 +1292,27 @@ class TestCephDiskDeactivateAndDestroy(unittest.TestCase):
             self.assertRaises(Exception, main._deallocate_osd_id,
                               cluster, osd_id)
 
+    def test_main_fix(self):
+        args = main.parse_args(['fix', '--all', '--selinux', '--permissions'])
+        commands = []
+
+        def _command(x):
+            commands.append(" ".join(x))
+            return ("", "", None)
+
+        with patch.multiple(
+            main,
+            command=_command,
+            command_init=lambda x: commands.append(x),
+            command_wait=lambda x: None,
+        ):
+            main.main_fix(args)
+            commands = " ".join(commands)
+            assert '/var/lib/ceph' in commands
+            assert 'restorecon' in commands
+            assert 'chown' in commands
+            assert 'find' in commands
+
 
 def raise_command_error(*args):
     e = subprocess.CalledProcessError('aaa', 'bbb', 'ccc')