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 |
Ken'ichi Ohmichi | 60680a8 | 2017-03-10 11:03:16 -0800 | [diff] [blame] | 14 | from tempest.lib.common.utils import data_utils |
Ken'ichi Ohmichi | 835a945 | 2017-01-27 18:17:07 -0800 | [diff] [blame] | 15 | from tempest.lib import decorators |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 16 | |
| 17 | |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 18 | class StacksTestJSON(base.BaseOrchestrationTest): |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 19 | empty_template = "HeatTemplateFormatVersion: '2012-12-12'\n" |
| 20 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 21 | @decorators.attr(type='smoke') |
Ken'ichi Ohmichi | 835a945 | 2017-01-27 18:17:07 -0800 | [diff] [blame] | 22 | @decorators.idempotent_id('d35d628c-07f6-4674-85a1-74db9919e986') |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 23 | def test_stack_list_responds(self): |
Anusha Ramineni | ab6c3a3 | 2015-08-18 08:33:09 +0530 | [diff] [blame] | 24 | stacks = self.client.list_stacks()['stacks'] |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 25 | self.assertIsInstance(stacks, list) |
| 26 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 27 | @decorators.attr(type='smoke') |
Ken'ichi Ohmichi | 835a945 | 2017-01-27 18:17:07 -0800 | [diff] [blame] | 28 | @decorators.idempotent_id('10498bd5-a83e-4b62-a817-ce24afe938fe') |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 29 | def test_stack_crud_no_resources(self): |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 30 | stack_name = data_utils.rand_name('heat') |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 31 | |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 32 | # create the stack |
| 33 | stack_identifier = self.create_stack( |
| 34 | stack_name, self.empty_template) |
Steve Baker | 6c2e0bf | 2013-06-21 11:23:20 +1200 | [diff] [blame] | 35 | stack_id = stack_identifier.split('/')[1] |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 36 | |
| 37 | # wait for create complete (with no resources it should be instant) |
| 38 | self.client.wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE') |
| 39 | |
Steve Baker | 6c2e0bf | 2013-06-21 11:23:20 +1200 | [diff] [blame] | 40 | # check for stack in list |
Anusha Ramineni | ab6c3a3 | 2015-08-18 08:33:09 +0530 | [diff] [blame] | 41 | stacks = self.client.list_stacks()['stacks'] |
Bartosz Górski | ab33b7e | 2013-06-27 00:39:47 -0700 | [diff] [blame] | 42 | list_ids = list([stack['id'] for stack in stacks]) |
Steve Baker | 6c2e0bf | 2013-06-21 11:23:20 +1200 | [diff] [blame] | 43 | self.assertIn(stack_id, list_ids) |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 44 | |
| 45 | # fetch the stack |
Anusha Ramineni | ab6c3a3 | 2015-08-18 08:33:09 +0530 | [diff] [blame] | 46 | stack = self.client.show_stack(stack_identifier)['stack'] |
Bartosz Górski | ab33b7e | 2013-06-27 00:39:47 -0700 | [diff] [blame] | 47 | self.assertEqual('CREATE_COMPLETE', stack['stack_status']) |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 48 | |
| 49 | # fetch the stack by name |
Anusha Ramineni | ab6c3a3 | 2015-08-18 08:33:09 +0530 | [diff] [blame] | 50 | stack = self.client.show_stack(stack_name)['stack'] |
Bartosz Górski | ab33b7e | 2013-06-27 00:39:47 -0700 | [diff] [blame] | 51 | self.assertEqual('CREATE_COMPLETE', stack['stack_status']) |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 52 | |
| 53 | # fetch the stack by id |
Anusha Ramineni | ab6c3a3 | 2015-08-18 08:33:09 +0530 | [diff] [blame] | 54 | stack = self.client.show_stack(stack_id)['stack'] |
Bartosz Górski | ab33b7e | 2013-06-27 00:39:47 -0700 | [diff] [blame] | 55 | self.assertEqual('CREATE_COMPLETE', stack['stack_status']) |
Steve Baker | d2525a9 | 2013-05-06 15:29:03 +1200 | [diff] [blame] | 56 | |
| 57 | # delete the stack |
Joseph Lanoux | 2707a0f | 2014-08-22 11:05:21 +0000 | [diff] [blame] | 58 | self.client.delete_stack(stack_identifier) |
Steven Hardy | 93eddcc | 2014-07-24 15:03:33 +0100 | [diff] [blame] | 59 | self.client.wait_for_stack_status(stack_identifier, 'DELETE_COMPLETE') |