blob: 3be2b7936363972193e9027e91d003794b3ba68e [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
Matthew Treinish01472ff2015-02-20 17:26:52 -050016from tempest_lib.common.utils import data_utils
17
Sean Dague1937d092013-05-17 16:36:38 -040018from tempest.api.compute import base
Hoisaleshwara Madan V S65e53032013-12-26 12:55:44 +053019from tempest import test
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050020
21
ivan-zhuf2b00502013-10-18 10:06:52 +080022class MultipleCreateTestJSON(base.BaseV2ComputeTest):
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050023 _name = 'multiple-create-test'
24
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050025 def _generate_name(self):
Masayuki Igawa259c1132013-10-31 17:48:44 +090026 return data_utils.rand_name(self._name)
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050027
28 def _create_multiple_servers(self, name=None, wait_until=None, **kwargs):
29 """
30 This is the right way to create_multiple servers and manage to get the
31 created servers into the servers list to be cleaned up after all.
32 """
33 kwargs['name'] = kwargs.get('name', self._generate_name())
David Kranz0fb14292015-02-11 15:55:20 -050034 body = self.create_test_server(**kwargs)
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050035
David Kranz0fb14292015-02-11 15:55:20 -050036 return body
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050037
Hoisaleshwara Madan V S65e53032013-12-26 12:55:44 +053038 @test.attr(type='gate')
Chris Hoge7579c1a2015-02-26 14:12:15 -080039 @test.idempotent_id('61e03386-89c3-449c-9bb1-a06f423fd9d1')
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050040 def test_multiple_create(self):
David Kranz0fb14292015-02-11 15:55:20 -050041 body = self._create_multiple_servers(wait_until='ACTIVE',
42 min_count=1,
43 max_count=2)
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050044 # NOTE(maurosr): do status response check and also make sure that
45 # reservation_id is not in the response body when the request send
46 # contains return_reservation_id=False
Attila Fazekase191cb12013-07-29 06:41:52 +020047 self.assertNotIn('reservation_id', body)
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050048
Hoisaleshwara Madan V S65e53032013-12-26 12:55:44 +053049 @test.attr(type='gate')
Chris Hoge7579c1a2015-02-26 14:12:15 -080050 @test.idempotent_id('864777fb-2f1e-44e3-b5b9-3eb6fa84f2f7')
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050051 def test_multiple_create_with_reservation_return(self):
David Kranz0fb14292015-02-11 15:55:20 -050052 body = self._create_multiple_servers(wait_until='ACTIVE',
53 min_count=1,
54 max_count=2,
55 return_reservation_id=True)
Mauro S. M. Rodriguesc5da4f42013-03-04 23:57:10 -050056 self.assertIn('reservation_id', body)