blob: 91c350ed6fe11c7379fd3968662a1ea8987f78b6 [file] [log] [blame]
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -05001# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2013 IBM Corp
4# All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License. You may obtain
8# a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15# License for the specific language governing permissions and limitations
16# under the License.
17
Sean Dague1937d092013-05-17 16:36:38 -040018from tempest.api.compute import base
Masayuki Igawa259c1132013-10-31 17:48:44 +090019from tempest.common.utils import data_utils
Hoisaleshwara Madan V S65e53032013-12-26 12:55:44 +053020from tempest import test
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050021
22
ivan-zhuf2b00502013-10-18 10:06:52 +080023class MultipleCreateTestJSON(base.BaseV2ComputeTest):
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050024 _interface = 'json'
25 _name = 'multiple-create-test'
26
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050027 def _generate_name(self):
Masayuki Igawa259c1132013-10-31 17:48:44 +090028 return data_utils.rand_name(self._name)
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050029
30 def _create_multiple_servers(self, name=None, wait_until=None, **kwargs):
31 """
32 This is the right way to create_multiple servers and manage to get the
33 created servers into the servers list to be cleaned up after all.
34 """
35 kwargs['name'] = kwargs.get('name', self._generate_name())
Ken'ichi Ohmichicfc052e2013-10-23 11:50:04 +090036 resp, body = self.create_test_server(**kwargs)
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050037
38 return resp, body
39
Hoisaleshwara Madan V S65e53032013-12-26 12:55:44 +053040 @test.attr(type='gate')
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050041 def test_multiple_create(self):
42 resp, body = self._create_multiple_servers(wait_until='ACTIVE',
43 min_count=1,
44 max_count=2)
45 # NOTE(maurosr): do status response check and also make sure that
46 # reservation_id is not in the response body when the request send
47 # contains return_reservation_id=False
48 self.assertEqual('202', resp['status'])
Attila Fazekase191cb12013-07-29 06:41:52 +020049 self.assertNotIn('reservation_id', body)
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050050
Hoisaleshwara Madan V S65e53032013-12-26 12:55:44 +053051 @test.attr(type='gate')
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050052 def test_multiple_create_with_reservation_return(self):
53 resp, body = self._create_multiple_servers(wait_until='ACTIVE',
54 min_count=1,
55 max_count=2,
56 return_reservation_id=True)
Chang Bo Guo4ae51d42013-09-16 18:01:39 -070057 self.assertEqual(resp['status'], '202')
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050058 self.assertIn('reservation_id', body)
59
60
61class MultipleCreateTestXML(MultipleCreateTestJSON):
62 _interface = 'xml'