summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorAlex Meade <alex.meade@rackspace.com>2011-11-10 14:21:57 -0500
committerAlex Meade <alex.meade@rackspace.com>2011-11-10 14:21:57 -0500
commitf2b9f3fa6c8e8e50b23919bad079c86b14b08dee (patch)
tree80fbb096c1d7ca6b36a8f4da500ee931a896845f /nova/tests
parent1a5418b7cbc6f19000ee2847067c681685dd416e (diff)
Converting start and stop to use instance objects
Related to blueprint internal-uuids Change-Id: Ie94bef94e50620419a306eeedcdca756f83f1af6
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/api/ec2/test_cloud.py29
-rw-r--r--nova/tests/test_compute.py30
2 files changed, 59 insertions, 0 deletions
diff --git a/nova/tests/api/ec2/test_cloud.py b/nova/tests/api/ec2/test_cloud.py
index 57c74ed14..e70f7b832 100644
--- a/nova/tests/api/ec2/test_cloud.py
+++ b/nova/tests/api/ec2/test_cloud.py
@@ -1369,6 +1369,35 @@ class CloudTestCase(test.TestCase):
result = self.cloud.terminate_instances(self.context, [instance_id])
self.assertTrue(result)
+ def test_start_instances(self):
+ kwargs = {'image_id': 'ami-1',
+ 'instance_type': FLAGS.default_instance_type,
+ 'max_count': 1, }
+ instance_id = self._run_instance(**kwargs)
+
+ result = self.cloud.stop_instances(self.context, [instance_id])
+ self.assertTrue(result)
+
+ result = self.cloud.start_instances(self.context, [instance_id])
+ self.assertTrue(result)
+
+ result = self.cloud.terminate_instances(self.context, [instance_id])
+ self.assertTrue(result)
+ self._restart_compute_service()
+
+ def test_stop_instances(self):
+ kwargs = {'image_id': 'ami-1',
+ 'instance_type': FLAGS.default_instance_type,
+ 'max_count': 1, }
+ instance_id = self._run_instance(**kwargs)
+
+ result = self.cloud.stop_instances(self.context, [instance_id])
+ self.assertTrue(result)
+
+ result = self.cloud.terminate_instances(self.context, [instance_id])
+ self.assertTrue(result)
+ self._restart_compute_service()
+
def test_terminate_instances(self):
kwargs = {'image_id': 'ami-1',
'instance_type': FLAGS.default_instance_type,
diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py
index 2b124b6fc..0e8d53751 100644
--- a/nova/tests/test_compute.py
+++ b/nova/tests/test_compute.py
@@ -1047,6 +1047,36 @@ class ComputeAPITestCase(BaseTestCase):
finally:
db.instance_destroy(self.context, ref[0]['id'])
+ def test_start(self):
+ instance_id = self._create_instance()
+ self.compute.run_instance(self.context, instance_id)
+
+ self.compute.stop_instance(self.context, instance_id)
+
+ instance = db.instance_get(self.context, instance_id)
+ self.assertEqual(instance['task_state'], None)
+
+ self.compute_api.start(self.context, instance)
+
+ instance = db.instance_get(self.context, instance_id)
+ self.assertEqual(instance['task_state'], task_states.STARTING)
+
+ db.instance_destroy(self.context, instance_id)
+
+ def test_stop(self):
+ instance_id = self._create_instance()
+ self.compute.run_instance(self.context, instance_id)
+
+ instance = db.instance_get(self.context, instance_id)
+ self.assertEqual(instance['task_state'], None)
+
+ self.compute_api.stop(self.context, instance)
+
+ instance = db.instance_get(self.context, instance_id)
+ self.assertEqual(instance['task_state'], task_states.STOPPING)
+
+ db.instance_destroy(self.context, instance_id)
+
def test_delete(self):
instance_id = self._create_instance()
self.compute.run_instance(self.context, instance_id)