blob: dbfee8ff77491e364814dc1c6a310c17ec67ffab [file] [log] [blame]
ZhiQiang Fan39f97222013-09-20 04:49:44 +08001# Copyright 2012 OpenStack Foundation
Jay Pipes13b479b2012-06-11 14:52:27 -04002# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
Daryl Wallecked8bef32011-12-05 23:02:08 -060016import base64
Masayuki Igawa90c914e2015-01-20 14:48:16 +090017from tempest_lib import exceptions as lib_exc
Daryl Wallecked8bef32011-12-05 23:02:08 -060018
Sean Dague1937d092013-05-17 16:36:38 -040019from tempest.api.compute import base
Yuiko Takadae9999d62014-03-06 09:22:54 +000020from tempest import test
Jay Pipes13b479b2012-06-11 14:52:27 -040021
Daryl Wallecked8bef32011-12-05 23:02:08 -060022
ivan-zhuf2b00502013-10-18 10:06:52 +080023class ServerPersonalityTestJSON(base.BaseV2ComputeTest):
Attila Fazekas19044d52013-02-16 07:35:06 +010024
25 @classmethod
Rohan Kanade60b73092015-02-04 17:58:19 +053026 def setup_clients(cls):
27 super(ServerPersonalityTestJSON, cls).setup_clients()
Attila Fazekas19044d52013-02-16 07:35:06 +010028 cls.client = cls.servers_client
29 cls.user_client = cls.limits_client
Daryl Wallecked8bef32011-12-05 23:02:08 -060030
Yuiko Takadae9999d62014-03-06 09:22:54 +000031 @test.attr(type='gate')
Chris Hoge7579c1a2015-02-26 14:12:15 -080032 @test.idempotent_id('176cd8c9-b9e8-48ee-a480-180beab292bf')
Daryl Wallecked8bef32011-12-05 23:02:08 -060033 def test_personality_files_exceed_limit(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050034 # Server creation should fail if greater than the maximum allowed
35 # number of files are injected into the server.
Daryl Wallecked8bef32011-12-05 23:02:08 -060036 file_contents = 'This is a test file.'
37 personality = []
rajalakshmi-ganesana4ab0072012-08-07 19:48:56 +053038 max_file_limit = \
39 self.user_client.get_specific_absolute_limit("maxPersonality")
ghanshyamaae07812014-12-17 11:38:06 +090040 if max_file_limit == -1:
41 raise self.skipException("No limit for personality files")
rajalakshmi-ganesana4ab0072012-08-07 19:48:56 +053042 for i in range(0, int(max_file_limit) + 1):
Daryl Wallecked8bef32011-12-05 23:02:08 -060043 path = 'etc/test' + str(i) + '.txt'
44 personality.append({'path': path,
45 'contents': base64.b64encode(file_contents)})
Ken'ichi Ohmichi20f43ed2014-08-05 00:33:42 +000046 # A 403 Forbidden or 413 Overlimit (old behaviour) exception
47 # will be raised when out of quota
Masayuki Igawa6b1cd292015-02-16 11:11:55 +090048 self.assertRaises((lib_exc.Forbidden, lib_exc.OverLimit),
Ken'ichi Ohmichi20f43ed2014-08-05 00:33:42 +000049 self.create_test_server, personality=personality)
Daryl Wallecked8bef32011-12-05 23:02:08 -060050
Yuiko Takadae9999d62014-03-06 09:22:54 +000051 @test.attr(type='gate')
Chris Hoge7579c1a2015-02-26 14:12:15 -080052 @test.idempotent_id('52f12ee8-5180-40cc-b417-31572ea3d555')
Daryl Wallecked8bef32011-12-05 23:02:08 -060053 def test_can_create_server_with_max_number_personality_files(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050054 # Server should be created successfully if maximum allowed number of
55 # files is injected into the server during creation.
saradpatele6062f62013-03-11 01:17:32 -070056 file_contents = 'This is a test file.'
57 max_file_limit = \
58 self.user_client.get_specific_absolute_limit("maxPersonality")
ghanshyamaae07812014-12-17 11:38:06 +090059 if max_file_limit == -1:
60 raise self.skipException("No limit for personality files")
saradpatele6062f62013-03-11 01:17:32 -070061 person = []
62 for i in range(0, int(max_file_limit)):
63 path = 'etc/test' + str(i) + '.txt'
64 person.append({
65 'path': path,
66 'contents': base64.b64encode(file_contents),
67 })
David Kranz0fb14292015-02-11 15:55:20 -050068 self.create_test_server(personality=person)