diff options
| author | Jenkins <jenkins@review.openstack.org> | 2011-10-14 19:04:13 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2011-10-14 19:04:13 +0000 |
| commit | c9d2aa8a72c16bfdf76e9a8622143ef7cf500cca (patch) | |
| tree | 900b256935b084f8c94fcc3852d9c270f148fb98 /nova/tests | |
| parent | 80105fbc530b7fc842f1fa8f8318128cf067fb77 (diff) | |
| parent | e50e9b44ab2b8b1184f93d24734af4b5862777bf (diff) | |
Merge "Adds the ability to automatically issue a hard reboot to instances that have been stuck in a 'rebooting' state for longer than a specified window."
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/test_db_api.py | 24 | ||||
| -rw-r--r-- | nova/tests/test_virt_drivers.py | 4 |
2 files changed, 28 insertions, 0 deletions
diff --git a/nova/tests/test_db_api.py b/nova/tests/test_db_api.py index 81194e3f9..6f6269e52 100644 --- a/nova/tests/test_db_api.py +++ b/nova/tests/test_db_api.py @@ -123,3 +123,27 @@ class DbApiTestCase(test.TestCase): results = db.migration_get_all_unconfirmed(ctxt, 10) self.assertEqual(0, len(results)) db.migration_update(ctxt, migration.id, {"status": "CONFIRMED"}) + + def test_instance_get_all_hung_in_rebooting(self): + ctxt = context.get_admin_context() + + # Ensure no instances are returned. + results = db.instance_get_all_hung_in_rebooting(ctxt, 10) + self.assertEqual(0, len(results)) + + # Ensure one rebooting instance with updated_at older than 10 seconds + # is returned. + updated_at = datetime.datetime(2000, 01, 01, 12, 00, 00) + values = {"task_state": "rebooting", "updated_at": updated_at} + instance = db.instance_create(ctxt, values) + results = db.instance_get_all_hung_in_rebooting(ctxt, 10) + self.assertEqual(1, len(results)) + db.instance_update(ctxt, instance.id, {"task_state": None}) + + # Ensure the newly rebooted instance is not returned. + updated_at = datetime.datetime.utcnow() + values = {"task_state": "rebooting", "updated_at": updated_at} + instance = db.instance_create(ctxt, values) + results = db.instance_get_all_hung_in_rebooting(ctxt, 10) + self.assertEqual(0, len(results)) + db.instance_update(ctxt, instance.id, {"task_state": None}) diff --git a/nova/tests/test_virt_drivers.py b/nova/tests/test_virt_drivers.py index fed89a2ec..be77dab2f 100644 --- a/nova/tests/test_virt_drivers.py +++ b/nova/tests/test_virt_drivers.py @@ -173,6 +173,10 @@ class _VirtDriverTestCase(test.TestCase): self.connection.unrescue(instance_ref, lambda x: None, network_info) @catch_notimplementederror + def test_poll_rebooting_instances(self): + self.connection.poll_rebooting_instances(10) + + @catch_notimplementederror def test_poll_rescued_instances(self): self.connection.poll_rescued_instances(10) |
