Mauro S. M. Rodrigues | c5da4f4 | 2013-03-04 23:57:10 -0500 | [diff] [blame] | 1 | # 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 Dague | 1937d09 | 2013-05-17 16:36:38 -0400 | [diff] [blame] | 18 | from tempest.api.compute import base |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 19 | from tempest.common.utils import data_utils |
Hoisaleshwara Madan V S | 65e5303 | 2013-12-26 12:55:44 +0530 | [diff] [blame^] | 20 | from tempest import test |
Mauro S. M. Rodrigues | c5da4f4 | 2013-03-04 23:57:10 -0500 | [diff] [blame] | 21 | |
| 22 | |
ivan-zhu | f2b0050 | 2013-10-18 10:06:52 +0800 | [diff] [blame] | 23 | class MultipleCreateTestJSON(base.BaseV2ComputeTest): |
Mauro S. M. Rodrigues | c5da4f4 | 2013-03-04 23:57:10 -0500 | [diff] [blame] | 24 | _interface = 'json' |
| 25 | _name = 'multiple-create-test' |
| 26 | |
Mauro S. M. Rodrigues | c5da4f4 | 2013-03-04 23:57:10 -0500 | [diff] [blame] | 27 | def _generate_name(self): |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 28 | return data_utils.rand_name(self._name) |
Mauro S. M. Rodrigues | c5da4f4 | 2013-03-04 23:57:10 -0500 | [diff] [blame] | 29 | |
| 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 Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 36 | resp, body = self.create_test_server(**kwargs) |
Mauro S. M. Rodrigues | c5da4f4 | 2013-03-04 23:57:10 -0500 | [diff] [blame] | 37 | |
| 38 | return resp, body |
| 39 | |
Hoisaleshwara Madan V S | 65e5303 | 2013-12-26 12:55:44 +0530 | [diff] [blame^] | 40 | @test.attr(type='gate') |
Mauro S. M. Rodrigues | c5da4f4 | 2013-03-04 23:57:10 -0500 | [diff] [blame] | 41 | 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 Fazekas | e191cb1 | 2013-07-29 06:41:52 +0200 | [diff] [blame] | 49 | self.assertNotIn('reservation_id', body) |
Mauro S. M. Rodrigues | c5da4f4 | 2013-03-04 23:57:10 -0500 | [diff] [blame] | 50 | |
Hoisaleshwara Madan V S | 65e5303 | 2013-12-26 12:55:44 +0530 | [diff] [blame^] | 51 | @test.attr(type='gate') |
Mauro S. M. Rodrigues | c5da4f4 | 2013-03-04 23:57:10 -0500 | [diff] [blame] | 52 | 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 Guo | 4ae51d4 | 2013-09-16 18:01:39 -0700 | [diff] [blame] | 57 | self.assertEqual(resp['status'], '202') |
Mauro S. M. Rodrigues | c5da4f4 | 2013-03-04 23:57:10 -0500 | [diff] [blame] | 58 | self.assertIn('reservation_id', body) |
| 59 | |
| 60 | |
| 61 | class MultipleCreateTestXML(MultipleCreateTestJSON): |
| 62 | _interface = 'xml' |