blob: 8ee62ab6f209262f9edbd230f9c9db63fd885d21 [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
14
15from tempest.api.orchestration import base
Masayuki Igawa259c1132013-10-31 17:48:44 +090016from tempest.common.utils import data_utils
Matthew Treinishcb09bbb2014-01-29 18:20:25 +000017from tempest import config
Clint Byrum71f27632013-09-09 11:41:32 -070018from tempest import exceptions
Matthew Treinish5c660ab2014-05-18 21:14:36 -040019from tempest import test
Clint Byrum71f27632013-09-09 11:41:32 -070020
Matthew Treinishcb09bbb2014-01-29 18:20:25 +000021CONF = config.CONF
Clint Byrum71f27632013-09-09 11:41:32 -070022
23LOG = logging.getLogger(__name__)
24
25
26class TestServerStackLimits(base.BaseOrchestrationTest):
Clint Byrum71f27632013-09-09 11:41:32 -070027
Matthew Treinish5c660ab2014-05-18 21:14:36 -040028 @test.attr(type='gate')
Clint Byrum71f27632013-09-09 11:41:32 -070029 def test_exceed_max_template_size_fails(self):
Sean Daguead824912014-03-25 14:56:35 -040030 stack_name = data_utils.rand_name('heat')
Matthew Treinishcb09bbb2014-01-29 18:20:25 +000031 fill = 'A' * CONF.orchestration.max_template_size
Clint Byrum71f27632013-09-09 11:41:32 -070032 template = '''
33HeatTemplateFormatVersion: '2012-12-12'
34Description: '%s'
35Outputs:
36 Foo: bar''' % fill
37 ex = self.assertRaises(exceptions.BadRequest, self.create_stack,
Sean Daguead824912014-03-25 14:56:35 -040038 stack_name, template)
Clint Byrum71f27632013-09-09 11:41:32 -070039 self.assertIn('Template exceeds maximum allowed size', str(ex))
Steven Hardyfdc6bd72014-03-21 16:56:04 +000040
Matthew Treinish5c660ab2014-05-18 21:14:36 -040041 @test.attr(type='gate')
Steven Hardyfdc6bd72014-03-21 16:56:04 +000042 def test_exceed_max_resources_per_stack(self):
43 stack_name = data_utils.rand_name('heat')
44 # Create a big template, one resource more than the limit
45 template = 'heat_template_version: \'2013-05-23\'\nresources:\n'
46 rsrc_snippet = ' random%s:\n type: \'OS::Heat::RandomString\'\n'
47 num_resources = CONF.orchestration.max_resources_per_stack + 1
48 for i in range(num_resources):
49 template += rsrc_snippet % i
50
51 ex = self.assertRaises(exceptions.BadRequest, self.create_stack,
52 stack_name, template)
53 self.assertIn('Maximum resources per stack exceeded', str(ex))