blob: 2acf97b7ac489e5ad2c907271661b6029a6a45f7 [file] [log] [blame]
Clint Byrum71f27632013-09-09 11:41:32 -07001# 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
Masayuki Igawa4b29e472015-02-16 10:41:54 +090013from tempest_lib import exceptions as lib_exc
Clint Byrum71f27632013-09-09 11:41:32 -070014
15from tempest.api.orchestration import base
Fei Long Wangd39431f2015-05-14 11:30:48 +120016from tempest.common.utils import data_utils
Matthew Treinishcb09bbb2014-01-29 18:20:25 +000017from tempest import config
Matthew Treinish5c660ab2014-05-18 21:14:36 -040018from tempest import test
Clint Byrum71f27632013-09-09 11:41:32 -070019
Matthew Treinishcb09bbb2014-01-29 18:20:25 +000020CONF = config.CONF
Clint Byrum71f27632013-09-09 11:41:32 -070021
Clint Byrum71f27632013-09-09 11:41:32 -070022
23class TestServerStackLimits(base.BaseOrchestrationTest):
Clint Byrum71f27632013-09-09 11:41:32 -070024
Chris Hoge7579c1a2015-02-26 14:12:15 -080025 @test.idempotent_id('ec9bed71-c460-45c9-ab98-295caa9fd76b')
Clint Byrum71f27632013-09-09 11:41:32 -070026 def test_exceed_max_template_size_fails(self):
Sean Daguead824912014-03-25 14:56:35 -040027 stack_name = data_utils.rand_name('heat')
Matthew Treinishcb09bbb2014-01-29 18:20:25 +000028 fill = 'A' * CONF.orchestration.max_template_size
Clint Byrum71f27632013-09-09 11:41:32 -070029 template = '''
30HeatTemplateFormatVersion: '2012-12-12'
31Description: '%s'
32Outputs:
33 Foo: bar''' % fill
Masayuki Igawa4b29e472015-02-16 10:41:54 +090034 ex = self.assertRaises(lib_exc.BadRequest, self.create_stack,
Sean Daguead824912014-03-25 14:56:35 -040035 stack_name, template)
Clint Byrum71f27632013-09-09 11:41:32 -070036 self.assertIn('Template exceeds maximum allowed size', str(ex))
Steven Hardyfdc6bd72014-03-21 16:56:04 +000037
Chris Hoge7579c1a2015-02-26 14:12:15 -080038 @test.idempotent_id('d1b83e73-7cad-4a22-9839-036548c5387c')
Steven Hardyfdc6bd72014-03-21 16:56:04 +000039 def test_exceed_max_resources_per_stack(self):
40 stack_name = data_utils.rand_name('heat')
41 # Create a big template, one resource more than the limit
42 template = 'heat_template_version: \'2013-05-23\'\nresources:\n'
43 rsrc_snippet = ' random%s:\n type: \'OS::Heat::RandomString\'\n'
44 num_resources = CONF.orchestration.max_resources_per_stack + 1
45 for i in range(num_resources):
46 template += rsrc_snippet % i
47
Masayuki Igawa4b29e472015-02-16 10:41:54 +090048 ex = self.assertRaises(lib_exc.BadRequest, self.create_stack,
Steven Hardyfdc6bd72014-03-21 16:56:04 +000049 stack_name, template)
50 self.assertIn('Maximum resources per stack exceeded', str(ex))