]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume tests.lvm.strategies initial filestore validation 24080/head
authorAlfredo Deza <adeza@redhat.com>
Wed, 12 Sep 2018 13:44:32 +0000 (09:44 -0400)
committerAlfredo Deza <adeza@redhat.com>
Thu, 13 Sep 2018 15:29:30 +0000 (11:29 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
(cherry picked from commit d1d68eade56ba3f898cd3bfd29aa1ee3bf5460ec)

src/ceph-volume/ceph_volume/tests/devices/lvm/strategies/test_filestore.py [new file with mode: 0644]

diff --git a/src/ceph-volume/ceph_volume/tests/devices/lvm/strategies/test_filestore.py b/src/ceph-volume/ceph_volume/tests/devices/lvm/strategies/test_filestore.py
new file mode 100644 (file)
index 0000000..312a283
--- /dev/null
@@ -0,0 +1,210 @@
+import pytest
+from ceph_volume.devices.lvm.strategies import filestore
+from ceph_volume.api import lvm
+
+
+class TestSingleType(object):
+
+    def test_hdd_device_is_large_enough(self, fakedevice, factory, conf_ceph):
+        conf_ceph(get_safe=lambda *a: '5120')
+        args = factory(osds_per_device=1)
+        devices = [
+            fakedevice(is_lvm_member=False, sys_api=dict(rotational='1', size=12073740000))
+        ]
+        computed_osd = filestore.SingleType(devices, args).computed['osds'][0]
+        assert computed_osd['data']['percentage'] == 55
+        assert computed_osd['data']['parts'] == 1
+        assert computed_osd['data']['human_readable_size'] == '6.24 GB'
+        assert computed_osd['data']['path'] == '/dev/sda'
+
+    def test_hdd_device_with_large_journal(self, fakedevice, factory, conf_ceph):
+        conf_ceph(get_safe=lambda *a: '5120')
+        args = factory(osds_per_device=1)
+        devices = [
+            fakedevice(is_lvm_member=False, sys_api=dict(rotational='1', size=6073740000))
+        ]
+        with pytest.raises(RuntimeError) as error:
+            filestore.SingleType(devices, args)
+        msg = "Unable to use device 5.66 GB /dev/sda, LVs would be smaller than 5GB"
+        assert msg in str(error)
+
+    def test_ssd_device_is_large_enough(self, fakedevice, factory, conf_ceph):
+        conf_ceph(get_safe=lambda *a: '5120')
+        args = factory(osds_per_device=1)
+        devices = [
+            fakedevice(is_lvm_member=False, sys_api=dict(rotational='0', size=12073740000))
+        ]
+        computed_osd = filestore.SingleType(devices, args).computed['osds'][0]
+        assert computed_osd['data']['percentage'] == 55
+        assert computed_osd['data']['parts'] == 1
+        assert computed_osd['data']['human_readable_size'] == '6.24 GB'
+        assert computed_osd['data']['path'] == '/dev/sda'
+
+    def test_ssd_device_with_large_journal(self, fakedevice, factory, conf_ceph):
+        conf_ceph(get_safe=lambda *a: '5120')
+        args = factory(osds_per_device=1)
+        devices = [
+            fakedevice(is_lvm_member=False, sys_api=dict(rotational='0', size=6073740000))
+        ]
+        with pytest.raises(RuntimeError) as error:
+            filestore.SingleType(devices, args)
+        msg = "Unable to use device 5.66 GB /dev/sda, LVs would be smaller than 5GB"
+        assert msg in str(error)
+
+    def test_ssd_device_multi_osd(self, fakedevice, factory, conf_ceph):
+        conf_ceph(get_safe=lambda *a: '5120')
+        args = factory(osds_per_device=4)
+        devices = [
+            fakedevice(is_lvm_member=False, sys_api=dict(rotational='0', size=16073740000))
+        ]
+        with pytest.raises(RuntimeError) as error:
+            filestore.SingleType(devices, args)
+        msg = "Unable to use device 14.97 GB /dev/sda, LVs would be smaller than 5GB"
+        assert msg in str(error)
+
+    def test_hdd_device_multi_osd(self, fakedevice, factory, conf_ceph):
+        conf_ceph(get_safe=lambda *a: '5120')
+        args = factory(osds_per_device=4)
+        devices = [
+            fakedevice(is_lvm_member=False, sys_api=dict(rotational='1', size=16073740000))
+        ]
+        with pytest.raises(RuntimeError) as error:
+            filestore.SingleType(devices, args)
+        msg = "Unable to use device 14.97 GB /dev/sda, LVs would be smaller than 5GB"
+        assert msg in str(error)
+
+    def test_device_is_lvm_member_fails(self, fakedevice, factory, conf_ceph):
+        conf_ceph(get_safe=lambda *a: '5120')
+        args = factory(osds_per_device=1)
+        devices = [
+            fakedevice(is_lvm_member=True, sys_api=dict(rotational='1', size=12073740000))
+        ]
+        with pytest.raises(RuntimeError) as error:
+            filestore.SingleType(devices, args)
+        assert 'Unable to use device, already a member of LVM' in str(error)
+
+    def test_hdd_device_with_small_configured_journal(self, fakedevice, factory, conf_ceph):
+        conf_ceph(get_safe=lambda *a: '120')
+        args = factory(osds_per_device=1)
+        devices = [
+            fakedevice(is_lvm_member=False, sys_api=dict(rotational='1', size=6073740000))
+        ]
+        with pytest.raises(RuntimeError) as error:
+            filestore.SingleType(devices, args)
+        msg = "journal sizes must be larger than 2GB, detected: 120.00 MB"
+        assert msg in str(error)
+
+    def test_ssd_device_with_small_configured_journal(self, fakedevice, factory, conf_ceph):
+        conf_ceph(get_safe=lambda *a: '120')
+        args = factory(osds_per_device=1)
+        devices = [
+            fakedevice(is_lvm_member=False, sys_api=dict(rotational='0', size=6073740000))
+        ]
+        with pytest.raises(RuntimeError) as error:
+            filestore.SingleType(devices, args)
+        msg = "journal sizes must be larger than 2GB, detected: 120.00 MB"
+        assert msg in str(error)
+
+
+class TestMixedType(object):
+
+    def test_minimum_size_is_not_met(self, stub_vgs, fakedevice, factory, conf_ceph):
+        conf_ceph(get_safe=lambda *a: '120')
+        args = factory(osds_per_device=1)
+        devices = [
+            fakedevice(is_lvm_member=False, sys_api=dict(rotational='0', size=6073740000)),
+            fakedevice(is_lvm_member=False, sys_api=dict(rotational='1', size=6073740000))
+        ]
+        with pytest.raises(RuntimeError) as error:
+            filestore.MixedType(devices, args)
+        msg = "journal sizes must be larger than 2GB, detected: 120.00 MB"
+        assert msg in str(error)
+
+    def test_ssd_device_is_not_large_enough(self, stub_vgs, fakedevice, factory, conf_ceph):
+        conf_ceph(get_safe=lambda *a: '7120')
+        args = factory(osds_per_device=1)
+        devices = [
+            fakedevice(is_lvm_member=False, sys_api=dict(rotational='0', size=6073740000)),
+            fakedevice(is_lvm_member=False, sys_api=dict(rotational='1', size=6073740000))
+        ]
+        with pytest.raises(RuntimeError) as error:
+            filestore.MixedType(devices, args)
+        msg = "Not enough space in fast devices (5.66 GB) to create 1 x 6.95 GB journal LV"
+        assert msg in str(error)
+
+    def test_hdd_device_is_lvm_member_fails(self, stub_vgs, fakedevice, factory, conf_ceph):
+        conf_ceph(get_safe=lambda *a: '5120')
+        args = factory(osds_per_device=1)
+        devices = [
+            fakedevice(is_lvm_member=False, sys_api=dict(rotational='0', size=6073740000)),
+            fakedevice(is_lvm_member=True, sys_api=dict(rotational='1', size=6073740000))
+        ]
+        with pytest.raises(RuntimeError) as error:
+            filestore.MixedType(devices, args)
+        assert 'Unable to use device, already a member of LVM' in str(error)
+
+    def test_ssd_is_lvm_member_doesnt_fail(self, volumes, stub_vgs, fakedevice, factory, conf_ceph):
+        # fast PV, because ssd is an LVM member
+        CephPV = lvm.PVolume(vg_name='fast', pv_name='/dev/sda', pv_tags='')
+        ssd = fakedevice(
+            is_lvm_member=True, sys_api=dict(rotational='0', size=6073740000), pvs_api=[CephPV]
+        )
+        hdd = fakedevice(is_lvm_member=False, sys_api=dict(rotational='1', size=6073740000))
+        # when get_api_vgs() gets called, it will return this one VG
+        stub_vgs([
+            dict(
+                vg_free='7g', vg_name='fast', lv_name='foo',
+                lv_path='/dev/vg/foo', lv_tags="ceph.type=data"
+            )
+        ])
+
+        conf_ceph(get_safe=lambda *a: '5120')
+        args = factory(osds_per_device=1)
+        devices = [ssd, hdd]
+        result = filestore.MixedType(devices, args).computed['osds'][0]
+        assert result['journal']['path'] == 'vg: fast'
+        assert result['journal']['percentage'] == 71
+        assert result['journal']['human_readable_size'] == '5.00 GB'
+
+    def test_no_common_vg(self, volumes, stub_vgs, fakedevice, factory, conf_ceph):
+        # fast PV, because ssd is an LVM member
+        CephPV1 = lvm.PVolume(vg_name='fast1', pv_name='/dev/sda', pv_tags='')
+        CephPV2 = lvm.PVolume(vg_name='fast2', pv_name='/dev/sdb', pv_tags='')
+        ssd1 = fakedevice(
+            is_lvm_member=True, sys_api=dict(rotational='0', size=6073740000), pvs_api=[CephPV1]
+        )
+        ssd2 = fakedevice(
+            is_lvm_member=True, sys_api=dict(rotational='0', size=6073740000), pvs_api=[CephPV2]
+        )
+        hdd = fakedevice(is_lvm_member=False, sys_api=dict(rotational='1', size=6073740000))
+        # when get_api_vgs() gets called, it will return this one VG
+        stub_vgs([
+            dict(
+                vg_free='7g', vg_name='fast1', lv_name='foo',
+                lv_path='/dev/vg/fast1', lv_tags="ceph.type=data"
+            ),
+            dict(
+                vg_free='7g', vg_name='fast2', lv_name='foo',
+                lv_path='/dev/vg/fast2', lv_tags="ceph.type=data"
+            )
+        ])
+
+        conf_ceph(get_safe=lambda *a: '5120')
+        args = factory(osds_per_device=1)
+        devices = [ssd1, ssd2, hdd]
+        with pytest.raises(RuntimeError) as error:
+            filestore.MixedType(devices, args)
+
+        assert 'Could not find a common VG between devices' in str(error)
+
+    def test_ssd_device_fails_multiple_osds(self, stub_vgs, fakedevice, factory, conf_ceph):
+        conf_ceph(get_safe=lambda *a: '15120')
+        args = factory(osds_per_device=2)
+        devices = [
+            fakedevice(is_lvm_member=False, sys_api=dict(rotational='0', size=16073740000)),
+            fakedevice(is_lvm_member=False, sys_api=dict(rotational='1', size=16073740000))
+        ]
+        with pytest.raises(RuntimeError) as error:
+            filestore.MixedType(devices, args)
+        msg = "Not enough space in fast devices (14.97 GB) to create 2 x 14.77 GB journal LV"
+        assert msg in str(error)