summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorJohannes Erdfelt <johannes.erdfelt@rackspace.com>2012-04-13 21:08:01 +0000
committerJohannes Erdfelt <johannes.erdfelt@rackspace.com>2012-04-13 21:28:36 +0000
commit8413e60b8e8d91ec2d1656bb3c16eafa3ee832b5 (patch)
tree444a476d31e9c9a297a8223c9e4b4898174a5292 /nova/tests
parent042a4d0d96b33ab2c86ef4e5e46560fef16d011f (diff)
Test unrescue works as well
The only unrescue test that happens right now is that it fails if not already in rescue. This test fills out to test unrescue works as intended. Also, remove unnecessary stub from rescue test. Change-Id: I4451afe5a7d2ada8dfaefad804345b66ac895094
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/test_xenapi.py18
-rw-r--r--nova/tests/xenapi/stubs.py10
2 files changed, 13 insertions, 15 deletions
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py
index da8091233..9921c621a 100644
--- a/nova/tests/test_xenapi.py
+++ b/nova/tests/test_xenapi.py
@@ -703,17 +703,22 @@ class XenAPIVMTestCase(test.TestCase):
session = xenapi_conn.XenAPISession('test_url', 'root', 'test_pass')
vm = vm_utils.VMHelper.lookup(session, instance.name)
vbd = xenapi_fake.create_vbd(vm, None)
-
- def fake_spawn(self, context, inst, network_info, image_meta):
- inst._rescue = False
- self.stubs.Set(vmops.VMOps, 'spawn', fake_spawn)
-
conn = xenapi_conn.get_connection(False)
- conn.rescue(self.context, instance, [], None)
+ image_meta = {'id': glance_stubs.FakeGlance.IMAGE_VHD,
+ 'disk_format': 'vhd'}
+ conn.rescue(self.context, instance, [], image_meta)
def test_unrescue(self):
instance = self._create_instance()
conn = xenapi_conn.get_connection(False)
+ # Unrescue expects the original instance to be powered off
+ conn.power_off(instance)
+ rescue_vm = xenapi_fake.create_vm(instance.name + '-rescue', 'Running')
+ conn.unrescue(instance, None)
+
+ def test_unrescue_not_in_rescue(self):
+ instance = self._create_instance()
+ conn = xenapi_conn.get_connection(False)
# Ensure that it will not unrescue a non-rescued instance.
self.assertRaises(exception.InstanceNotInRescueMode, conn.unrescue,
instance, None)
@@ -974,6 +979,7 @@ class XenAPIMigrateInstance(test.TestCase):
def test_migrate_disk_and_power_off(self):
instance = db.instance_create(self.context, self.instance_values)
+ xenapi_fake.create_vm(instance.name, 'Running')
instance_type = db.instance_type_get_by_name(self.context, 'm1.large')
stubs.stubout_session(self.stubs, stubs.FakeSessionForMigrationTests)
conn = xenapi_conn.get_connection(False)
diff --git a/nova/tests/xenapi/stubs.py b/nova/tests/xenapi/stubs.py
index e97568f03..533c12896 100644
--- a/nova/tests/xenapi/stubs.py
+++ b/nova/tests/xenapi/stubs.py
@@ -215,7 +215,7 @@ class FakeSessionForVMTests(fake.SessionBase):
vm = fake.get_record('VM', ref)
if vm['power_state'] != 'Halted':
raise fake.Failure(['VM_BAD_POWER_STATE', ref, 'Halted',
- vm['power_state']])
+ vm['power_state']])
vm['power_state'] = 'Running'
vm['is_a_template'] = False
vm['is_control_domain'] = False
@@ -302,9 +302,6 @@ class FakeSessionForFirewallTests(FakeSessionForVMTests):
def stub_out_vm_methods(stubs):
- def fake_shutdown(self, inst, vm, method="clean"):
- pass
-
def fake_acquire_bootlock(self, vm):
pass
@@ -315,7 +312,6 @@ def stub_out_vm_methods(stubs):
def fake_generate_ephemeral(cls, *args):
pass
- stubs.Set(vmops.VMOps, "_shutdown", fake_shutdown)
stubs.Set(vmops.VMOps, "_acquire_bootlock", fake_acquire_bootlock)
stubs.Set(vmops.VMOps, "_release_bootlock", fake_release_bootlock)
stubs.Set(vm_utils.VMHelper, 'generate_ephemeral', fake_generate_ephemeral)
@@ -382,9 +378,6 @@ def stub_out_migration_methods(stubs):
vdi_rec = session.call_xenapi("VDI.get_record", vdi_ref)
return vdi_ref, {'uuid': vdi_rec['uuid'], }
- def fake_shutdown(self, inst, vm, hard=True):
- pass
-
@classmethod
def fake_sr(cls, session, *args):
pass
@@ -410,5 +403,4 @@ def stub_out_migration_methods(stubs):
stubs.Set(vm_utils.VMHelper, 'get_vdi_for_vm_safely', fake_get_vdi)
stubs.Set(vm_utils.VMHelper, 'get_sr_path', fake_get_sr_path)
stubs.Set(vmops.VMOps, 'reset_network', fake_reset_network)
- stubs.Set(vmops.VMOps, '_shutdown', fake_shutdown)
stubs.Set(vm_utils.VMHelper, 'generate_ephemeral', fake_generate_ephemeral)