Adam Litke has uploaded a new change for review. Change subject: wip: how can I test block volumes? ......................................................................
wip: how can I test block volumes? Change-Id: I4f584edabe61f6c5c473f722b7d1d20a505a5849 Signed-off-by: Adam Litke <ali...@redhat.com> --- M tests/storagetestlib.py M tests/volumeartifacts_tests.py M vdsm/storage/blockVolume.py 3 files changed, 42 insertions(+), 14 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/48/49548/1 diff --git a/tests/storagetestlib.py b/tests/storagetestlib.py index a3568b5..47cd3ab 100644 --- a/tests/storagetestlib.py +++ b/tests/storagetestlib.py @@ -53,7 +53,11 @@ fake_lvm.createVG(sduuid, devices, blockSD.STORAGE_DOMAIN_TAG, blockSD.VG_METADATASIZE) + os.makedirs(os.path.join(tmpdir, 'dev', sduuid)) fake_lvm.createLV(sduuid, sd.METADATA, blockSD.SD_METADATA_SIZE) + with open(fake_lvm.lvPath(sduuid, sd.METADATA), 'w') as f: + os.ftruncate(f.fileno(), blockSD.SD_METADATA_SIZE << 20) + # Create the rest of the special LVs for metafile, sizemb in sd.SPECIAL_VOLUME_SIZES_MIB.iteritems(): diff --git a/tests/volumeartifacts_tests.py b/tests/volumeartifacts_tests.py index 9824973..7275e57 100644 --- a/tests/volumeartifacts_tests.py +++ b/tests/volumeartifacts_tests.py @@ -29,11 +29,6 @@ from storage import blockSD, fileSD, image, volume, blockVolume, fileVolume -class FakeDomainManifest(object): - def __init__(self, sduuid): - self.sdUUID = sduuid - - class VolumeArtifactsTestsMixin(object): def setUp(self): self.sduuid = str(uuid.uuid4()) @@ -104,9 +99,13 @@ class FakeBlockVolumeMetadata(blockVolume.BlockVolumeMetadata): - @classmethod - def _putMetadata(cls, metaId, meta): - fake_metadata[metaId] = meta + def __init__(self, repoPath, sdUUID, imgUUID, volUUID): + super(FakeBlockVolumeMetadata, self).__init__( + repoPath, sdUUID, imgUUID, volUUID) + + #@classmethod + #def _putMetadata(cls, metaId, meta): + # fake_metadata[('vol_md', metaId)] = meta class BlockVolumeArtifactsTests(VolumeArtifactsTestsMixin, VdsmTestCase): @@ -120,13 +119,24 @@ lvm = FakeLVM(tmpdir) with MonkeyPatchScope([ (blockSD, 'lvm', lvm), + (blockSD, 'selectMetadata', self.fake_select_metadata), (blockVolume, 'lvm', lvm), - (blockVolume, 'BlockVolumeMetadata', - FakeBlockVolumeMetadata)]): + #(blockVolume, 'BlockVolumeMetadata', + # FakeBlockVolumeMetadata), + #(image.ImageManifest, 'create_image_dir', + # self.fake_create_image_dir)]): + ]): manifest = make_blocksd(tmpdir, lvm, sduuid=self.sduuid) + fake_metadata[('sd_md', manifest.sdUUID)] = manifest._metadata self._fake_metadata = {} yield manifest + def fake_select_metadata(self, sduuid): + return fake_metadata[('sd_md', sduuid)] + + def fake_create_image_dir(self, sd_id, img_id): + pass + def test_size_adjusted(self): # Test that size is rounded up to LVM granularity pass diff --git a/vdsm/storage/blockVolume.py b/vdsm/storage/blockVolume.py index 6af171b..d4fa8f2 100644 --- a/vdsm/storage/blockVolume.py +++ b/vdsm/storage/blockVolume.py @@ -78,7 +78,16 @@ vol_id) def validate(self): - raise volume.VolumeArtifactsNotFound() + try: + lv = lvm.getLV(self.domain_manifest.sdUUID, self.vol_id) + except se.LogicalVolumeDoesNotExistError: + self.log.error("LV artifact missing: %s/%s", + self.domain_manifest.sdUUID, self.vol_id) + raise volume.VolumeArtifactsNotFound() + if TAG_VOL_ARTIFACT not in lv.tags: + self.log.error("LV missing TAG_VOL_ARTIFACT tag: %s/%s", + self.domain_manifest.sdUUID, self.vol_id) + raise volume.VolumeArtifactsNotFound() def create(self, size, vol_format, disk_type, desc, parent_vol_id=volume.BLANK_UUID): @@ -98,8 +107,13 @@ tags = [TAG_VOL_ARTIFACT, TAG_PREFIX_PARENT + parent_vol_id, TAG_PREFIX_IMAGE + self.img_id] - lvm.createLV(self.domain_manifest.sdUUID, self.vol_id, lv_size, - activate=True, initialTags=tags) + try: + lvm.createLV(self.domain_manifest.sdUUID, self.vol_id, lv_size, + activate=True, initialTags=tags) + except se.CannotCreateLogicalVolume as e: + self.log.error("Failed to create LV %s/%s: %s", + self.domain_manifest.sdUUID, self.vol_id, e) + raise volume.CannotCreateVolumeArtifacts() # Create the metadata artifact. with self.domain_manifest.acquireVolumeMetadataSlot( @@ -119,7 +133,7 @@ BlockVolumeMetadata.newVolumeLease(meta_id, self.domain_manifest.sdUUID, self.vol_id) - + repo_path = self.domain_manifest.getRepoPath() image_manifest = image.ImageManifest(repo_path) img_path = image_manifest.create_image_dir(self.domain_manifest.sdUUID, -- To view, visit https://gerrit.ovirt.org/49548 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4f584edabe61f6c5c473f722b7d1d20a505a5849 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke <ali...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches