summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThuleau Édouard <thuleau@gmail.com>2011-09-02 17:49:45 +0200
committerThuleau Édouard <thuleau@gmail.com>2011-09-02 17:49:45 +0200
commitccb5334c600de07f1c9aa2657dd29134fda29bc4 (patch)
tree3bffb662aa6a5e0c9d0ede64e2108c28eb0e475e
parentcae343eecdeba6b3f18dbdc330206edabd9ed287 (diff)
downloadnova-ccb5334c600de07f1c9aa2657dd29134fda29bc4.tar.gz
nova-ccb5334c600de07f1c9aa2657dd29134fda29bc4.tar.xz
nova-ccb5334c600de07f1c9aa2657dd29134fda29bc4.zip
Add tests for flags 'snapshot_image_format'.
-rw-r--r--nova/tests/test_libvirt.py41
1 files changed, 40 insertions, 1 deletions
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py
index 8c6775b29..a7b24c1b8 100644
--- a/nova/tests/test_libvirt.py
+++ b/nova/tests/test_libvirt.py
@@ -321,7 +321,7 @@ class LibvirtConnTestCase(test.TestCase):
instance_data = dict(self.test_instance)
self._check_xml_and_container(instance_data)
- def test_snapshot(self):
+ def test_snapshot_in_raw_format(self):
if not self.lazy_load_library_exists():
return
@@ -354,8 +354,47 @@ class LibvirtConnTestCase(test.TestCase):
snapshot = image_service.show(context, recv_meta['id'])
self.assertEquals(snapshot['properties']['image_state'], 'available')
self.assertEquals(snapshot['status'], 'active')
+ self.assertEquals(snapshot['disk_format'], FLAGS.snapshot_image_format)
self.assertEquals(snapshot['name'], snapshot_name)
+ def test_snapshot_in_qcow2_format(self):
+ if not self.lazy_load_library_exists():
+ return
+
+ self.flags(image_service='nova.image.fake.FakeImageService')
+ self.flags(snapshot_image_format='qcow2')
+
+ # Start test
+ image_service = utils.import_object(FLAGS.image_service)
+
+ # Assuming that base image already exists in image_service
+ instance_ref = db.instance_create(self.context, self.test_instance)
+ properties = {'instance_id': instance_ref['id'],
+ 'user_id': str(self.context.user_id)}
+ snapshot_name = 'test-snap'
+ sent_meta = {'name': snapshot_name, 'is_public': False,
+ 'status': 'creating', 'properties': properties}
+ # Create new image. It will be updated in snapshot method
+ # To work with it from snapshot, the single image_service is needed
+ recv_meta = image_service.create(context, sent_meta)
+
+ self.mox.StubOutWithMock(connection.LibvirtConnection, '_conn')
+ connection.LibvirtConnection._conn.lookupByName = self.fake_lookup
+ self.mox.StubOutWithMock(connection.utils, 'execute')
+ connection.utils.execute = self.fake_execute
+
+ self.mox.ReplayAll()
+
+ conn = connection.LibvirtConnection(False)
+ conn.snapshot(self.context, instance_ref, recv_meta['id'])
+
+ snapshot = image_service.show(context, recv_meta['id'])
+ self.assertEquals(snapshot['properties']['image_state'], 'available')
+ self.assertEquals(snapshot['status'], 'active')
+ self.assertEquals(snapshot['disk_format'], FLAGS.snapshot_image_format)
+ self.assertEquals(snapshot['name'], snapshot_name)
+
+
def test_snapshot_no_image_architecture(self):
if not self.lazy_load_library_exists():
return