From: Jan Fajerski Date: Thu, 12 Dec 2019 12:45:44 +0000 (+0100) Subject: tests: fix tests after batch sizing was fixed X-Git-Tag: v14.2.8~52^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3dc93ffae1438d88371d9891251fdea076812e8e;p=ceph.git tests: fix tests after batch sizing was fixed Signed-off-by: Jan Fajerski (cherry picked from commit 405112970ec62fca345d10040c1648b7e629d11a) --- 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 a3b83a9e6bd..43125471bac 100644 --- a/src/ceph-volume/ceph_volume/tests/api/test_lvm.py +++ b/src/ceph-volume/ceph_volume/tests/api/test_lvm.py @@ -43,12 +43,12 @@ class TestGetAPIVgs(object): assert api.get_api_vgs() == [{'vg_name': 'VolGroup00'}] def test_report_has_stuff_with_empty_attrs(self, monkeypatch): - report = [' VolGroup00 ;;;;;;9g'] + report = [' VolGroup00 ;;;;;;4194304'] monkeypatch.setattr(api.process, 'call', lambda x, **kw: (report, '', 0)) result = api.get_api_vgs()[0] assert len(result.keys()) == 7 assert result['vg_name'] == 'VolGroup00' - assert result['vg_free'] == '9g' + assert result['vg_extent_size'] == '4194304' def test_report_has_multiple_items(self, monkeypatch): report = [' VolGroup00;;;;;;;', ' ceph_vg;;;;;;;'] @@ -373,59 +373,48 @@ class TestVolumeGroupFree(object): class TestCreateLVs(object): + def setup(self): + self.vg = api.VolumeGroup(vg_name='ceph', + vg_extent_size=1073741824, + vg_extent_count=99999999, + vg_free_count=999) + 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', - vg_size='99999999g', vg_free_count='999' - ) - lvs = api.create_lvs(vg, parts=4) + lvs = api.create_lvs(self.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', - vg_size='99999999g', vg_free_count='999' - ) - lvs = api.create_lvs(vg, parts=4) + lvs = api.create_lvs(self.vg, parts=4) assert lvs[0][1]['extents'] == 249 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', vg_free_count='1000' - ) + vg = api.VolumeGroup(vg_name='ceph', + vg_extent_size=1073741824, + vg_extent_count=99999999, + vg_free_count=1000) lvs = api.create_lvs(vg, parts=4) assert lvs[0][1]['extents'] == 250 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', vg_free_count='999' - ) - kwargs = api.create_lvs(vg, parts=4)[0][1] + kwargs = api.create_lvs(self.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', vg_free_count='999' - ) - lvs = api.create_lvs(vg) + lvs = api.create_lvs(self.vg) assert len(lvs) == 1 class TestVolumeGroupSizing(object): def setup(self): - self.vg = api.VolumeGroup( - vg_name='ceph', vg_free='1024g', - vg_free_count='261129' - ) + self.vg = api.VolumeGroup(vg_name='ceph', + vg_extent_size=1073741824, + vg_free_count=1024) def test_parts_and_size_errors(self): with pytest.raises(ValueError) as error: @@ -460,8 +449,7 @@ class TestVolumeGroupSizing(object): def test_extents_are_halfed_rounded_down(self): result = self.vg.sizing(size=512) - # the real extents would've given 130564.5 - assert result['extents'] == 130564 + assert result['extents'] == 512 def test_bit_less_size_rounds_down(self): result = self.vg.sizing(size=129) diff --git a/src/ceph-volume/ceph_volume/tests/devices/lvm/strategies/test_bluestore.py b/src/ceph-volume/ceph_volume/tests/devices/lvm/strategies/test_bluestore.py index a652aa28f1a..d64a7a56877 100644 --- a/src/ceph-volume/ceph_volume/tests/devices/lvm/strategies/test_bluestore.py +++ b/src/ceph-volume/ceph_volume/tests/devices/lvm/strategies/test_bluestore.py @@ -14,7 +14,7 @@ class TestSingleType(object): computed_osd = bluestore.SingleType.with_auto_devices(args, devices).computed['osds'][0] assert computed_osd['data']['percentage'] == 100 assert computed_osd['data']['parts'] == 1 - assert computed_osd['data']['human_readable_size'] == '5.66 GB' + assert computed_osd['data']['human_readable_size'] == '5.00 GB' assert computed_osd['data']['path'] == '/dev/sda' def test_sdd_device_is_large_enough(self, fakedevice, factory): @@ -26,7 +26,7 @@ class TestSingleType(object): computed_osd = bluestore.SingleType.with_auto_devices(args, devices).computed['osds'][0] assert computed_osd['data']['percentage'] == 100 assert computed_osd['data']['parts'] == 1 - assert computed_osd['data']['human_readable_size'] == '5.66 GB' + assert computed_osd['data']['human_readable_size'] == '5.00 GB' assert computed_osd['data']['path'] == '/dev/sda' def test_device_cannot_have_many_osds_per_device(self, fakedevice, factory): 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 index bc9afb70681..710c09288b7 100644 --- 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 @@ -165,8 +165,9 @@ class TestMixedType(object): # 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" + vg_name='fast', lv_name='foo', + lv_path='/dev/vg/foo', lv_tags="ceph.type=data", + vg_extent_size=1024*1024*1024, vg_free_count=7 ) ])