Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ceph-volume tests.lvm.strategies initial filestore validation
Signed-off-by: Alfredo Deza <adeza@redhat.com> (cherry picked from commit d1d68ea)
- Loading branch information
Alfredo Deza
committed
Sep 13, 2018
1 parent
fc74b49
commit 428b80d
Showing
1 changed file
with
210 additions
and
0 deletions.
There are no files selected for viewing
210 changes: 210 additions & 0 deletions
210
src/ceph-volume/ceph_volume/tests/devices/lvm/strategies/test_filestore.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |