Merge "Gracefully handle Xen resize failure"
This commit is contained in:
@@ -746,6 +746,30 @@ class ComputeTestCase(test.TestCase):
|
|||||||
self.context, inst_ref['uuid'], 1)
|
self.context, inst_ref['uuid'], 1)
|
||||||
self.compute.terminate_instance(self.context, instance_id)
|
self.compute.terminate_instance(self.context, instance_id)
|
||||||
|
|
||||||
|
def test_resize_instance_handles_migration_error(self):
|
||||||
|
"""Ensure vm_state is ERROR when MigrationError occurs"""
|
||||||
|
def raise_migration_failure(*args):
|
||||||
|
raise exception.MigrationError(reason='test failure')
|
||||||
|
self.stubs.Set(self.compute.driver,
|
||||||
|
'migrate_disk_and_power_off',
|
||||||
|
raise_migration_failure)
|
||||||
|
|
||||||
|
instance_id = self._create_instance()
|
||||||
|
context = self.context.elevated()
|
||||||
|
inst_ref = db.instance_get(context, instance_id)
|
||||||
|
|
||||||
|
self.compute.run_instance(self.context, instance_id)
|
||||||
|
db.instance_update(self.context, inst_ref['uuid'], {'host': 'foo'})
|
||||||
|
self.compute.prep_resize(context, inst_ref['uuid'], 1)
|
||||||
|
migration_ref = db.migration_get_by_instance_and_status(context,
|
||||||
|
inst_ref['uuid'], 'pre-migrating')
|
||||||
|
self.compute.resize_instance(context,
|
||||||
|
inst_ref['uuid'],
|
||||||
|
migration_ref['id'])
|
||||||
|
inst_ref = db.instance_get(context, instance_id)
|
||||||
|
self.assertEqual(inst_ref['vm_state'], vm_states.ERROR)
|
||||||
|
self.compute.terminate_instance(context, instance_id)
|
||||||
|
|
||||||
def test_migrate(self):
|
def test_migrate(self):
|
||||||
context = self.context.elevated()
|
context = self.context.elevated()
|
||||||
instance_id = self._create_instance()
|
instance_id = self._create_instance()
|
||||||
|
|||||||
@@ -791,6 +791,19 @@ class XenAPIMigrateInstance(test.TestCase):
|
|||||||
conn = xenapi_conn.get_connection(False)
|
conn = xenapi_conn.get_connection(False)
|
||||||
conn.migrate_disk_and_power_off(self.context, instance, '127.0.0.1')
|
conn.migrate_disk_and_power_off(self.context, instance, '127.0.0.1')
|
||||||
|
|
||||||
|
def test_migrate_disk_and_power_off_passes_exceptions(self):
|
||||||
|
instance = db.instance_create(self.context, self.instance_values)
|
||||||
|
stubs.stubout_session(self.stubs, stubs.FakeSessionForMigrationTests)
|
||||||
|
|
||||||
|
def fake_raise(*args, **kwargs):
|
||||||
|
raise exception.MigrationError(reason='test failure')
|
||||||
|
self.stubs.Set(vmops.VMOps, "_migrate_vhd", fake_raise)
|
||||||
|
|
||||||
|
conn = xenapi_conn.get_connection(False)
|
||||||
|
self.assertRaises(exception.MigrationError,
|
||||||
|
conn.migrate_disk_and_power_off,
|
||||||
|
self.context, instance, '127.0.0.1')
|
||||||
|
|
||||||
def test_revert_migrate(self):
|
def test_revert_migrate(self):
|
||||||
instance = db.instance_create(self.context, self.instance_values)
|
instance = db.instance_create(self.context, self.instance_values)
|
||||||
self.called = False
|
self.called = False
|
||||||
|
|||||||
Reference in New Issue
Block a user