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 |
| 26 | def setUpClass(cls): |
| 27 | super(StacksTestJSON, cls).setUpClass() |
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): |
Bartosz Górski | ab33b7e | 2013-06-27 00:39:47 -0700 | [diff] [blame] | 31 | resp, stacks = self.client.list_stacks() |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 32 | self.assertEqual('200', resp['status']) |
| 33 | self.assertIsInstance(stacks, list) |
| 34 | |
Matthew Treinish | 5c660ab | 2014-05-18 21:14:36 -0400 | [diff] [blame] | 35 | @test.attr(type='smoke') |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 36 | def test_stack_crud_no_resources(self): |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 37 | stack_name = data_utils.rand_name('heat') |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 38 | |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 39 | # create the stack |
| 40 | stack_identifier = self.create_stack( |
| 41 | stack_name, self.empty_template) |
Steve Baker | 6c2e0bf | 2013-06-21 11:23:20 +1200 | [diff] [blame] | 42 | stack_id = stack_identifier.split('/')[1] |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 43 | |
| 44 | # wait for create complete (with no resources it should be instant) |
| 45 | self.client.wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE') |
| 46 | |
Steve Baker | 6c2e0bf | 2013-06-21 11:23:20 +1200 | [diff] [blame] | 47 | # check for stack in list |
Bartosz Górski | ab33b7e | 2013-06-27 00:39:47 -0700 | [diff] [blame] | 48 | resp, stacks = self.client.list_stacks() |
| 49 | list_ids = list([stack['id'] for stack in stacks]) |
Steve Baker | 6c2e0bf | 2013-06-21 11:23:20 +1200 | [diff] [blame] | 50 | self.assertIn(stack_id, list_ids) |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 51 | |
| 52 | # fetch the stack |
Bartosz Górski | ab33b7e | 2013-06-27 00:39:47 -0700 | [diff] [blame] | 53 | resp, stack = self.client.get_stack(stack_identifier) |
| 54 | self.assertEqual('CREATE_COMPLETE', stack['stack_status']) |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 55 | |
| 56 | # fetch the stack by name |
Bartosz Górski | ab33b7e | 2013-06-27 00:39:47 -0700 | [diff] [blame] | 57 | resp, stack = self.client.get_stack(stack_name) |
| 58 | self.assertEqual('CREATE_COMPLETE', stack['stack_status']) |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 59 | |
| 60 | # fetch the stack by id |
Bartosz Górski | ab33b7e | 2013-06-27 00:39:47 -0700 | [diff] [blame] | 61 | resp, stack = self.client.get_stack(stack_id) |
| 62 | self.assertEqual('CREATE_COMPLETE', stack['stack_status']) |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 63 | |
| 64 | # delete the stack |
| 65 | resp = self.client.delete_stack(stack_identifier) |
| 66 | self.assertEqual('204', resp[0]['status']) |
Steven Hardy | 93eddcc | 2014-07-24 15:03:33 +0100 | [diff] [blame] | 67 | self.client.wait_for_stack_status(stack_identifier, 'DELETE_COMPLETE') |