blob: dc1bb4f81739a77efc5900d77a95e3b5ad4d0d61 [file] [log] [blame]
Steve Bakerd2525a92013-05-06 15:29:03 +12001# 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 Bakerd2525a92013-05-06 15:29:03 +120013from tempest.api.orchestration import base
Ken'ichi Ohmichi60680a82017-03-10 11:03:16 -080014from tempest.lib.common.utils import data_utils
Ken'ichi Ohmichi835a9452017-01-27 18:17:07 -080015from tempest.lib import decorators
Steve Bakerd2525a92013-05-06 15:29:03 +120016
17
Steve Bakerd2525a92013-05-06 15:29:03 +120018class StacksTestJSON(base.BaseOrchestrationTest):
Steve Bakerd2525a92013-05-06 15:29:03 +120019 empty_template = "HeatTemplateFormatVersion: '2012-12-12'\n"
20
Jordan Pittier3b46d272017-04-12 16:17:28 +020021 @decorators.attr(type='smoke')
Ken'ichi Ohmichi835a9452017-01-27 18:17:07 -080022 @decorators.idempotent_id('d35d628c-07f6-4674-85a1-74db9919e986')
Steve Bakerd2525a92013-05-06 15:29:03 +120023 def test_stack_list_responds(self):
Anusha Ramineniab6c3a32015-08-18 08:33:09 +053024 stacks = self.client.list_stacks()['stacks']
Steve Bakerd2525a92013-05-06 15:29:03 +120025 self.assertIsInstance(stacks, list)
26
Jordan Pittier3b46d272017-04-12 16:17:28 +020027 @decorators.attr(type='smoke')
Ken'ichi Ohmichi835a9452017-01-27 18:17:07 -080028 @decorators.idempotent_id('10498bd5-a83e-4b62-a817-ce24afe938fe')
Steve Bakerd2525a92013-05-06 15:29:03 +120029 def test_stack_crud_no_resources(self):
Masayuki Igawa259c1132013-10-31 17:48:44 +090030 stack_name = data_utils.rand_name('heat')
Steve Bakerd2525a92013-05-06 15:29:03 +120031
Steve Bakerd2525a92013-05-06 15:29:03 +120032 # create the stack
33 stack_identifier = self.create_stack(
34 stack_name, self.empty_template)
Steve Baker6c2e0bf2013-06-21 11:23:20 +120035 stack_id = stack_identifier.split('/')[1]
Steve Bakerd2525a92013-05-06 15:29:03 +120036
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 Baker6c2e0bf2013-06-21 11:23:20 +120040 # check for stack in list
Anusha Ramineniab6c3a32015-08-18 08:33:09 +053041 stacks = self.client.list_stacks()['stacks']
Bartosz Górskiab33b7e2013-06-27 00:39:47 -070042 list_ids = list([stack['id'] for stack in stacks])
Steve Baker6c2e0bf2013-06-21 11:23:20 +120043 self.assertIn(stack_id, list_ids)
Steve Bakerd2525a92013-05-06 15:29:03 +120044
45 # fetch the stack
Anusha Ramineniab6c3a32015-08-18 08:33:09 +053046 stack = self.client.show_stack(stack_identifier)['stack']
Bartosz Górskiab33b7e2013-06-27 00:39:47 -070047 self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
Steve Bakerd2525a92013-05-06 15:29:03 +120048
49 # fetch the stack by name
Anusha Ramineniab6c3a32015-08-18 08:33:09 +053050 stack = self.client.show_stack(stack_name)['stack']
Bartosz Górskiab33b7e2013-06-27 00:39:47 -070051 self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
Steve Bakerd2525a92013-05-06 15:29:03 +120052
53 # fetch the stack by id
Anusha Ramineniab6c3a32015-08-18 08:33:09 +053054 stack = self.client.show_stack(stack_id)['stack']
Bartosz Górskiab33b7e2013-06-27 00:39:47 -070055 self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
Steve Bakerd2525a92013-05-06 15:29:03 +120056
57 # delete the stack
Joseph Lanoux2707a0f2014-08-22 11:05:21 +000058 self.client.delete_stack(stack_identifier)
Steven Hardy93eddcc2014-07-24 15:03:33 +010059 self.client.wait_for_stack_status(stack_identifier, 'DELETE_COMPLETE')