blob: bb5b89da93fa9228f5409fb51eb41ae25afd7144 [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
13import logging
Matthew Treinish01472ff2015-02-20 17:26:52 -050014
Masayuki Igawa4b29e472015-02-16 10:41:54 +090015from tempest_lib import exceptions as lib_exc
Clint Byrum71f27632013-09-09 11:41:32 -070016
17from tempest.api.orchestration import base
Fei Long Wangd39431f2015-05-14 11:30:48 +120018from tempest.common.utils import data_utils
Matthew Treinishcb09bbb2014-01-29 18:20:25 +000019from tempest import config
Matthew Treinish5c660ab2014-05-18 21:14:36 -040020from tempest import test
Clint Byrum71f27632013-09-09 11:41:32 -070021
Matthew Treinishcb09bbb2014-01-29 18:20:25 +000022CONF = config.CONF
Clint Byrum71f27632013-09-09 11:41:32 -070023
24LOG = logging.getLogger(__name__)
25
26
27class TestServerStackLimits(base.BaseOrchestrationTest):
Clint Byrum71f27632013-09-09 11:41:32 -070028
Chris Hoge7579c1a2015-02-26 14:12:15 -080029 @test.idempotent_id('ec9bed71-c460-45c9-ab98-295caa9fd76b')
Clint Byrum71f27632013-09-09 11:41:32 -070030 def test_exceed_max_template_size_fails(self):
Sean Daguead824912014-03-25 14:56:35 -040031 stack_name = data_utils.rand_name('heat')
Matthew Treinishcb09bbb2014-01-29 18:20:25 +000032 fill = 'A' * CONF.orchestration.max_template_size
Clint Byrum71f27632013-09-09 11:41:32 -070033 template = '''
34HeatTemplateFormatVersion: '2012-12-12'
35Description: '%s'
36Outputs:
37 Foo: bar''' % fill
Masayuki Igawa4b29e472015-02-16 10:41:54 +090038 ex = self.assertRaises(lib_exc.BadRequest, self.create_stack,
Sean Daguead824912014-03-25 14:56:35 -040039 stack_name, template)
Clint Byrum71f27632013-09-09 11:41:32 -070040 self.assertIn('Template exceeds maximum allowed size', str(ex))
Steven Hardyfdc6bd72014-03-21 16:56:04 +000041
Chris Hoge7579c1a2015-02-26 14:12:15 -080042 @test.idempotent_id('d1b83e73-7cad-4a22-9839-036548c5387c')
Steven Hardyfdc6bd72014-03-21 16:56:04 +000043 def test_exceed_max_resources_per_stack(self):
44 stack_name = data_utils.rand_name('heat')
45 # Create a big template, one resource more than the limit
46 template = 'heat_template_version: \'2013-05-23\'\nresources:\n'
47 rsrc_snippet = ' random%s:\n type: \'OS::Heat::RandomString\'\n'
48 num_resources = CONF.orchestration.max_resources_per_stack + 1
49 for i in range(num_resources):
50 template += rsrc_snippet % i
51
Masayuki Igawa4b29e472015-02-16 10:41:54 +090052 ex = self.assertRaises(lib_exc.BadRequest, self.create_stack,
Steven Hardyfdc6bd72014-03-21 16:56:04 +000053 stack_name, template)
54 self.assertIn('Maximum resources per stack exceeded', str(ex))