From: Alfredo Deza Date: Mon, 4 Jun 2018 18:04:52 +0000 (-0400) Subject: ceph-volume tests verify create_lvs behavior X-Git-Tag: v13.2.1~135^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c96e37cd6b9241fe40b349a71e1d490c472341f0;p=ceph.git ceph-volume tests verify create_lvs behavior Signed-off-by: Alfredo Deza (cherry picked from commit 8c487124d795778dbbf461ffb95841b1c8025e08) --- diff --git a/src/ceph-volume/ceph_volume/tests/api/test_lvm.py b/src/ceph-volume/ceph_volume/tests/api/test_lvm.py index a1cd8cc9c0d7..43fd0a56fe97 100644 --- a/src/ceph-volume/ceph_volume/tests/api/test_lvm.py +++ b/src/ceph-volume/ceph_volume/tests/api/test_lvm.py @@ -388,6 +388,39 @@ class TestVolumeGroupFree(object): assert vg.free == 100 +class TestCreateLVs(object): + + def test_creates_correct_lv_number_from_parts(self, monkeypatch): + monkeypatch.setattr('ceph_volume.api.lvm.create_lv', lambda *a, **kw: (a, kw)) + vg = api.VolumeGroup(vg_name='ceph', vg_free='1024g') + lvs = api.create_lvs(vg, parts=4) + assert len(lvs) == 4 + + def test_suffixes_the_size_arg(self, monkeypatch): + monkeypatch.setattr('ceph_volume.api.lvm.create_lv', lambda *a, **kw: (a, kw)) + vg = api.VolumeGroup(vg_name='ceph', vg_free='1024g') + lvs = api.create_lvs(vg, parts=4) + assert lvs[0][1]['size'] == '256g' + + def test_only_uses_free_size(self, monkeypatch): + monkeypatch.setattr('ceph_volume.api.lvm.create_lv', lambda *a, **kw: (a, kw)) + vg = api.VolumeGroup(vg_name='ceph', vg_free='1024g', vg_size='99999999g') + lvs = api.create_lvs(vg, parts=4) + assert lvs[0][1]['size'] == '256g' + + def test_null_tags_are_set_by_default(self, monkeypatch): + monkeypatch.setattr('ceph_volume.api.lvm.create_lv', lambda *a, **kw: (a, kw)) + vg = api.VolumeGroup(vg_name='ceph', vg_free='1024g', vg_size='99999999g') + kwargs = api.create_lvs(vg, parts=4)[0][1] + assert list(kwargs['tags'].values()) == ['null', 'null', 'null', 'null'] + + def test_fallback_to_one_part(self, monkeypatch): + monkeypatch.setattr('ceph_volume.api.lvm.create_lv', lambda *a, **kw: (a, kw)) + vg = api.VolumeGroup(vg_name='ceph', vg_free='1024g', vg_size='99999999g') + lvs = api.create_lvs(vg) + assert len(lvs) == 1 + + class TestVolumeGroupSizing(object): def test_parts_and_size_errors(self):