summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorAlex Meade <alex.meade@rackspace.com>2011-11-23 11:43:30 -0500
committerAlex Meade <alex.meade@rackspace.com>2011-11-29 10:47:38 -0500
commitda003c175a8211d6070fa9b171e67c4cf012e9cc (patch)
treecb371bb24e29a2eb9c5ee52935aae1ae640ded43 /nova/tests
parente2a5955e7e979ccd039fb77df8b6e7814cdc1aa1 (diff)
power_on/power_off in compute manager to use uuids
Related to blueprint internal-uuids. Changes power_on and power_off of instances to use uuids. Also, fixes a test for get_actions to be more accurate. Later a migration will need to be written for instance_get_actions to use uuids instead of ids. Change-Id: Id0896f4bf3f0c64a77ac9c421bad702073f2fc50
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/test_compute.py58
1 files changed, 55 insertions, 3 deletions
diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py
index f03665d57..47f2fb83d 100644
--- a/nova/tests/test_compute.py
+++ b/nova/tests/test_compute.py
@@ -277,6 +277,44 @@ class ComputeTestCase(BaseTestCase):
self.assertTrue(called['unrescued'])
self.compute.terminate_instance(self.context, instance_id)
+ def test_power_on(self):
+ """Ensure instance can be powered on"""
+
+ called = {'power_on': False}
+
+ def fake_driver_power_on(self, instance):
+ called['power_on'] = True
+
+ self.stubs.Set(nova.virt.driver.ComputeDriver, 'power_on',
+ fake_driver_power_on)
+
+ instance = self._create_fake_instance()
+ instance_id = instance['id']
+ instance_uuid = instance['uuid']
+ self.compute.run_instance(self.context, instance_id)
+ self.compute.power_on_instance(self.context, instance_uuid)
+ self.assertTrue(called['power_on'])
+ self.compute.terminate_instance(self.context, instance_id)
+
+ def test_power_off(self):
+ """Ensure instance can be powered off"""
+
+ called = {'power_off': False}
+
+ def fake_driver_power_off(self, instance):
+ called['power_off'] = True
+
+ self.stubs.Set(nova.virt.driver.ComputeDriver, 'power_off',
+ fake_driver_power_off)
+
+ instance = self._create_fake_instance()
+ instance_id = instance['id']
+ instance_uuid = instance['uuid']
+ self.compute.run_instance(self.context, instance_id)
+ self.compute.power_off_instance(self.context, instance_uuid)
+ self.assertTrue(called['power_off'])
+ self.compute.terminate_instance(self.context, instance_id)
+
def test_pause(self):
"""Ensure instance can be paused and unpaused"""
instance = self._create_fake_instance()
@@ -2266,10 +2304,24 @@ class ComputeAPITestCase(BaseTestCase):
self.compute_api.delete(self.context, instance)
def test_get_actions(self):
+
+ expected = [{'id': 1,
+ 'instance_id': 5,
+ 'action': 'rebuild',
+ 'error': '',
+ }]
+
+ def fake_get_actions(context, instance):
+ return expected
+
+ self.stubs.Set(nova.db, 'instance_get_actions',
+ fake_get_actions)
+
+ instance = self._create_fake_instance()
context = self.context.elevated()
- instance_id = self._create_instance()
- instance = self.compute_api.get(self.context, instance_id)
- self.compute_api.get_actions(context, instance)
+ actual = self.compute_api.get_actions(context, instance)
+ self.assertEqual(expected, actual)
+
self.compute_api.delete(self.context, instance)
def test_inject_file(self):