summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorRafi Khardalian <rafi@metacloud.com>2013-05-29 21:26:19 +0000
committerRafi Khardalian <rafi@metacloud.com>2013-06-05 22:00:12 +0000
commit6e768363450774cfee90e41aa5c40af780d3e04a (patch)
tree23c62b22088edb250028f3c1f110b136f7043daf /nova/tests
parentc9695c1d734593a30c5b36626c73e4eb1cb277bc (diff)
Regenerate missing resized backing files
Fixes bug 1185588 The only way to reliably determine whether we are using a legacy (pre-Grizzly) backing structure is to look at the backing file reference for the instance/disk itself. Thus, if we determine the backing file contains an underscore, we use the value following it as our legacy_backing_size, which is then used to create the necessary backing file. Change-Id: I145f71068c972a604e5361ae79d6315286136786
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/virt/libvirt/test_imagebackend.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/nova/tests/virt/libvirt/test_imagebackend.py b/nova/tests/virt/libvirt/test_imagebackend.py
index 50aacba2f..fa708f4f4 100644
--- a/nova/tests/virt/libvirt/test_imagebackend.py
+++ b/nova/tests/virt/libvirt/test_imagebackend.py
@@ -258,6 +258,7 @@ class Qcow2TestCase(_ImageTestCase, test.TestCase):
if self.OLD_STYLE_INSTANCE_PATH:
os.path.exists(self.OLD_STYLE_INSTANCE_PATH).AndReturn(False)
os.path.exists(self.TEMPLATE_PATH).AndReturn(False)
+ os.path.exists(self.PATH).AndReturn(False)
imagebackend.disk.get_disk_size(self.TEMPLATE_PATH
).AndReturn(self.SIZE)
os.path.exists(self.PATH).AndReturn(False)
@@ -279,6 +280,7 @@ class Qcow2TestCase(_ImageTestCase, test.TestCase):
if self.OLD_STYLE_INSTANCE_PATH:
os.path.exists(self.OLD_STYLE_INSTANCE_PATH).AndReturn(False)
os.path.exists(self.TEMPLATE_PATH).AndReturn(False)
+ os.path.exists(self.PATH).AndReturn(False)
imagebackend.disk.get_disk_size(self.TEMPLATE_PATH
).AndReturn(self.SIZE)
self.mox.ReplayAll()
@@ -288,6 +290,35 @@ class Qcow2TestCase(_ImageTestCase, test.TestCase):
image.create_image, fn, self.TEMPLATE_PATH, 1)
self.mox.VerifyAll()
+ def test_generate_resized_backing_files(self):
+ fn = self.prepare_mocks()
+ fn(target=self.TEMPLATE_PATH)
+ self.mox.StubOutWithMock(os.path, 'exists')
+ self.mox.StubOutWithMock(imagebackend.disk, 'get_disk_size')
+ self.mox.StubOutWithMock(imagebackend.libvirt_utils,
+ 'get_disk_backing_file')
+ if self.OLD_STYLE_INSTANCE_PATH:
+ os.path.exists(self.OLD_STYLE_INSTANCE_PATH).AndReturn(False)
+ os.path.exists(self.TEMPLATE_PATH).AndReturn(False)
+ os.path.exists(self.PATH).AndReturn(True)
+
+ imagebackend.libvirt_utils.get_disk_backing_file(self.PATH)\
+ .AndReturn(self.QCOW2_BASE)
+ os.path.exists(self.QCOW2_BASE).AndReturn(False)
+ imagebackend.libvirt_utils.copy_image(self.TEMPLATE_PATH,
+ self.QCOW2_BASE)
+ imagebackend.disk.extend(self.QCOW2_BASE, self.SIZE)
+
+ imagebackend.disk.get_disk_size(self.TEMPLATE_PATH
+ ).AndReturn(self.SIZE)
+ os.path.exists(self.PATH).AndReturn(True)
+ self.mox.ReplayAll()
+
+ image = self.image_class(self.INSTANCE, self.NAME)
+ image.create_image(fn, self.TEMPLATE_PATH, self.SIZE)
+
+ self.mox.VerifyAll()
+
class LvmTestCase(_ImageTestCase, test.TestCase):
VG = 'FakeVG'