]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/ceph-volume/ceph_volume/tests/devices/lvm/test_prepare.py
update sources to 12.2.10
[ceph.git] / ceph / src / ceph-volume / ceph_volume / tests / devices / lvm / test_prepare.py
index bc2486cf6944fbd795383b3ecd18b1b100da5358..c7963bb2ff199a354562abca3eec3fefbe896ba6 100644 (file)
@@ -32,6 +32,21 @@ class TestPrepareDevice(object):
         assert 'A vg/lv path or an existing device is needed' in str(error)
 
 
+class TestGetClusterFsid(object):
+
+    def test_fsid_is_passed_in(self, factory):
+        args = factory(cluster_fsid='aaaa-1111')
+        prepare_obj = lvm.prepare.Prepare([])
+        prepare_obj.args = args
+        assert prepare_obj.get_cluster_fsid() == 'aaaa-1111'
+
+    def test_fsid_is_read_from_ceph_conf(self, factory, conf_ceph_stub):
+        conf_ceph_stub('[global]\nfsid = bbbb-2222')
+        prepare_obj = lvm.prepare.Prepare([])
+        prepare_obj.args = factory(cluster_fsid=None)
+        assert prepare_obj.get_cluster_fsid() == 'bbbb-2222'
+
+
 class TestPrepare(object):
 
     def test_main_spits_help_with_no_arguments(self, capsys):
@@ -47,14 +62,16 @@ class TestPrepare(object):
         assert 'Use the bluestore objectstore' in stdout
         assert 'A physical device or logical' in stdout
 
-    def test_excludes_filestore_bluestore_flags(self, capsys):
+    def test_excludes_filestore_bluestore_flags(self, capsys, device_info):
+        device_info()
         with pytest.raises(SystemExit):
             lvm.prepare.Prepare(argv=['--data', '/dev/sdfoo', '--filestore', '--bluestore']).main()
         stdout, stderr = capsys.readouterr()
         expected = 'Cannot use --filestore (filestore) with --bluestore (bluestore)'
         assert expected in stdout
 
-    def test_excludes_other_filestore_bluestore_flags(self, capsys):
+    def test_excludes_other_filestore_bluestore_flags(self, capsys, device_info):
+        device_info()
         with pytest.raises(SystemExit):
             lvm.prepare.Prepare(argv=[
                 '--bluestore', '--data', '/dev/sdfoo',
@@ -64,7 +81,8 @@ class TestPrepare(object):
         expected = 'Cannot use --bluestore (bluestore) with --journal (filestore)'
         assert expected in stdout
 
-    def test_excludes_block_and_journal_flags(self, capsys):
+    def test_excludes_block_and_journal_flags(self, capsys, device_info):
+        device_info()
         with pytest.raises(SystemExit):
             lvm.prepare.Prepare(argv=[
                 '--bluestore', '--data', '/dev/sdfoo', '--block.db', 'vg/ceph1',
@@ -74,6 +92,14 @@ class TestPrepare(object):
         expected = 'Cannot use --block.db (bluestore) with --journal (filestore)'
         assert expected in stdout
 
+    def test_journal_is_required_with_filestore(self, is_root, monkeypatch, device_info):
+        monkeypatch.setattr("os.path.exists", lambda path: True)
+        device_info()
+        with pytest.raises(SystemExit) as error:
+            lvm.prepare.Prepare(argv=['--filestore', '--data', '/dev/sdfoo']).main()
+        expected = '--journal is required when using --filestore'
+        assert expected in str(error)
+
 
 class TestGetJournalLV(object):