blob: d5e66e83b3ca2fa7605c6c9c83b5fcba1363593c [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
26 def setUpClass(cls):
27 super(StacksTestJSON, cls).setUpClass()
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):
Bartosz Górskiab33b7e2013-06-27 00:39:47 -070031 resp, stacks = self.client.list_stacks()
Steve Bakerd2525a92013-05-06 15:29:03 +120032 self.assertEqual('200', resp['status'])
33 self.assertIsInstance(stacks, list)
34
Matthew Treinish5c660ab2014-05-18 21:14:36 -040035 @test.attr(type='smoke')
Steve Bakerd2525a92013-05-06 15:29:03 +120036 def test_stack_crud_no_resources(self):
Masayuki Igawa259c1132013-10-31 17:48:44 +090037 stack_name = data_utils.rand_name('heat')
Steve Bakerd2525a92013-05-06 15:29:03 +120038
Steve Bakerd2525a92013-05-06 15:29:03 +120039 # create the stack
40 stack_identifier = self.create_stack(
41 stack_name, self.empty_template)
Steve Baker6c2e0bf2013-06-21 11:23:20 +120042 stack_id = stack_identifier.split('/')[1]
Steve Bakerd2525a92013-05-06 15:29:03 +120043
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 Baker6c2e0bf2013-06-21 11:23:20 +120047 # check for stack in list
Bartosz Górskiab33b7e2013-06-27 00:39:47 -070048 resp, stacks = self.client.list_stacks()
49 list_ids = list([stack['id'] for stack in stacks])
Steve Baker6c2e0bf2013-06-21 11:23:20 +120050 self.assertIn(stack_id, list_ids)
Steve Bakerd2525a92013-05-06 15:29:03 +120051
52 # fetch the stack
Bartosz Górskiab33b7e2013-06-27 00:39:47 -070053 resp, stack = self.client.get_stack(stack_identifier)
54 self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
Steve Bakerd2525a92013-05-06 15:29:03 +120055
56 # fetch the stack by name
Bartosz Górskiab33b7e2013-06-27 00:39:47 -070057 resp, stack = self.client.get_stack(stack_name)
58 self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
Steve Bakerd2525a92013-05-06 15:29:03 +120059
60 # fetch the stack by id
Bartosz Górskiab33b7e2013-06-27 00:39:47 -070061 resp, stack = self.client.get_stack(stack_id)
62 self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
Steve Bakerd2525a92013-05-06 15:29:03 +120063
64 # delete the stack
65 resp = self.client.delete_stack(stack_identifier)
66 self.assertEqual('204', resp[0]['status'])
Steven Hardy93eddcc2014-07-24 15:03:33 +010067 self.client.wait_for_stack_status(stack_identifier, 'DELETE_COMPLETE')