blob: 4bda5ab41e861ba355f3123607ba3bb6c8c18636 [file] [log] [blame]
Steve Bakerd2525a92013-05-06 15:29:03 +12001# 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 Bakerd2525a92013-05-06 15:29:03 +120015from tempest.api.orchestration import base
16from tempest.common.utils.data_utils import rand_name
Matthew Treinishf4a9b0f2013-07-26 16:58:26 -040017from tempest.openstack.common import log as logging
Steve Bakerd2525a92013-05-06 15:29:03 +120018from tempest.test import attr
19
20
21LOG = logging.getLogger(__name__)
22
23
24class 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órskiab33b7e2013-06-27 00:39:47 -070036 resp, stacks = self.client.list_stacks()
Steve Bakerd2525a92013-05-06 15:29:03 +120037 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 Bakerd2525a92013-05-06 15:29:03 +120044 # create the stack
45 stack_identifier = self.create_stack(
46 stack_name, self.empty_template)
Steve Baker6c2e0bf2013-06-21 11:23:20 +120047 stack_id = stack_identifier.split('/')[1]
Steve Bakerd2525a92013-05-06 15:29:03 +120048
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 Baker6c2e0bf2013-06-21 11:23:20 +120052 # check for stack in list
Bartosz Górskiab33b7e2013-06-27 00:39:47 -070053 resp, stacks = self.client.list_stacks()
54 list_ids = list([stack['id'] for stack in stacks])
Steve Baker6c2e0bf2013-06-21 11:23:20 +120055 self.assertIn(stack_id, list_ids)
Steve Bakerd2525a92013-05-06 15:29:03 +120056
57 # fetch the stack
Bartosz Górskiab33b7e2013-06-27 00:39:47 -070058 resp, stack = self.client.get_stack(stack_identifier)
59 self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
Steve Bakerd2525a92013-05-06 15:29:03 +120060
61 # fetch the stack by name
Bartosz Górskiab33b7e2013-06-27 00:39:47 -070062 resp, stack = self.client.get_stack(stack_name)
63 self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
Steve Bakerd2525a92013-05-06 15:29:03 +120064
65 # fetch the stack by id
Bartosz Górskiab33b7e2013-06-27 00:39:47 -070066 resp, stack = self.client.get_stack(stack_id)
67 self.assertEqual('CREATE_COMPLETE', stack['stack_status'])
Steve Bakerd2525a92013-05-06 15:29:03 +120068
69 # delete the stack
70 resp = self.client.delete_stack(stack_identifier)
71 self.assertEqual('204', resp[0]['status'])