예제 #1
0
 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
예제 #2
0
 def setup(self):
     self.vg = api.VolumeGroup(vg_name='ceph',
                               vg_extent_size=1073741824,
                               vg_free_count=1024)
예제 #3
0
 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
예제 #4
0
 def setup(self):
     self.vg = api.VolumeGroup(vg_name='ceph',
                               vg_free='1024g',
                               vg_free_count='261129')
예제 #5
0
 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'
예제 #6
0
 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)
예제 #7
0
 def test_integer_gets_produced_whitespace(self):
     vg = api.VolumeGroup(vg_name='nosize', vg_free=' 100g ')
     assert vg.free == 100
예제 #8
0
 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)
예제 #9
0
 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")
예제 #10
0
 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
예제 #11
0
 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
예제 #12
0
 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
예제 #13
0
 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
예제 #14
0
 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)
예제 #15
0
 def test_no_g_in_output(self):
     vg = api.VolumeGroup(vg_name='nosize', vg_free='')
     with pytest.raises(RuntimeError):
         vg.free
예제 #16
0
파일: test_lvm.py 프로젝트: zxgm/ceph
 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')
예제 #17
0
 def test_size_without_g(self):
     vg = api.VolumeGroup(vg_name='nosize', vg_free='1')
     with pytest.raises(RuntimeError):
         vg.free
예제 #18
0
파일: test_lvm.py 프로젝트: zxgm/ceph
 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 == []
예제 #19
0
 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)
예제 #20
0
 def test_volume_group_no_empty_name(self):
     with pytest.raises(ValueError):
         api.VolumeGroup(vg_name='')
예제 #21
0
 def test_integer_gets_rounded_down(self):
     vg = api.VolumeGroup(vg_name='nosize', vg_free='100.99g')
     assert vg.free == 100
예제 #22
0
 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
예제 #23
0
 def setup(self):
     self.foo_volume = api.VolumeGroup(vg_name='foo', lv_tags='')
예제 #24
0
 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