Lee Yarwood has uploaded a new change for review.
Change subject: [WIP] BZ#748386 - qemuConvert test cases ......................................................................
[WIP] BZ#748386 - qemuConvert test cases
Adds some simple qemu-img tests against volume.qemuConvert() to ensure volumes remain the correct format after being converted.
Change-Id: I1c9f302928c246f7ce195d169f8d5a533df1a344 Signed-off-by: Lee Yarwood lyarwood@redhat.com --- A tests/qemuImgTests.py A vdsm/storage/fakeVolume.py 2 files changed, 214 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/90/9290/1
diff --git a/tests/qemuImgTests.py b/tests/qemuImgTests.py new file mode 100644 index 0000000..e1cc70c --- /dev/null +++ b/tests/qemuImgTests.py @@ -0,0 +1,148 @@ +# +# Copyright 2012 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +# Refer to the README and COPYING files for full details of the license +# + +from testrunner import VdsmTestCase as TestCase + +import tempfile +import uuid +import os + + +from storage.threadLocal import vars +from storage.fakeVolume import FakeFileVolume +import storage.task as task +import storage.volume as volume +import storage.misc as misc + +EXT_QEMUIMG = '/bin/qemu-img' +EXT_DD = '/bin/dd' +VOL_SIZE = "10M" +VOL_ALLOC = "20" + +class FileVolumes(): + + def __init__(self): + self.dir = tempfile.mkdtemp() + self.sduuid = str(uuid.uuid4()) + self.imguuid = str(uuid.uuid4()) + self.repo = self.dir + "/" + self.sduuid + "/images/" + self.imguuid + os.makedirs(self.repo) + + def genPathUUID(self): + u = str(uuid.uuid4()) + p = self.repo + "/" + u + return p, u + + + def createCOW(self): + path, voluuid = self.genPathUUID() + misc.execCmd([EXT_QEMUIMG, "create", "-f", "qcow2", path, VOL_SIZE],sync=False) + return FakeFileVolume(repoPath=self.dir, sdUUID=self.sduuid, imgUUID=self.imguuid, volUUID=voluuid, + volFormat=volume.COW_FORMAT, volPath=path) + + def createRAW(self): + path, voluuid = self.genPathUUID() + misc.execCmd([EXT_QEMUIMG, "create", "-f", "raw", path, VOL_SIZE],sync=False) + return FakeFileVolume(repoPath=self.dir, sdUUID=self.sduuid, imgUUID=self.imguuid, volUUID=voluuid, + volFormat=volume.RAW_FORMAT, volPath=path) + + def createCOWPrealloc(self): + v = self.createCOW() + misc.execCmd([EXT_DD, "if=/dev/zero", "of=%s" % v.getVolumePath(), "bs=512"]) + return v + + + def createCOWChild(self,parent): + path, voluuid = self.genPathUUID() + misc.execCmd([EXT_QEMUIMG, "create", "-f", "qcow2", "-o", "backing_file=%s/%s,backing_fmt=raw" % + (self.repo,parent.volUUID), self.repo + "/" + voluuid, VOL_SIZE],sync=False) + fake = FakeFileVolume(repoPath=self.dir, sdUUID=self.sduuid, imgUUID=self.imguuid, volUUID=voluuid, + volFormat=volume.COW_FORMAT, volPath=path) + # Hack to avoid a call to sdc.produce() later when we try to find the parent. + fake.setParent(parent.volUUID) + fake.setParentVolume(parent) + return fake + + def cleanUp(self): + os.rmdir(self.dir) + + +class qemuImgRebaseTestCase(TestCase): + """ + + """ + +class qemuImgCreateTestCase(TestCase): + """ + + """ + +class qemuImgConvertTestCase(TestCase): + + + def runQemuConvert(self, src, dst): + + vars.task = task.Task(id=None, name='qemuImgTests') + try: + (rc, out, err) = volume.qemuConvert(src, dst, vars.task.aborting) + self.assertFalse(rc) + except Exception: + self.fail() + + + def testFileQemuConvert(self): + # create the repo + t = FileVolumes() + + # RAW to RAW + src = t.createRAW() + dst = t.createRAW() + self.runQemuConvert(src, dst) + + # QCOW2 to RAW + #src = t.createCOW() + #dst = t.createRAW() + #self.runQemuConvert(src, dst) + + # RAW to QCOW2 + #src = t.createRAW() + #dst = t.createCOW() + #self.runQemuConvert(src, dst) + + # RAW<-QCOW2 to RAW<-QCOW2 + parent = t.createRAW() + src = t.createCOWChild(parent) + dst = t.createCOW() + self.runQemuConvert(src, dst) + + # Convert a COW parent child to another COW + # RAW<-QCOW2<-QCOW2 to RAW<-QCOW2<-QCOW2 + rawParent = t.createRAW() + src = t.createCOWChild(rawParent) + cowChild = t.createCOWChild(src) + dst = t.createCOW() + self.runQemuConvert(src,dst) + + + + + def testBlockQemuConvert(self): + pass + diff --git a/vdsm/storage/fakeVolume.py b/vdsm/storage/fakeVolume.py new file mode 100644 index 0000000..72516b7 --- /dev/null +++ b/vdsm/storage/fakeVolume.py @@ -0,0 +1,66 @@ +# +# Copyright 2012 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +# Refer to the README and COPYING files for full details of the license +# + +import volume +import misc + +class FakeFileVolume(volume.Volume): + """ + A fake file volume class to aid with testing. + """ + + def __init__(self, repoPath, sdUUID, imgUUID, volUUID, volFormat, volPath): + volume.Volume.__init__(self, repoPath, sdUUID, imgUUID, volUUID) + + self.md = {"SIZE": None,"TYPE":None,"FORMAT":None,"DISKTYPE":None,"VOLTYPE":None, + "PUUID":None,"DOMAIN":None,"CTIME":None,"IMAGE":None,"DESCRIPTION":None, + "LEGALITY":None,"MTIME":None,"ILLEGAL":None,"LEGAL":None,"FAKE":None} + + self.setFormat(volFormat) + self.setVolumePath(volPath) + self.parentVolume = None + + def validateImagePath(self): + pass + + def validateVolumePath(self): + pass + + def setVolumePath(self,volPath): + self.volumePath = volPath + + def setParent(self, puuid): + self.setMetaParam(volume.PUUID, puuid) + + def getParent(self): + return self.getMetaParam(volume.PUUID) + + def setParentVolume(self,parent): + self.parentVolume = parent + + def getParentVolume(self): + return self.parentVolume + + def setMetadata(self, m, mid=None): + for k,v in m.iteritems(): + self.md[k] = v + + def getMetadata(self): + return self.md
-- To view, visit http://gerrit.ovirt.org/9290 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange Gerrit-Change-Id: I1c9f302928c246f7ce195d169f8d5a533df1a344 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Lee Yarwood lyarwood@redhat.com
oVirt Jenkins CI Server has posted comments on this change.
Change subject: [WIP] BZ#748386 - qemuConvert test cases ......................................................................
Patch Set 1:
Build Started http://jenkins.ovirt.org/job/vdsm_unit_tests_manual_gerrit/57/ (1/2)
-- To view, visit http://gerrit.ovirt.org/9290 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I1c9f302928c246f7ce195d169f8d5a533df1a344 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Lee Yarwood lyarwood@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: [WIP] BZ#748386 - qemuConvert test cases ......................................................................
Patch Set 1:
Build Started http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/34/ (2/2)
-- To view, visit http://gerrit.ovirt.org/9290 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I1c9f302928c246f7ce195d169f8d5a533df1a344 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Lee Yarwood lyarwood@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: [WIP] BZ#748386 - qemuConvert test cases ......................................................................
Patch Set 1: I would prefer that you didn't submit this
Build Unstable
http://jenkins.ovirt.org/job/vdsm_unit_tests_manual_gerrit/57/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/34/ : UNSTABLE
-- To view, visit http://gerrit.ovirt.org/9290 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I1c9f302928c246f7ce195d169f8d5a533df1a344 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Lee Yarwood lyarwood@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
Lee Yarwood has posted comments on this change.
Change subject: [WIP] BZ#748386 - qemuConvert test cases ......................................................................
Patch Set 1:
This is very much a WIP at present but I wanted to at least start pushing to gerrit for viability.
I will will up with a thread to vdsm-devel regarding the best way to write tests against volumes shortly.
-- To view, visit http://gerrit.ovirt.org/9290 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I1c9f302928c246f7ce195d169f8d5a533df1a344 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Lee Yarwood lyarwood@redhat.com Gerrit-Reviewer: Lee Yarwood lyarwood@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: [WIP] BZ#748386 - qemuConvert test cases ......................................................................
Patch Set 2:
Build Started http://jenkins.ovirt.org/job/vdsm_unit_tests_manual_gerrit/394/ (1/2)
-- To view, visit http://gerrit.ovirt.org/9290 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I1c9f302928c246f7ce195d169f8d5a533df1a344 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Lee Yarwood lyarwood@redhat.com Gerrit-Reviewer: Lee Yarwood lyarwood@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: [WIP] BZ#748386 - qemuConvert test cases ......................................................................
Patch Set 2:
Build Started http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/360/ (2/2)
-- To view, visit http://gerrit.ovirt.org/9290 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I1c9f302928c246f7ce195d169f8d5a533df1a344 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Lee Yarwood lyarwood@redhat.com Gerrit-Reviewer: Lee Yarwood lyarwood@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: [WIP] BZ#748386 - qemuConvert test cases ......................................................................
Patch Set 2: Fails
Build Failed
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/360/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_manual_gerrit/394/ : FAILURE
-- To view, visit http://gerrit.ovirt.org/9290 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: I1c9f302928c246f7ce195d169f8d5a533df1a344 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Lee Yarwood lyarwood@redhat.com Gerrit-Reviewer: Lee Yarwood lyarwood@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
Lee Yarwood has abandoned this change.
Change subject: [WIP] BZ#748386 - qemuConvert test cases ......................................................................
Patch Set 2: Abandoned
http://gerrit.ovirt.org/#/c/10979/
-- To view, visit http://gerrit.ovirt.org/9290 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: abandon Gerrit-Change-Id: I1c9f302928c246f7ce195d169f8d5a533df1a344 Gerrit-PatchSet: 2 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Lee Yarwood lyarwood@redhat.com Gerrit-Reviewer: Lee Yarwood lyarwood@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
vdsm-patches@lists.fedorahosted.org