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