blob: 5cdd8b4f4778cea502c06f39f8ab77c139891758 [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
Masayuki Igawa259c1132013-10-31 17:48:44 +090014from tempest.common.utils import data_utils
Matthew Treinishf4a9b0f2013-07-26 16:58:26 -040015from tempest.openstack.common import log as logging
Matthew Treinish5c660ab2014-05-18 21:14:36 -040016from tempest import test
Steve Bakerd2525a92013-05-06 15:29:03 +120017
18
19LOG = logging.getLogger(__name__)
20
21
22class StacksTestJSON(base.BaseOrchestrationTest):
Steve Bakerd2525a92013-05-06 15:29:03 +120023 empty_template = "HeatTemplateFormatVersion: '2012-12-12'\n"
24
25 @classmethod
Andrea Frittoli556f7962014-09-15 13:14:54 +010026 def resource_setup(cls):
27 super(StacksTestJSON, cls).resource_setup()
Steve Bakerd2525a92013-05-06 15:29:03 +120028
Matthew Treinish5c660ab2014-05-18 21:14:36 -040029 @test.attr(type='smoke')
Steve Bakerd2525a92013-05-06 15:29:03 +120030 def test_stack_list_responds(self):
David Kranz8ad924b2015-01-16 16:50:18 -050031 stacks = self.client.list_stacks()
Steve Bakerd2525a92013-05-06 15:29:03 +120032 self.assertIsInstance(stacks, list)
33
Matthew Treinish5c660ab2014-05-18 21:14:36 -040034 @test.attr(type='smoke')
Steve Bakerd2525a92013-05-06 15:29:03 +120035 def test_stack_crud_no_resources(self):
Masayuki Igawa259c1132013-10-31 17:48:44 +090036 stack_name = data_utils.rand_name('heat')
Steve Bakerd2525a92013-05-06 15:29:03 +120037
Steve Bakerd2525a92013-05-06 15:29:03 +120038 # create the stack
39 stack_identifier = self.create_stack(
40 stack_name, self.empty_template)
Steve Baker6c2e0bf2013-06-21 11:23:20 +120041 stack_id = stack_identifier.split('/')[1]
Steve Bakerd2525a92013-05-06 15:29:03 +120042
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 Baker6c2e0bf2013-06-21 11:23:20 +120046 # check for stack in list
David Kranz8ad924b2015-01-16 16:50:18 -050047 stacks = self.client.list_stacks()
Bartosz Górskiab33b7e2013-06-27 00:39:47 -070048 list_ids = list([stack['id'] for stack in stacks])
Steve Baker6c2e0bf2013-06-21 11:23:20 +120049 self.assertIn(stack_id, list_ids)
Steve Bakerd2525a92013-05-06 15:29:03 +120050
51 # fetch the stack
David Kranz8ad924b2015-01-16 16:50:18 -050052 stack = self.client.get_stack(stack_identifier)
Bartosz Górskiab33b7e2013-06-27 00:39:47 -070053 self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
Steve Bakerd2525a92013-05-06 15:29:03 +120054
55 # fetch the stack by name
David Kranz8ad924b2015-01-16 16:50:18 -050056 stack = self.client.get_stack(stack_name)
Bartosz Górskiab33b7e2013-06-27 00:39:47 -070057 self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
Steve Bakerd2525a92013-05-06 15:29:03 +120058
59 # fetch the stack by id
David Kranz8ad924b2015-01-16 16:50:18 -050060 stack = self.client.get_stack(stack_id)
Bartosz Górskiab33b7e2013-06-27 00:39:47 -070061 self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
Steve Bakerd2525a92013-05-06 15:29:03 +120062
63 # delete the stack
Joseph Lanoux2707a0f2014-08-22 11:05:21 +000064 self.client.delete_stack(stack_identifier)
Steven Hardy93eddcc2014-07-24 15:03:33 +010065 self.client.wait_for_stack_status(stack_identifier, 'DELETE_COMPLETE')