From d5d2df5718fae936d8c3f852be2fdc81b7789870 Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Mon, 7 Nov 2011 17:20:16 -0500 Subject: Adding task_states.REBOOTING_HARD Fixes bug 884906 Change-Id: I546d0ddd7afee7596a4c47053dae3cb3ba18fdb2 --- nova/tests/api/openstack/test_servers.py | 5 +++ nova/tests/test_compute.py | 52 ++++++++++++++++++++++++++++++-- 2 files changed, 55 insertions(+), 2 deletions(-) (limited to 'nova/tests') 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): -- cgit