diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-09-05 06:02:06 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-09-05 06:02:06 +0000 |
| commit | 84c62b35ff349ff0301eed36f765031d400e6c24 (patch) | |
| tree | a9352394feab525ec37dcf26010355e24ae22cc1 /nova/tests | |
| parent | 9bb97b04b1b3034b32bcf3bcfc5f190408db5579 (diff) | |
| parent | a692e7750f9aa6394c1ab9df5e22ecb908e7eb29 (diff) | |
Merge "Allow hard reboot of a soft rebooting instance"
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/compute/test_compute.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index e48efdaa1..e96f525c9 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -3078,6 +3078,42 @@ class ComputeAPITestCase(BaseTestCase): db.instance_destroy(self.context, inst_ref['uuid']) + def test_hard_reboot_of_soft_rebooting_instance(self): + """Ensure instance can be hard rebooted while soft rebooting""" + instance = jsonutils.to_primitive(self._create_fake_instance()) + self.compute.run_instance(self.context, instance=instance) + + inst_ref = db.instance_get_by_uuid(self.context, instance['uuid']) + + db.instance_update(self.context, instance['uuid'], + {"task_state": task_states.REBOOTING}) + + reboot_type = "HARD" + self.compute_api.reboot(self.context, inst_ref, reboot_type) + + inst_ref = db.instance_get_by_uuid(self.context, inst_ref['uuid']) + self.assertEqual(inst_ref['task_state'], task_states.REBOOTING_HARD) + + db.instance_destroy(self.context, inst_ref['uuid']) + + def test_soft_reboot_of_rebooting_instance(self): + """Ensure instance can't be soft rebooted while rebooting""" + instance = jsonutils.to_primitive(self._create_fake_instance()) + self.compute.run_instance(self.context, instance=instance) + + inst_ref = db.instance_get_by_uuid(self.context, instance['uuid']) + + db.instance_update(self.context, instance['uuid'], + {"task_state": task_states.REBOOTING}) + + inst_ref = db.instance_get_by_uuid(self.context, inst_ref['uuid']) + reboot_type = "SOFT" + self.assertRaises(exception.InstanceInvalidState, + self.compute_api.reboot, + self.context, + inst_ref, + reboot_type) + def test_hostname_create(self): """Ensure instance hostname is set during creation.""" inst_type = instance_types.get_instance_type_by_name('m1.tiny') |
