Adam Litke has uploaded a new change for review.
Change subject: tests: Add FakeLVM LV properties tests ......................................................................
tests: Add FakeLVM LV properties tests
Building on the example environment in FakeLVMSimpleVGTests we create a single logical volume. We then verify that the properties and attributes of that LV match what is returned by the real lvm module. Some problems were found in FakeLVM and are resolved here.
Change-Id: I1bca30db49db84fc5d42ff8736a4c69f17b17247 Signed-off-by: Adam Litke alitke@redhat.com --- M tests/storagefakelib.py M tests/storagefakelibTests.py 2 files changed, 72 insertions(+), 3 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/59/47859/1
diff --git a/tests/storagefakelib.py b/tests/storagefakelib.py index 1eb0c86..52dce33 100644 --- a/tests/storagefakelib.py +++ b/tests/storagefakelib.py @@ -76,6 +76,13 @@
def createLV(self, vgName, lvName, size, activate=True, contiguous=False, initialTag=None): + # Size is expected as a string in MB, convert to a string in bytes. + size = str(int(size) << 20) + + # devices is hard to emulate properly (must have a PE allocator that + # works the same as for LVM). Since we don't need this value, use None + devices = None + lv_attr = dict(voltype='-', permission='w', allocations='i', @@ -90,20 +97,22 @@ attr=lv_attr, size=str(size), seg_start_pe='0', - devices='', - tags=[], + devices=None, + tags=(), writeable=True, opened=False, active=True)
vg_dict = self.lvmd.setdefault(vgName, {}) vg_dict[lvName] = lv_md + lv_count = int(self.vgmd[vgName]['lv_count']) + 1 + self.vgmd[vgName]['lv_count'] = str(lv_count)
def activateLVs(self, vgName, lvNames): pass
def addtag(self, vg, lv, tag): - self.lvmd[vg][lv]['tags'].append(tag) + self.lvmd[vg][lv]['tags'] += (tag,)
def lvPath(self, vgName, lvName): return os.path.join(self.root, "dev", vgName, lvName) diff --git a/tests/storagefakelibTests.py b/tests/storagefakelibTests.py index 549c0a4..a80a9a2 100644 --- a/tests/storagefakelibTests.py +++ b/tests/storagefakelibTests.py @@ -30,6 +30,8 @@ class FakeLVMSimpleVGTests(VdsmTestCase): VG_NAME = '1ffead52-7363-4968-a8c7-3bc34504d452' DEVICES = ['360014054d75cb132d474c0eae9825766'] + LV_NAME = '54e3378a-b2f6-46ff-b2da-a9c82522a55e' + LV_SIZE_MB = 1024
@contextmanager def base_config(self): @@ -68,6 +70,28 @@ blockSD.STORAGE_UNREADY_DOMAIN_TAG, blockSD.VG_METADATASIZE) yield lvm + + def lv_config(self, lvm): + """ + Create a single logical volume on the base configuration. + + lvm.createLV('1ffead52-7363-4968-a8c7-3bc34504d452', + '54e3378a-b2f6-46ff-b2da-a9c82522a55e', 1024) + + print lvm.getLV('1ffead52-7363-4968-a8c7-3bc34504d452', + '54e3378a-b2f6-46ff-b2da-a9c82522a55e') + LV(uuid='89tSvh-HJl5-SO2K-O36t-3qkj-Zo2J-yugkjk', + name='54e3378a-b2f6-46ff-b2da-a9c82522a55e', + vg_name='1ffead52-7363-4968-a8c7-3bc34504d452', + attr=LV_ATTR(voltype='-', permission='w', allocations='i', + fixedminor='-', state='a', devopen='-', target='-', + zero='-'), + size='1073741824', seg_start_pe='0', + devices='/dev/mapper/360014054d75cb132d474c0eae9825766(0)', + tags=(), writeable=True, opened=False, active=True) + """ + lvm.createLV(self.VG_NAME, self.LV_NAME, str(self.LV_SIZE_MB)) + return lvm.getLV(self.VG_NAME, self.LV_NAME)
@permutations([ ['name', VG_NAME], @@ -135,3 +159,39 @@ with self.base_config() as lvm: pv = lvm.getPV(self.DEVICES[0]) self.assertIsNone(pv.pe_start) + + @permutations([ + ['name', LV_NAME], + ['vg_name', VG_NAME], + ['size', '1073741824'], + ['seg_start_pe', '0'], + ['tags', ()], + ['writeable', True], + ['opened', False], + ['active', True], + ]) + def test_lv_properties(self, var, val): + with self.base_config() as lvm: + lv = self.lv_config(lvm) + self.assertEqual(val, getattr(lv, var)) + + @permutations([ + ['voltype', '-'], + ['permission', 'w'], + ['allocations', 'i'], + ['fixedminor', '-'], + ['state', 'a'], + ['devopen', '-'], + ['target', '-'], + ['zero', '-'], + ]) + def test_lv_attributes(self, var, val): + with self.base_config() as lvm: + lv = self.lv_config(lvm) + self.assertEqual(val, getattr(lv.attr, var)) + + def test_lv_devices(self): + # As documented in FakeLVM, devices is not emulated and should be None + with self.base_config() as lvm: + lv = self.lv_config(lvm) + self.assertIsNone(lv.devices)
automation@ovirt.org has posted comments on this change.
Change subject: tests: Add FakeLVM LV properties tests ......................................................................
Patch Set 1:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: tests: Add FakeLVM LV properties tests ......................................................................
Patch Set 2:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: tests: Add FakeLVM LV properties tests ......................................................................
Patch Set 3:
* Update tracker::IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: tests: Add FakeLVM LV properties tests ......................................................................
Patch Set 4:
* Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
automation@ovirt.org has posted comments on this change.
Change subject: tests: Add FakeLVM LV properties tests ......................................................................
Patch Set 5:
* Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.5', 'ovirt-3.4', 'ovirt-3.3'])
Nir Soffer has posted comments on this change.
Change subject: tests: Add FakeLVM LV properties tests ......................................................................
Patch Set 5: Code-Review+2
Adam Litke has posted comments on this change.
Change subject: tests: Add FakeLVM LV properties tests ......................................................................
Patch Set 5: Verified+1
Dan Kenigsberg has submitted this change and it was merged.
Change subject: tests: Add FakeLVM LV properties tests ......................................................................
tests: Add FakeLVM LV properties tests
Building on the example environment in FakeLVMSimpleVGTests we create a single logical volume. We then verify that the properties and attributes of that LV match what is returned by the real lvm module. Some problems were found in FakeLVM and are resolved here.
Since createLV accepts the size in MB, two of the manifest_tests needed to be fixed.
Change-Id: I1bca30db49db84fc5d42ff8736a4c69f17b17247 Signed-off-by: Adam Litke alitke@redhat.com Reviewed-on: https://gerrit.ovirt.org/47859 Continuous-Integration: Jenkins CI Reviewed-by: Nir Soffer nsoffer@redhat.com --- M tests/manifest_tests.py M tests/storagefakelib.py M tests/storagefakelibTests.py 3 files changed, 58 insertions(+), 5 deletions(-)
Approvals: Adam Litke: Verified Nir Soffer: Looks good to me, approved Jenkins CI: Passed CI tests
automation@ovirt.org has posted comments on this change.
Change subject: tests: Add FakeLVM LV properties tests ......................................................................
Patch Set 6:
* Update tracker: IGNORE, no Bug-Url found * Set MODIFIED::IGNORE, no Bug-Url found.
vdsm-patches@lists.fedorahosted.org