]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume tests mkfs filestore fails on non-zero exit status
authorAlfredo Deza <adeza@redhat.com>
Thu, 26 Apr 2018 20:24:57 +0000 (16:24 -0400)
committerAlfredo Deza <adeza@redhat.com>
Thu, 26 Apr 2018 20:24:57 +0000 (16:24 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
src/ceph-volume/ceph_volume/tests/util/test_prepare.py

index dfccca336e32b638749a971c56d404aaf03cbef7..2bac81086bc640c74fe372e187f7df4aca5f692a 100644 (file)
@@ -287,3 +287,32 @@ class TestNormalizeFlags(object):
     def test_normalize_strings_duplicate_flags(self, flags):
         result = sorted(prepare._normalize_mount_flags(flags, extras=['discard','rw']).split(','))
         assert ','.join(result) == 'auto,discard,exec,rw'
+
+
+class TestMkfsFilestore(object):
+
+    def test_non_zero_exit_status(self, stub_call, monkeypatch):
+        conf.cluster = 'ceph'
+        monkeypatch.setattr('ceph_volume.util.prepare.system.chown', lambda x: True)
+        stub_call(([], [], 1))
+        with pytest.raises(RuntimeError) as error:
+            prepare.osd_mkfs_filestore('1', 'asdf-1234', 'keyring')
+        assert "Command failed with exit code 1" in str(error)
+
+    def test_non_zero_exit_formats_command_correctly(self, stub_call, monkeypatch):
+        conf.cluster = 'ceph'
+        monkeypatch.setattr('ceph_volume.util.prepare.system.chown', lambda x: True)
+        stub_call(([], [], 1))
+        with pytest.raises(RuntimeError) as error:
+            prepare.osd_mkfs_filestore('1', 'asdf-1234', 'keyring')
+        expected = ' '.join([
+            'ceph-osd',
+            '--cluster',
+            'ceph',
+            '--osd-objectstore', 'filestore', '--mkfs',
+            '-i', '1', '--monmap', '/var/lib/ceph/osd/ceph-1/activate.monmap',
+            '--keyfile', '-', '--osd-data', '/var/lib/ceph/osd/ceph-1/',
+            '--osd-journal', '/var/lib/ceph/osd/ceph-1/journal',
+            '--osd-uuid', 'asdf-1234',
+            '--setuser', 'ceph', '--setgroup', 'ceph'])
+        assert expected in str(error)