summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorBoris Filippov <bfilippov@griddynamics.com>2012-09-26 04:55:03 +0400
committerGerrit Code Review <review@openstack.org>2012-10-12 10:25:53 +0000
commit0df84e9bba8d5a77680cc65fd5488e9a5298f2cd (patch)
treec0383398ec144b6f78436594f1956b6c647e6587 /nova/tests
parent4f3930632ca0cde0afa233d7345f8ddb19c4c37c (diff)
Implement snapshots for raw backend
blueprint snapshots-for-everyone Use simple qemu-img convert for raw snapshots. Polymorphically select snapshot behavior for raw and qcow2. Allow images to be constructed from actual device/file path. Change-Id: I6a57e43c6775c144c41a53382dcc7504ce6d4c43
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/fake_imagebackend.py8
-rw-r--r--nova/tests/fake_libvirt_utils.py6
-rw-r--r--nova/tests/test_libvirt.py11
3 files changed, 23 insertions, 2 deletions
diff --git a/nova/tests/fake_imagebackend.py b/nova/tests/fake_imagebackend.py
index b6a052f2a..978c879fd 100644
--- a/nova/tests/fake_imagebackend.py
+++ b/nova/tests/fake_imagebackend.py
@@ -37,6 +37,9 @@ class Backend(object):
def cache(self, fetch_func, filename, size=None, *args, **kwargs):
pass
+ def snapshot(self, name):
+ pass
+
def libvirt_info(self, disk_bus, disk_dev, device_type,
cache_mode):
info = config.LibvirtConfigGuestDisk()
@@ -50,3 +53,8 @@ class Backend(object):
return info
return FakeImage(instance, name)
+
+ def snapshot(self, path, name, image_type=''):
+ #NOTE(bfilippov): this is done in favor for
+ # snapshot tests in test_libvirt.LibvirtConnTestCase
+ return imagebackend.Backend(True).snapshot(path, name, image_type)
diff --git a/nova/tests/fake_libvirt_utils.py b/nova/tests/fake_libvirt_utils.py
index 1862521c1..4f7c96d4f 100644
--- a/nova/tests/fake_libvirt_utils.py
+++ b/nova/tests/fake_libvirt_utils.py
@@ -104,7 +104,7 @@ def file_open(path, mode=None):
def find_disk(virt_dom):
- return "some/path"
+ return "filename"
def load_file(path):
@@ -115,6 +115,10 @@ def load_file(path):
return ''
+def logical_volume_info(path):
+ return {}
+
+
def file_delete(path):
return True
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py
index 7af877f22..7de72266b 100644
--- a/nova/tests/test_libvirt.py
+++ b/nova/tests/test_libvirt.py
@@ -53,6 +53,7 @@ from nova.virt.libvirt import config
from nova.virt.libvirt import driver as libvirt_driver
from nova.virt.libvirt import firewall
from nova.virt.libvirt import imagebackend
+from nova.virt.libvirt import snapshots
from nova.virt.libvirt import utils as libvirt_utils
from nova.virt.libvirt import volume
from nova.virt.libvirt import volume_nfs
@@ -484,6 +485,7 @@ class LibvirtConnTestCase(test.TestCase):
self.flags(libvirt_snapshots_directory='')
self.call_libvirt_dependant_setup = False
libvirt_driver.libvirt_utils = fake_libvirt_utils
+ snapshots.libvirt_utils = fake_libvirt_utils
def fake_extend(image, size):
pass
@@ -532,7 +534,7 @@ class LibvirtConnTestCase(test.TestCase):
def fake_lookup(self, instance_name):
return FakeVirtDomain()
- def fake_execute(self, *args):
+ def fake_execute(self, *args, **kwargs):
open(args[-1], "a").close()
def create_service(self, **kwargs):
@@ -1129,6 +1131,7 @@ class LibvirtConnTestCase(test.TestCase):
libvirt_driver.LibvirtDriver._conn.lookupByName = self.fake_lookup
self.mox.StubOutWithMock(libvirt_driver.utils, 'execute')
libvirt_driver.utils.execute = self.fake_execute
+ libvirt_driver.libvirt_utils.disk_type = "qcow2"
self.mox.ReplayAll()
@@ -1164,6 +1167,11 @@ class LibvirtConnTestCase(test.TestCase):
libvirt_driver.utils.execute = self.fake_execute
self.stubs.Set(libvirt_driver.libvirt_utils, 'disk_type', 'raw')
+ def convert_image(source, dest, out_format):
+ libvirt_driver.libvirt_utils.files[dest] = ''
+
+ images.convert_image = convert_image
+
self.mox.ReplayAll()
conn = libvirt_driver.LibvirtDriver(False)
@@ -1197,6 +1205,7 @@ class LibvirtConnTestCase(test.TestCase):
libvirt_driver.LibvirtDriver._conn.lookupByName = self.fake_lookup
self.mox.StubOutWithMock(libvirt_driver.utils, 'execute')
libvirt_driver.utils.execute = self.fake_execute
+ libvirt_driver.libvirt_utils.disk_type = "qcow2"
self.mox.ReplayAll()