From a7e379b40773bae03b435b1119b2563a86a6c6df Mon Sep 17 00:00:00 2001 From: Brian Lamar Date: Thu, 10 May 2012 16:54:12 -0400 Subject: [PATCH] More accurate rescue mode testing for XenAPI Update test_rescue to make sure the swap partition wasn't rescued. Since this test fails with the current code, I also updated the code so the test passed. Fixes bug 997835 Change-Id: I9f09b3bbbee0ddfcbfdb243a7dff0b9bae99925d --- nova/tests/test_xenapi.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index 7e926571..3056661b 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -713,13 +713,26 @@ class XenAPIVMTestCase(test.TestCase): def test_rescue(self): instance = self._create_instance() session = xenapi_conn.XenAPISession('test_url', 'root', 'test_pass') - vm = vm_utils.VMHelper.lookup(session, instance.name) - vbd = xenapi_fake.create_vbd(vm, None) + vm_ref = vm_utils.VMHelper.lookup(session, instance.name) + + xenapi_fake.create_vbd(vm_ref, "swap", userdevice=1) + xenapi_fake.create_vbd(vm_ref, "rootfs", userdevice=0) + conn = xenapi_conn.get_connection(False) image_meta = {'id': glance_stubs.FakeGlance.IMAGE_VHD, 'disk_format': 'vhd'} conn.rescue(self.context, instance, [], image_meta) + vm = xenapi_fake.get_record('VM', vm_ref) + rescue_name = "%s-rescue" % vm["name_label"] + rescue_ref = vm_utils.VMHelper.lookup(session, rescue_name) + rescue_vm = xenapi_fake.get_record('VM', rescue_ref) + + vdi_uuids = [] + for vbd_uuid in rescue_vm["VBDs"]: + vdi_uuids.append(xenapi_fake.get_record('VBD', vbd_uuid)["VDI"]) + self.assertTrue("swap" not in vdi_uuids) + def test_unrescue(self): instance = self._create_instance() conn = xenapi_conn.get_connection(False)