Adam Litke has uploaded a new change for review.
Change subject: tests: Streamline fake blockSD creation ......................................................................
tests: Streamline fake blockSD creation
The BlockManifestTests test various functions of the BlockStorageDomainManifest by creating a mock blockSD using FakeLVM. Some tests created the storage domain's VG and others did not. None of these tests created the other internal LVs needed for a properly functioning SD (ie. metadata, ids, etc.). In order to unify the testing environment and prepare for additional sophistication in FakeLVM, converge make_vg and make_blocksd_manifest into a new function make_blocksd which does everything needed. While sometimes we will set up more than is strictly necessary for some tests, the advantage of unified setup is far more important.
Change-Id: I0cc0aef3a77da9e7d81ded85f0c7e8b21cb2b990 Signed-off-by: Adam Litke alitke@redhat.com --- M tests/manifest_tests.py M tests/storagetestlib.py 2 files changed, 26 insertions(+), 36 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/14/47914/1
diff --git a/tests/manifest_tests.py b/tests/manifest_tests.py index 57d5c41..1219769 100644 --- a/tests/manifest_tests.py +++ b/tests/manifest_tests.py @@ -23,8 +23,7 @@ from testlib import VdsmTestCase, namedTemporaryDir, make_file from monkeypatch import MonkeyPatchScope from storagefakelib import FakeLVM -from storagetestlib import make_filesd_manifest, make_blocksd_manifest, \ - make_file_volume, make_vg +from storagetestlib import make_filesd_manifest, make_blocksd, make_file_volume
from storage import sd, blockSD, blockVolume
@@ -79,7 +78,7 @@ with namedTemporaryDir() as tmpdir: lvm = FakeLVM(tmpdir) with MonkeyPatchScope([(blockSD, 'lvm', lvm)]): - manifest = make_blocksd_manifest(tmpdir) + manifest = make_blocksd(tmpdir, lvm) vg_name = manifest.sdUUID make_file(lvm.lvPath(vg_name, 'metadata')) self.assertIsInstance(manifest.getReadDelay(), float) @@ -89,8 +88,8 @@ with namedTemporaryDir() as tmpdir: lvm = FakeLVM(tmpdir) with MonkeyPatchScope([(blockSD, 'lvm', lvm)]): - manifest = make_blocksd_manifest(tmpdir) - vg_name = make_vg(lvm, manifest) + manifest = make_blocksd(tmpdir, lvm) + vg_name = manifest.sdUUID lv_name = str(uuid.uuid4()) lvm.createLV(vg_name, lv_name, VOLSIZE / MB) lvm.fake_lv_symlink_create(vg_name, lv_name) @@ -102,10 +101,9 @@ with namedTemporaryDir() as tmpdir: lvm = FakeLVM(tmpdir) with MonkeyPatchScope([(blockSD, 'lvm', lvm)]): - manifest = make_blocksd_manifest(tmpdir) - vg_name = make_vg(lvm, manifest) + manifest = make_blocksd(tmpdir, lvm) lv_name = str(uuid.uuid4()) - lvm.createLV(vg_name, lv_name, VOLSIZE / MB) + lvm.createLV(manifest.sdUUID, lv_name, VOLSIZE / MB) self.assertEqual(VOLSIZE, manifest.getVSize('<imgUUID>', lv_name))
@@ -114,7 +112,7 @@ lvm = FakeLVM(tmpdir) with MonkeyPatchScope([(blockSD, 'lvm', lvm)]): metadata = {sd.DMDK_VERSION: 3} - manifest = make_blocksd_manifest(tmpdir, metadata) + manifest = make_blocksd(tmpdir, lvm, metadata=metadata) metadata[sd.DMDK_SDUUID] = manifest.sdUUID self.assertEquals(manifest.sdUUID, manifest.getMetaParam(sd.DMDK_SDUUID)) @@ -123,7 +121,7 @@ with namedTemporaryDir() as tmpdir: lvm = FakeLVM(tmpdir) with MonkeyPatchScope([(blockSD, 'lvm', lvm)]): - manifest = make_blocksd_manifest(tmpdir) + manifest = make_blocksd(tmpdir, lvm) self.assertEquals(512, manifest.logBlkSize) self.assertEquals(512, manifest.phyBlkSize)
@@ -134,7 +132,7 @@ metadata = {sd.DMDK_VERSION: 3, blockSD.DMDK_LOGBLKSIZE: 2048, blockSD.DMDK_PHYBLKSIZE: 1024} - manifest = make_blocksd_manifest(tmpdir, metadata) + manifest = make_blocksd(tmpdir, lvm, metadata=metadata) self.assertEquals(2048, manifest.logBlkSize) self.assertEquals(1024, manifest.phyBlkSize)
@@ -145,8 +143,7 @@ with namedTemporaryDir() as tmpdir: lvm = FakeLVM(tmpdir) with MonkeyPatchScope([(blockSD, 'lvm', lvm)]): - manifest = make_blocksd_manifest(tmpdir) - make_vg(lvm, manifest) + manifest = make_blocksd(tmpdir, lvm) lvs = ('0b6287f0-3679-4c4d-8be5-9bbfe3ec9c1f', 'ea13af29-b64a-4d1a-b35f-3e6ab15c3b04') for lv, offset in zip(lvs, [4, 7]): @@ -160,8 +157,7 @@ with namedTemporaryDir() as tmpdir: lvm = FakeLVM(tmpdir) with MonkeyPatchScope([(blockSD, 'lvm', lvm)]): - manifest = make_blocksd_manifest(tmpdir) - make_vg(lvm, manifest) + manifest = make_blocksd(tmpdir, lvm) with manifest.acquireVolumeMetadataSlot(None, 1): acquired = manifest._lvTagMetaSlotLock.acquire(False) self.assertFalse(acquired) diff --git a/tests/storagetestlib.py b/tests/storagetestlib.py index 2f64e0a..f3585cc 100644 --- a/tests/storagetestlib.py +++ b/tests/storagetestlib.py @@ -35,38 +35,32 @@ yield
-def make_blocksd_manifest(tmpdir=None, metadata=None, sduuid=None): +def make_blocksd(tmpdir, fake_lvm, sduuid=None, devices=None, metadata=None): if sduuid is None: sduuid = str(uuid.uuid4()) + if devices is None: + devices = get_random_devices() if metadata is None: metadata = FakeMetadata({sd.DMDK_VERSION: 3}) + + fake_lvm.createVG(sduuid, devices, blockSD.STORAGE_DOMAIN_TAG, + blockSD.VG_METADATASIZE) + fake_lvm.createLV(sduuid, sd.METADATA, blockSD.SD_METADATA_SIZE) + + # Create the rest of the special LVs + for metafile, sizemb in sd.SPECIAL_VOLUME_SIZES_MIB.iteritems(): + fake_lvm.createLV(sduuid, metafile, sizemb) + manifest = blockSD.BlockStorageDomainManifest(sduuid, metadata) - if tmpdir is not None: - manifest.domaindir = tmpdir - os.makedirs(os.path.join(manifest.domaindir, sduuid, sd.DOMAIN_IMAGES)) + manifest.domaindir = tmpdir + os.makedirs(os.path.join(manifest.domaindir, sduuid, sd.DOMAIN_IMAGES)) + return manifest
def get_random_devices(count=NR_PVS): return ['/dev/mapper/{0}'.format(os.urandom(16).encode('hex')) for _ in range(count)] - - -def make_vg(fake_lvm, manifest, devices=None): - vg_name = manifest.sdUUID - if devices is None: - devices = get_random_devices() - fake_lvm.createVG(vg_name, devices, blockSD.STORAGE_UNREADY_DOMAIN_TAG, - blockSD.VG_METADATASIZE) - fake_lvm.createLV(vg_name, sd.METADATA, blockSD.SD_METADATA_SIZE) - - # Fake the PV information for our metadata LV (example lvs session follows) - # # lvs -o devices b19d16a0-06e1-4c92-b959-2019f503c8ac/metadata - # Devices - # /dev/mapper/360014059e671b7fc2c44169a58c00289(0) - fake_lvm.lvmd[vg_name][sd.METADATA]['devices'] = \ - '{0}(0)'.format(devices[0]) - return vg_name
def get_metafile_path(domaindir):
automation@ovirt.org has posted comments on this change.
Change subject: tests: Streamline fake blockSD creation ......................................................................
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: Streamline fake blockSD creation ......................................................................
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: Streamline fake blockSD creation ......................................................................
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: Streamline fake blockSD creation ......................................................................
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'])
Nir Soffer has posted comments on this change.
Change subject: tests: Streamline fake blockSD creation ......................................................................
Patch Set 4: Code-Review+2
Adam Litke has posted comments on this change.
Change subject: tests: Streamline fake blockSD creation ......................................................................
Patch Set 4: Verified+1
Dan Kenigsberg has submitted this change and it was merged.
Change subject: tests: Streamline fake blockSD creation ......................................................................
tests: Streamline fake blockSD creation
The BlockManifestTests test various functions of the BlockStorageDomainManifest by creating a mock blockSD using FakeLVM. Some tests created the storage domain's VG and others did not. None of these tests created the other internal LVs needed for a properly functioning SD (ie. metadata, ids, etc.). In order to unify the testing environment and prepare for additional sophistication in FakeLVM, converge make_vg and make_blocksd_manifest into a new function make_blocksd which does everything needed. While sometimes we will set up more than is strictly necessary for some tests, the advantage of unified setup is far more important.
Change-Id: I0cc0aef3a77da9e7d81ded85f0c7e8b21cb2b990 Signed-off-by: Adam Litke alitke@redhat.com Reviewed-on: https://gerrit.ovirt.org/47914 Continuous-Integration: Jenkins CI Reviewed-by: Nir Soffer nsoffer@redhat.com --- M tests/manifest_tests.py M tests/storagetestlib.py 2 files changed, 26 insertions(+), 36 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: Streamline fake blockSD creation ......................................................................
Patch Set 5:
* Update tracker: IGNORE, no Bug-Url found * Set MODIFIED::IGNORE, no Bug-Url found.
vdsm-patches@lists.fedorahosted.org