From b668949cf39d1a1a4f00d92a21662201f5cd7423 Mon Sep 17 00:00:00 2001 From: TerryHowe Date: Sat, 16 May 2015 08:01:43 -0600 Subject: [PATCH] Update orchestration functional tests Update the orchestration functional tests to use the setup and teardown. The test cleans up after itself now, but it doesn't wait for the deleted stack to complete which would be a good feature, but we don't have a wait method that waits for something to be gone. Change-Id: Id8b06e08fb22e4af3b90c4b8ab6400378565d804 --- .../functional/orchestration/v1/test_stack.py | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/openstack/tests/functional/orchestration/v1/test_stack.py b/openstack/tests/functional/orchestration/v1/test_stack.py index d8c836f4..374914b6 100644 --- a/openstack/tests/functional/orchestration/v1/test_stack.py +++ b/openstack/tests/functional/orchestration/v1/test_stack.py @@ -10,21 +10,39 @@ # License for the specific language governing permissions and limitations # under the License. +from openstack.orchestration.v1 import stack from openstack.tests.functional import base class TestStack(base.BaseFunctionalTest): - def test_create_stack(self): - stack = self.conn.orchestration.create_stack( - name='test_stack', - parameters={'key_name': 'heat_key', - 'image_id': 'fedora-20.x86_64'}, - template_url='http://git.openstack.org/cgit/openstack/' + - 'heat-templates/plain/hot/F20/WordPress_Native.yaml' + NAME = 'test_stack' + ID = None + + @classmethod + def setUpClass(cls): + super(TestStack, cls).setUpClass() + if cls.conn.compute.find_keypair(cls.NAME) is None: + cls.conn.compute.create_keypair(name=cls.NAME) + template_url = ('http://git.openstack.org/cgit/openstack/' + + 'heat-templates/plain/hot/F20/WordPress_Native.yaml') + sot = cls.conn.orchestration.create_stack( + name=cls.NAME, + parameters={'key_name': cls.NAME, 'image_id': 'fedora-20.x86_64'}, + template_url=template_url, ) + assert isinstance(sot, stack.Stack) + cls.assertIs(True, (sot.id is not None)) + cls.ID = sot.id + cls.assertIs(cls.NAME, sot.name) + cls.conn.orchestration.wait_for_stack(sot) - self.conn.orchestration.wait_for_stack(stack) + @classmethod + def tearDownClass(cls): + super(TestStack, cls).tearDownClass() + cls.conn.orchestration.delete_stack(cls.ID) + cls.conn.compute.delete_keypair(cls.NAME) - self.assertIsNotNone(stack.id) - self.assertEqual('test_stack', stack.name) + def test_list(self): + names = [o.name for o in self.conn.orchestration.list_stacks()] + self.assertIn(self.NAME, names)