diff options
| author | Jenkins <jenkins@review.openstack.org> | 2011-11-03 20:25:06 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2011-11-03 20:25:06 +0000 |
| commit | 03b366d434eb23f15391801099e7e307b17e979f (patch) | |
| tree | c73b32806f176d9b8fed3fdfca9bf33212769c9c /nova/tests | |
| parent | fec3c19c492ee16096fdcd369b0adee6ddf43fb8 (diff) | |
| parent | ca6295e5dd238a88b731c3bf3e337007d12b6c1c (diff) | |
Merge "Gracefully handle Xen resize failure"
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/test_compute.py | 24 | ||||
| -rw-r--r-- | nova/tests/test_xenapi.py | 13 |
2 files changed, 37 insertions, 0 deletions
diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index 7295c9f1f..b235bcade 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -746,6 +746,30 @@ class ComputeTestCase(test.TestCase): self.context, inst_ref['uuid'], 1) 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): context = self.context.elevated() instance_id = self._create_instance() diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index 08a7686b5..6587bedd1 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -791,6 +791,19 @@ class XenAPIMigrateInstance(test.TestCase): conn = xenapi_conn.get_connection(False) 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): instance = db.instance_create(self.context, self.instance_values) self.called = False |
