Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 1 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 2 | # not use this file except in compliance with the License. You may obtain |
| 3 | # a copy of the License at |
| 4 | # |
| 5 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | # |
| 7 | # Unless required by applicable law or agreed to in writing, software |
| 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 10 | # License for the specific language governing permissions and limitations |
| 11 | # under the License. |
| 12 | |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 13 | from tempest.api.orchestration import base |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 14 | from tempest.common.utils import data_utils |
Matthew Treinish | f4a9b0f | 2013-07-26 16:58:26 -0400 | [diff] [blame] | 15 | from tempest.openstack.common import log as logging |
Matthew Treinish | 5c660ab | 2014-05-18 21:14:36 -0400 | [diff] [blame] | 16 | from tempest import test |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 17 | |
| 18 | |
| 19 | LOG = logging.getLogger(__name__) |
| 20 | |
| 21 | |
| 22 | class StacksTestJSON(base.BaseOrchestrationTest): |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 23 | empty_template = "HeatTemplateFormatVersion: '2012-12-12'\n" |
| 24 | |
| 25 | @classmethod |
Andrea Frittoli | 556f796 | 2014-09-15 13:14:54 +0100 | [diff] [blame] | 26 | def resource_setup(cls): |
| 27 | super(StacksTestJSON, cls).resource_setup() |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 28 | |
Matthew Treinish | 5c660ab | 2014-05-18 21:14:36 -0400 | [diff] [blame] | 29 | @test.attr(type='smoke') |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 30 | def test_stack_list_responds(self): |
David Kranz | 8ad924b | 2015-01-16 16:50:18 -0500 | [diff] [blame] | 31 | stacks = self.client.list_stacks() |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 32 | self.assertIsInstance(stacks, list) |
| 33 | |
Matthew Treinish | 5c660ab | 2014-05-18 21:14:36 -0400 | [diff] [blame] | 34 | @test.attr(type='smoke') |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 35 | def test_stack_crud_no_resources(self): |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 36 | stack_name = data_utils.rand_name('heat') |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 37 | |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 38 | # create the stack |
| 39 | stack_identifier = self.create_stack( |
| 40 | stack_name, self.empty_template) |
Steve Baker | 6c2e0bf | 2013-06-21 11:23:20 +1200 | [diff] [blame] | 41 | stack_id = stack_identifier.split('/')[1] |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 42 | |
| 43 | # wait for create complete (with no resources it should be instant) |
| 44 | self.client.wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE') |
| 45 | |
Steve Baker | 6c2e0bf | 2013-06-21 11:23:20 +1200 | [diff] [blame] | 46 | # check for stack in list |
David Kranz | 8ad924b | 2015-01-16 16:50:18 -0500 | [diff] [blame] | 47 | stacks = self.client.list_stacks() |
Bartosz Górski | ab33b7e | 2013-06-27 00:39:47 -0700 | [diff] [blame] | 48 | list_ids = list([stack['id'] for stack in stacks]) |
Steve Baker | 6c2e0bf | 2013-06-21 11:23:20 +1200 | [diff] [blame] | 49 | self.assertIn(stack_id, list_ids) |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 50 | |
| 51 | # fetch the stack |
David Kranz | 8ad924b | 2015-01-16 16:50:18 -0500 | [diff] [blame] | 52 | stack = self.client.get_stack(stack_identifier) |
Bartosz Górski | ab33b7e | 2013-06-27 00:39:47 -0700 | [diff] [blame] | 53 | self.assertEqual('CREATE_COMPLETE', stack['stack_status']) |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 54 | |
| 55 | # fetch the stack by name |
David Kranz | 8ad924b | 2015-01-16 16:50:18 -0500 | [diff] [blame] | 56 | stack = self.client.get_stack(stack_name) |
Bartosz Górski | ab33b7e | 2013-06-27 00:39:47 -0700 | [diff] [blame] | 57 | self.assertEqual('CREATE_COMPLETE', stack['stack_status']) |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 58 | |
| 59 | # fetch the stack by id |
David Kranz | 8ad924b | 2015-01-16 16:50:18 -0500 | [diff] [blame] | 60 | stack = self.client.get_stack(stack_id) |
Bartosz Górski | ab33b7e | 2013-06-27 00:39:47 -0700 | [diff] [blame] | 61 | self.assertEqual('CREATE_COMPLETE', stack['stack_status']) |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 62 | |
| 63 | # delete the stack |
Joseph Lanoux | 2707a0f | 2014-08-22 11:05:21 +0000 | [diff] [blame] | 64 | self.client.delete_stack(stack_identifier) |
Steven Hardy | 93eddcc | 2014-07-24 15:03:33 +0100 | [diff] [blame] | 65 | self.client.wait_for_stack_status(stack_identifier, 'DELETE_COMPLETE') |