diff options
| author | Jenkins <jenkins@review.openstack.org> | 2011-11-21 21:38:05 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2011-11-21 21:38:05 +0000 |
| commit | d0152210600e00a3ff87b83c1af666a2fb7a2abf (patch) | |
| tree | 7955860662cfd906475c6c94a6d37b2d59343efc /nova/tests | |
| parent | 9b4d3a2aac177ba47f3b0f0323b7b05ff5601d59 (diff) | |
| parent | 21e08712d9ac5577c27e7ea4c9271372bc0bd3ed (diff) | |
Merge "Put instances in ERROR state when scheduler fails."
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/scheduler/test_scheduler.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/nova/tests/scheduler/test_scheduler.py b/nova/tests/scheduler/test_scheduler.py index 2c32bbd94..05f954b73 100644 --- a/nova/tests/scheduler/test_scheduler.py +++ b/nova/tests/scheduler/test_scheduler.py @@ -132,6 +132,9 @@ class TestDriver(driver.Scheduler): method = 'named_method' driver.cast_to_host(context, topic, host, method, num=num) + def schedule_failing_method(self, context, instance_id): + raise exception.NoValidHost(reason="") + class SchedulerTestCase(test.TestCase): """Test case for scheduler""" @@ -244,6 +247,21 @@ class SchedulerTestCase(test.TestCase): db.instance_destroy(ctxt, i_ref1['id']) db.instance_destroy(ctxt, i_ref2['id']) + def test_exception_puts_instance_in_error_state(self): + """Test that an exception from the scheduler puts an instance + in the ERROR state.""" + + scheduler = manager.SchedulerManager() + ctxt = context.get_admin_context() + inst = _create_instance() + self.assertRaises(Exception, scheduler._schedule, + 'failing_method', ctxt, 'scheduler', + instance_id=inst['uuid']) + + # Refresh the instance + inst = db.instance_get(ctxt, inst['id']) + self.assertEqual(inst['vm_state'], vm_states.ERROR) + class SimpleDriverTestCase(test.TestCase): """Test case for simple driver""" |
