def test_find_the_correct_one(self, volume_groups): volume1 = api.VolumeGroup(vg_name='volume1', lv_tags='') volume2 = api.VolumeGroup(vg_name='volume2', lv_tags='') volume_groups.append(volume1) volume_groups.append(volume2) assert volume_groups.get(vg_name='volume1') == volume1
def setup(self): self.vg = api.VolumeGroup(vg_name='ceph', vg_extent_size=1073741824, vg_free_count=1024)
def test_single_vg_is_matched(self, volume_groups, monkeypatch): FooVG = api.VolumeGroup(vg_name='foo') volume_groups.append(FooVG) monkeypatch.setattr(api, 'VolumeGroups', lambda: volume_groups) assert api.get_vg(vg_name='foo') == FooVG
def setup(self): self.vg = api.VolumeGroup(vg_name='ceph', vg_free='1024g', vg_free_count='261129')
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_error_message(self): vg = api.VolumeGroup(vg_name='nosize', vg_free='F') with pytest.raises(RuntimeError) as error: vg.free assert "Unable to convert vg size to integer: 'F'" in str(error)
def test_integer_gets_produced_whitespace(self): vg = api.VolumeGroup(vg_name='nosize', vg_free=' 100g ') assert vg.free == 100
def test_unable_to_allocate_past_free_size(self): vg = api.VolumeGroup(vg_name='ceph', vg_free='1024g') with pytest.raises(exceptions.SizeAllocationError): vg.sizing(size=2048)
def setup(self): self.foo_volume = api.Volume(lv_name='foo', lv_path='/path', vg_name='foo_group', lv_tags='') self.foo_group = api.VolumeGroup(vg_name='foo_group', vg_extent_size="4194304", vg_extent_count="100", vg_free_count="100")
def test_half_size_produces_round_sizes(self): vg = api.VolumeGroup(vg_name='ceph', vg_free='1024g') result = vg.sizing(size=512) assert result['sizes'] == 512 assert result['percentages'] == 50 assert result['parts'] == 2
def test_bit_less_size_rounds_down(self): vg = api.VolumeGroup(vg_name='ceph', vg_free='1024g') result = vg.sizing(size=129) assert result['sizes'] == 146 assert result['percentages'] == 14 assert result['parts'] == 7
def test_two_parts_produces_half_size(self): vg = api.VolumeGroup(vg_name='ceph', vg_free='1024g') result = vg.sizing(parts=2) assert result['sizes'] == 512
def test_two_parts_produces_50_percent(self): vg = api.VolumeGroup(vg_name='ceph', vg_free='1024g') result = vg.sizing(parts=2) assert result['percentages'] == 50
def test_parts_and_size_errors(self): vg = api.VolumeGroup(vg_name='ceph', vg_free='1024g') with pytest.raises(ValueError) as error: vg.sizing(parts=4, size=10) assert "Cannot process sizing" in str(error)
def test_no_g_in_output(self): vg = api.VolumeGroup(vg_name='nosize', vg_free='') with pytest.raises(RuntimeError): vg.free
def test_volume_has_multiple_matches(self, volume_groups): volume1 = volume2 = api.VolumeGroup(vg_name='foo', lv_path='/dev/vg/lv', lv_tags='') volume_groups.append(volume1) volume_groups.append(volume2) with pytest.raises(exceptions.MultipleVGsError): volume_groups.get(vg_name='foo')
def test_size_without_g(self): vg = api.VolumeGroup(vg_name='nosize', vg_free='1') with pytest.raises(RuntimeError): vg.free
def test_filter_by_tag_does_not_match_one(self, volume_groups): vg_tags = "ceph.group=dmcache,ceph.disk_type=ssd" osd = api.VolumeGroup(vg_name='volume1', vg_path='/dev/vg/lv', vg_tags=vg_tags) volume_groups.append(osd) volume_groups = volume_groups.filter(vg_tags={'ceph.group': 'data', 'ceph.disk_type': 'ssd'}) assert volume_groups == []
def test_invalid_float(self): vg = api.VolumeGroup(vg_name='nosize', vg_free=' g') with pytest.raises(RuntimeError) as error: vg.free assert "Unable to convert to integer: ' '" in str(error.value)
def test_volume_group_no_empty_name(self): with pytest.raises(ValueError): api.VolumeGroup(vg_name='')
def test_integer_gets_rounded_down(self): vg = api.VolumeGroup(vg_name='nosize', vg_free='100.99g') assert vg.free == 100
def test_integer_gets_produced(self): vg = api.VolumeGroup(vg_name='nosize', vg_free_count=100, vg_extent_size=4194304) assert vg.free == 100 * 4194304
def setup(self): self.foo_volume = api.VolumeGroup(vg_name='foo', lv_tags='')
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