Clint Byrum | 71f2763 | 2013-09-09 11:41:32 -0700 | [diff] [blame] | 1 | # 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 | |
| 13 | import logging |
Matthew Treinish | 01472ff | 2015-02-20 17:26:52 -0500 | [diff] [blame] | 14 | |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 15 | from tempest_lib import exceptions as lib_exc |
Clint Byrum | 71f2763 | 2013-09-09 11:41:32 -0700 | [diff] [blame] | 16 | |
| 17 | from tempest.api.orchestration import base |
Fei Long Wang | d39431f | 2015-05-14 11:30:48 +1200 | [diff] [blame^] | 18 | from tempest.common.utils import data_utils |
Matthew Treinish | cb09bbb | 2014-01-29 18:20:25 +0000 | [diff] [blame] | 19 | from tempest import config |
Matthew Treinish | 5c660ab | 2014-05-18 21:14:36 -0400 | [diff] [blame] | 20 | from tempest import test |
Clint Byrum | 71f2763 | 2013-09-09 11:41:32 -0700 | [diff] [blame] | 21 | |
Matthew Treinish | cb09bbb | 2014-01-29 18:20:25 +0000 | [diff] [blame] | 22 | CONF = config.CONF |
Clint Byrum | 71f2763 | 2013-09-09 11:41:32 -0700 | [diff] [blame] | 23 | |
| 24 | LOG = logging.getLogger(__name__) |
| 25 | |
| 26 | |
| 27 | class TestServerStackLimits(base.BaseOrchestrationTest): |
Clint Byrum | 71f2763 | 2013-09-09 11:41:32 -0700 | [diff] [blame] | 28 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 29 | @test.idempotent_id('ec9bed71-c460-45c9-ab98-295caa9fd76b') |
Clint Byrum | 71f2763 | 2013-09-09 11:41:32 -0700 | [diff] [blame] | 30 | def test_exceed_max_template_size_fails(self): |
Sean Dague | ad82491 | 2014-03-25 14:56:35 -0400 | [diff] [blame] | 31 | stack_name = data_utils.rand_name('heat') |
Matthew Treinish | cb09bbb | 2014-01-29 18:20:25 +0000 | [diff] [blame] | 32 | fill = 'A' * CONF.orchestration.max_template_size |
Clint Byrum | 71f2763 | 2013-09-09 11:41:32 -0700 | [diff] [blame] | 33 | template = ''' |
| 34 | HeatTemplateFormatVersion: '2012-12-12' |
| 35 | Description: '%s' |
| 36 | Outputs: |
| 37 | Foo: bar''' % fill |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 38 | ex = self.assertRaises(lib_exc.BadRequest, self.create_stack, |
Sean Dague | ad82491 | 2014-03-25 14:56:35 -0400 | [diff] [blame] | 39 | stack_name, template) |
Clint Byrum | 71f2763 | 2013-09-09 11:41:32 -0700 | [diff] [blame] | 40 | self.assertIn('Template exceeds maximum allowed size', str(ex)) |
Steven Hardy | fdc6bd7 | 2014-03-21 16:56:04 +0000 | [diff] [blame] | 41 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 42 | @test.idempotent_id('d1b83e73-7cad-4a22-9839-036548c5387c') |
Steven Hardy | fdc6bd7 | 2014-03-21 16:56:04 +0000 | [diff] [blame] | 43 | 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 Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 52 | ex = self.assertRaises(lib_exc.BadRequest, self.create_stack, |
Steven Hardy | fdc6bd7 | 2014-03-21 16:56:04 +0000 | [diff] [blame] | 53 | stack_name, template) |
| 54 | self.assertIn('Maximum resources per stack exceeded', str(ex)) |