From 7964c831a10f632cc86ce7992ea101ca9763028a Mon Sep 17 00:00:00 2001 From: Kei Masumoto Date: Wed, 28 Sep 2011 15:05:54 -0400 Subject: [PATCH] Fixed bug lp850602. Adding backing file copy operation on kvm block migration. Change-Id: I165b0f8778e712c8932260c0110e159b2e9a6cfb --- nova/tests/test_libvirt.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index aefe26cc..8b6f2080 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -629,9 +629,12 @@ class LibvirtConnTestCase(test.TestCase): fake_timer = FakeTime() + # _fake_network_info must be called before create_fake_libvirt_mock(), + # as _fake_network_info calls utils.import_class() and + # create_fake_libvirt_mock() mocks utils.import_class(). + network_info = _fake_network_info(self.stubs, 1) self.create_fake_libvirt_mock() instance_ref = db.instance_create(self.context, self.test_instance) - network_info = _fake_network_info(self.stubs, 1) # Start test self.mox.ReplayAll() @@ -684,10 +687,7 @@ class LibvirtConnTestCase(test.TestCase): return vdmock self.create_fake_libvirt_mock(lookupByName=fake_lookup) -# self.mox.StubOutWithMock(self.compute, "recover_live_migration") self.mox.StubOutWithMock(self.compute, "rollback_live_migration") -# self.compute.recover_live_migration(self.context, instance_ref, -# dest='dest') self.compute.rollback_live_migration(self.context, instance_ref, 'dest', False) @@ -722,7 +722,8 @@ class LibvirtConnTestCase(test.TestCase): # Test data instance_ref = db.instance_create(self.context, self.test_instance) - dummyjson = '[{"path": "%s/disk", "local_gb": "10G", "type": "raw"}]' + dummyjson = ('[{"path": "%s/disk", "local_gb": "10G",' + ' "type": "raw", "backing_file": ""}]') # Preparing mocks # qemu-img should be mockd since test environment might not have @@ -763,7 +764,10 @@ class LibvirtConnTestCase(test.TestCase): "") ret = ("image: /test/disk\nfile format: raw\n" - "virtual size: 20G (21474836480 bytes)\ndisk size: 3.1G\n") + "virtual size: 20G (21474836480 bytes)\ndisk size: 3.1G\n" + "disk size: 102M\n" + "cluster_size: 2097152\n" + "backing file: /test/dummy (actual path: /backing/file)\n") # Preparing mocks vdmock = self.mox.CreateMock(libvirt.virDomain) @@ -793,7 +797,9 @@ class LibvirtConnTestCase(test.TestCase): info[0]['path'] == '/test/disk' and info[1]['path'] == '/test/disk.local' and info[0]['local_gb'] == '10G' and - info[1]['local_gb'] == '20G') + info[1]['local_gb'] == '20G' and + info[0]['backing_file'] == "" and + info[1]['backing_file'] == "file") db.instance_destroy(self.context, instance_ref['id']) @@ -806,6 +812,10 @@ class LibvirtConnTestCase(test.TestCase): def fake_none(self, instance): return + # _fake_network_info must be called before create_fake_libvirt_mock(), + # as _fake_network_info calls utils.import_class() and + # create_fake_libvirt_mock() mocks utils.import_class(). + network_info = _fake_network_info(self.stubs, 1) self.create_fake_libvirt_mock() instance = db.instance_create(self.context, self.test_instance) @@ -815,8 +825,6 @@ class LibvirtConnTestCase(test.TestCase): conn.firewall_driver.setattr('setup_basic_filtering', fake_none) conn.firewall_driver.setattr('prepare_instance_filter', fake_none) - network_info = _fake_network_info(self.stubs, 1) - try: conn.spawn(self.context, instance, network_info) except Exception, e: