blob: 40b9c161d3a3487918a915e4ad91ec68cf4fb86e [file] [log] [blame]
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -05001# Copyright 2013 IBM Corp
2# 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
Sean Dague1937d092013-05-17 16:36:38 -040016from tempest.api.compute import base
Masayuki Igawa259c1132013-10-31 17:48:44 +090017from tempest.common.utils import data_utils
Hoisaleshwara Madan V S65e53032013-12-26 12:55:44 +053018from tempest import test
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050019
20
ivan-zhuf2b00502013-10-18 10:06:52 +080021class MultipleCreateTestJSON(base.BaseV2ComputeTest):
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050022 _name = 'multiple-create-test'
23
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050024 def _generate_name(self):
Masayuki Igawa259c1132013-10-31 17:48:44 +090025 return data_utils.rand_name(self._name)
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050026
27 def _create_multiple_servers(self, name=None, wait_until=None, **kwargs):
28 """
29 This is the right way to create_multiple servers and manage to get the
30 created servers into the servers list to be cleaned up after all.
31 """
32 kwargs['name'] = kwargs.get('name', self._generate_name())
Ken'ichi Ohmichicfc052e2013-10-23 11:50:04 +090033 resp, body = self.create_test_server(**kwargs)
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050034
35 return resp, body
36
Hoisaleshwara Madan V S65e53032013-12-26 12:55:44 +053037 @test.attr(type='gate')
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050038 def test_multiple_create(self):
39 resp, body = self._create_multiple_servers(wait_until='ACTIVE',
40 min_count=1,
41 max_count=2)
42 # NOTE(maurosr): do status response check and also make sure that
43 # reservation_id is not in the response body when the request send
44 # contains return_reservation_id=False
45 self.assertEqual('202', resp['status'])
Attila Fazekase191cb12013-07-29 06:41:52 +020046 self.assertNotIn('reservation_id', body)
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050047
Hoisaleshwara Madan V S65e53032013-12-26 12:55:44 +053048 @test.attr(type='gate')
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050049 def test_multiple_create_with_reservation_return(self):
50 resp, body = self._create_multiple_servers(wait_until='ACTIVE',
51 min_count=1,
52 max_count=2,
53 return_reservation_id=True)
Chang Bo Guo4ae51d42013-09-16 18:01:39 -070054 self.assertEqual(resp['status'], '202')
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050055 self.assertIn('reservation_id', body)
56
57
58class MultipleCreateTestXML(MultipleCreateTestJSON):
59 _interface = 'xml'