summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2011-11-08 15:30:25 +0000
committerGerrit Code Review <review@openstack.org>2011-11-08 15:30:25 +0000
commitd6f9b26ca3ff01ecef45e61e8fd473106dec3d86 (patch)
tree71c732436120a36f80a3dd6176cc7ebc4f882d84 /nova/tests
parentd8165400ac5ccb61142c12af1346cf41edc31cc4 (diff)
parentd5d2df5718fae936d8c3f852be2fdc81b7789870 (diff)
Merge "Adding task_states.REBOOTING_HARD"
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/api/openstack/test_servers.py5
-rw-r--r--nova/tests/test_compute.py52
2 files changed, 55 insertions, 2 deletions
diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py
index 31c87e630..d7f44ddd1 100644
--- a/nova/tests/api/openstack/test_servers.py
+++ b/nova/tests/api/openstack/test_servers.py
@@ -1306,6 +1306,11 @@ class ServerStatusTest(test.TestCase):
task_states.REBOOTING)
self.assertEqual(response['server']['status'], 'REBOOT')
+ def test_reboot_hard(self):
+ response = self._get_with_state(vm_states.ACTIVE,
+ task_states.REBOOTING_HARD)
+ self.assertEqual(response['server']['status'], 'HARD_REBOOT')
+
def test_rebuild(self):
response = self._get_with_state(vm_states.REBUILDING)
self.assertEqual(response['server']['status'], 'REBUILD')
diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py
index b235bcade..479fd4647 100644
--- a/nova/tests/test_compute.py
+++ b/nova/tests/test_compute.py
@@ -342,20 +342,68 @@ class ComputeTestCase(test.TestCase):
self.compute.resume_instance(self.context, instance_id)
self.compute.terminate_instance(self.context, instance_id)
- def test_soft_reboot(self):
+ def test_soft_reboot_api(self):
"""Ensure instance can be soft rebooted"""
instance_id = self._create_instance()
+ self.compute.run_instance(self.context, instance_id)
+
+ inst_ref = db.instance_get(self.context, instance_id)
+ self.assertEqual(inst_ref['task_state'], None)
+
reboot_type = "SOFT"
+ self.compute_api.reboot(self.context, instance_id, reboot_type)
+
+ inst_ref = db.instance_get(self.context, instance_id)
+ self.assertEqual(inst_ref['task_state'], task_states.REBOOTING)
+
+ db.instance_destroy(self.context, instance_id)
+
+ def test_soft_reboot(self):
+ """Ensure instance can be soft rebooted"""
+ instance_id = self._create_instance()
self.compute.run_instance(self.context, instance_id)
+ db.instance_update(self.context, instance_id,
+ {'task_state': task_states.REBOOTING})
+
+ reboot_type = "SOFT"
self.compute.reboot_instance(self.context, instance_id, reboot_type)
+
+ inst_ref = db.instance_get(self.context, instance_id)
+ self.assertEqual(inst_ref['power_state'], power_state.RUNNING)
+ self.assertEqual(inst_ref['task_state'], None)
+
self.compute.terminate_instance(self.context, instance_id)
- def test_hard_reboot(self):
+ def test_hard_reboot_api(self):
"""Ensure instance can be hard rebooted"""
instance_id = self._create_instance()
+ self.compute.run_instance(self.context, instance_id)
+
+ inst_ref = db.instance_get(self.context, instance_id)
+ self.assertEqual(inst_ref['task_state'], None)
+
reboot_type = "HARD"
+ self.compute_api.reboot(self.context, instance_id, reboot_type)
+
+ inst_ref = db.instance_get(self.context, instance_id)
+ self.assertEqual(inst_ref['task_state'], task_states.REBOOTING_HARD)
+
+ db.instance_destroy(self.context, instance_id)
+
+ def test_hard_reboot(self):
+ """Ensure instance can be hard rebooted"""
+ instance_id = self._create_instance()
self.compute.run_instance(self.context, instance_id)
+ db.instance_update(self.context, instance_id,
+ {'task_state': task_states.REBOOTING_HARD})
+
+ reboot_type = "HARD"
self.compute.reboot_instance(self.context, instance_id, reboot_type)
+
+ inst_ref = db.instance_get(self.context, instance_id)
+ self.assertEqual(inst_ref['power_state'], power_state.RUNNING)
+ self.assertEqual(inst_ref['task_state'], None)
+
self.compute.terminate_instance(self.context, instance_id)
def test_set_admin_password(self):