]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume tests add util.prepare unit tests
authorAlfredo Deza <adeza@redhat.com>
Fri, 19 Jan 2018 14:58:36 +0000 (09:58 -0500)
committerAlfredo Deza <adeza@redhat.com>
Mon, 22 Jan 2018 19:43:49 +0000 (14:43 -0500)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
src/ceph-volume/ceph_volume/tests/util/test_prepare.py [new file with mode: 0644]

diff --git a/src/ceph-volume/ceph_volume/tests/util/test_prepare.py b/src/ceph-volume/ceph_volume/tests/util/test_prepare.py
new file mode 100644 (file)
index 0000000..b299ea3
--- /dev/null
@@ -0,0 +1,50 @@
+from ceph_volume.util import prepare
+from ceph_volume.util.prepare import system
+from ceph_volume import conf
+from ceph_volume.tests.conftest import Factory
+
+
+class TestFormatDevice(object):
+
+    def test_include_force(self, fake_run, monkeypatch):
+        monkeypatch.setattr(conf, 'ceph', Factory(get_list=lambda *a, **kw: []))
+        prepare.format_device('/dev/sxx')
+        flags = fake_run.calls[0]['args'][0]
+        assert '-f' in flags
+
+    def test_device_is_always_appended(self, fake_run, conf_ceph):
+        conf_ceph(get_list=lambda *a, **kw: [])
+        prepare.format_device('/dev/sxx')
+        flags = fake_run.calls[0]['args'][0]
+        assert flags[-1] == '/dev/sxx'
+
+    def test_extra_flags_are_added(self, fake_run, conf_ceph):
+        conf_ceph(get_list=lambda *a, **kw: ['--why-yes'])
+        prepare.format_device('/dev/sxx')
+        flags = fake_run.calls[0]['args'][0]
+        assert '--why-yes' in flags
+
+
+class TestOsdMkfsBluestore(object):
+
+    def test_keyring_is_added(self, fake_call, monkeypatch):
+        monkeypatch.setattr(system, 'chown', lambda path: True)
+        prepare.osd_mkfs_bluestore(1, 'asdf', keyring='secret')
+        assert '--keyfile' in fake_call.calls[0]['args'][0]
+
+    def test_keyring_is_not_added(self, fake_call, monkeypatch):
+        monkeypatch.setattr(system, 'chown', lambda path: True)
+        prepare.osd_mkfs_bluestore(1, 'asdf')
+        assert '--keyfile' not in fake_call.calls[0]['args'][0]
+
+    def test_wal_is_added(self, fake_call, monkeypatch):
+        monkeypatch.setattr(system, 'chown', lambda path: True)
+        prepare.osd_mkfs_bluestore(1, 'asdf', wal='/dev/smm1')
+        assert '--bluestore-block-wal-path' in fake_call.calls[0]['args'][0]
+        assert '/dev/smm1' in fake_call.calls[0]['args'][0]
+
+    def test_db_is_added(self, fake_call, monkeypatch):
+        monkeypatch.setattr(system, 'chown', lambda path: True)
+        prepare.osd_mkfs_bluestore(1, 'asdf', db='/dev/smm2')
+        assert '--bluestore-block-db-path' in fake_call.calls[0]['args'][0]
+        assert '/dev/smm2' in fake_call.calls[0]['args'][0]