Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [diff] [blame] | 1 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 |
| 2 | |
ZhiQiang Fan | 39f9722 | 2013-09-20 04:49:44 +0800 | [diff] [blame] | 3 | # Copyright 2012 OpenStack Foundation |
Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [diff] [blame] | 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 | |
ivan-zhu | 1feeb38 | 2013-01-24 10:14:39 +0800 | [diff] [blame] | 18 | import testtools |
Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [diff] [blame] | 19 | |
Sean Dague | 1937d09 | 2013-05-17 16:36:38 -0400 | [diff] [blame] | 20 | from tempest.api import compute |
| 21 | from tempest.api.compute import base |
Chris Yeoh | 9465b0b | 2013-02-09 22:19:15 +1030 | [diff] [blame] | 22 | from tempest.test import attr |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 23 | |
| 24 | |
ivan-zhu | f2b0050 | 2013-10-18 10:06:52 +0800 | [diff] [blame] | 25 | class ServerDiskConfigTestJSON(base.BaseV2ComputeTest): |
Attila Fazekas | 19044d5 | 2013-02-16 07:35:06 +0100 | [diff] [blame] | 26 | _interface = 'json' |
David Kranz | 1b3bf7f | 2012-04-12 14:39:23 -0400 | [diff] [blame] | 27 | |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 28 | @classmethod |
| 29 | def setUpClass(cls): |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 30 | if not compute.DISK_CONFIG_ENABLED: |
| 31 | msg = "DiskConfig extension not enabled." |
ivan-zhu | 1feeb38 | 2013-01-24 10:14:39 +0800 | [diff] [blame] | 32 | raise cls.skipException(msg) |
ivan-zhu | a5141d9 | 2013-03-06 23:12:43 +0800 | [diff] [blame] | 33 | super(ServerDiskConfigTestJSON, cls).setUpClass() |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 34 | cls.client = cls.os.servers_client |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame^] | 35 | resp, server = cls.create_test_server(wait_until='ACTIVE') |
| 36 | cls.server_id = server['id'] |
| 37 | |
| 38 | def _update_server_with_disk_config(self, disk_config): |
| 39 | resp, server = self.client.get_server(self.server_id) |
| 40 | if disk_config != server['OS-DCF:diskConfig']: |
| 41 | resp, server = self.client.update_server(self.server_id, |
| 42 | disk_config=disk_config) |
| 43 | self.assertEqual(200, resp.status) |
| 44 | self.client.wait_for_server_status(server['id'], 'ACTIVE') |
| 45 | resp, server = self.client.get_server(server['id']) |
| 46 | self.assertEqual(disk_config, server['OS-DCF:diskConfig']) |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 47 | |
Giulio Fidente | ba3985a | 2013-05-29 01:46:36 +0200 | [diff] [blame] | 48 | @attr(type='gate') |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 49 | def test_rebuild_server_with_manual_disk_config(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 50 | # A server should be rebuilt using the manual disk config option |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame^] | 51 | self._update_server_with_disk_config(disk_config='AUTO') |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 52 | |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame^] | 53 | resp, server = self.client.rebuild(self.server_id, |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 54 | self.image_ref_alt, |
| 55 | disk_config='MANUAL') |
| 56 | |
Attila Fazekas | f7f34f9 | 2013-08-01 17:01:44 +0200 | [diff] [blame] | 57 | # Wait for the server to become active |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 58 | self.client.wait_for_server_status(server['id'], 'ACTIVE') |
| 59 | |
Attila Fazekas | f7f34f9 | 2013-08-01 17:01:44 +0200 | [diff] [blame] | 60 | # Verify the specified attributes are set correctly |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 61 | resp, server = self.client.get_server(server['id']) |
| 62 | self.assertEqual('MANUAL', server['OS-DCF:diskConfig']) |
| 63 | |
Giulio Fidente | ba3985a | 2013-05-29 01:46:36 +0200 | [diff] [blame] | 64 | @attr(type='gate') |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 65 | def test_rebuild_server_with_auto_disk_config(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 66 | # A server should be rebuilt using the auto disk config option |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame^] | 67 | self._update_server_with_disk_config(disk_config='MANUAL') |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 68 | |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame^] | 69 | resp, server = self.client.rebuild(self.server_id, |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 70 | self.image_ref_alt, |
| 71 | disk_config='AUTO') |
| 72 | |
Attila Fazekas | f7f34f9 | 2013-08-01 17:01:44 +0200 | [diff] [blame] | 73 | # Wait for the server to become active |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 74 | self.client.wait_for_server_status(server['id'], 'ACTIVE') |
| 75 | |
Attila Fazekas | f7f34f9 | 2013-08-01 17:01:44 +0200 | [diff] [blame] | 76 | # Verify the specified attributes are set correctly |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 77 | resp, server = self.client.get_server(server['id']) |
| 78 | self.assertEqual('AUTO', server['OS-DCF:diskConfig']) |
| 79 | |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame^] | 80 | def _get_alternative_flavor(self): |
| 81 | resp, server = self.client.get_server(self.server_id) |
| 82 | |
| 83 | if int(server['flavor']['id']) == self.flavor_ref: |
| 84 | return self.flavor_ref_alt |
| 85 | else: |
| 86 | return self.flavor_ref |
| 87 | |
ivan-zhu | 1feeb38 | 2013-01-24 10:14:39 +0800 | [diff] [blame] | 88 | @testtools.skipUnless(compute.RESIZE_AVAILABLE, 'Resize not available.') |
Giulio Fidente | ba3985a | 2013-05-29 01:46:36 +0200 | [diff] [blame] | 89 | @attr(type='gate') |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 90 | def test_resize_server_from_manual_to_auto(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 91 | # A server should be resized from manual to auto disk config |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame^] | 92 | self._update_server_with_disk_config(disk_config='MANUAL') |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 93 | |
Attila Fazekas | f7f34f9 | 2013-08-01 17:01:44 +0200 | [diff] [blame] | 94 | # Resize with auto option |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame^] | 95 | flavor_id = self._get_alternative_flavor() |
| 96 | self.client.resize(self.server_id, flavor_id, disk_config='AUTO') |
| 97 | self.client.wait_for_server_status(self.server_id, 'VERIFY_RESIZE') |
| 98 | self.client.confirm_resize(self.server_id) |
| 99 | self.client.wait_for_server_status(self.server_id, 'ACTIVE') |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 100 | |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame^] | 101 | resp, server = self.client.get_server(self.server_id) |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 102 | self.assertEqual('AUTO', server['OS-DCF:diskConfig']) |
| 103 | |
ivan-zhu | 1feeb38 | 2013-01-24 10:14:39 +0800 | [diff] [blame] | 104 | @testtools.skipUnless(compute.RESIZE_AVAILABLE, 'Resize not available.') |
Giulio Fidente | ba3985a | 2013-05-29 01:46:36 +0200 | [diff] [blame] | 105 | @attr(type='gate') |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 106 | def test_resize_server_from_auto_to_manual(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 107 | # A server should be resized from auto to manual disk config |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame^] | 108 | self._update_server_with_disk_config(disk_config='AUTO') |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 109 | |
Attila Fazekas | f7f34f9 | 2013-08-01 17:01:44 +0200 | [diff] [blame] | 110 | # Resize with manual option |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame^] | 111 | flavor_id = self._get_alternative_flavor() |
| 112 | self.client.resize(self.server_id, flavor_id, disk_config='MANUAL') |
| 113 | self.client.wait_for_server_status(self.server_id, 'VERIFY_RESIZE') |
| 114 | self.client.confirm_resize(self.server_id) |
| 115 | self.client.wait_for_server_status(self.server_id, 'ACTIVE') |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 116 | |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame^] | 117 | resp, server = self.client.get_server(self.server_id) |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 118 | self.assertEqual('MANUAL', server['OS-DCF:diskConfig']) |
| 119 | |
ivan-zhu | 72d7d5b | 2013-10-16 17:30:58 +0800 | [diff] [blame] | 120 | @attr(type='gate') |
| 121 | def test_update_server_from_auto_to_manual(self): |
| 122 | # A server should be updated from auto to manual disk config |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame^] | 123 | self._update_server_with_disk_config(disk_config='AUTO') |
ivan-zhu | 72d7d5b | 2013-10-16 17:30:58 +0800 | [diff] [blame] | 124 | |
| 125 | # Update the disk_config attribute to manual |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame^] | 126 | resp, server = self.client.update_server(self.server_id, |
ivan-zhu | 72d7d5b | 2013-10-16 17:30:58 +0800 | [diff] [blame] | 127 | disk_config='MANUAL') |
| 128 | self.assertEqual(200, resp.status) |
| 129 | self.client.wait_for_server_status(server['id'], 'ACTIVE') |
| 130 | |
| 131 | # Verify the disk_config attribute is set correctly |
| 132 | resp, server = self.client.get_server(server['id']) |
| 133 | self.assertEqual('MANUAL', server['OS-DCF:diskConfig']) |
ivan-zhu | a5141d9 | 2013-03-06 23:12:43 +0800 | [diff] [blame] | 134 | |
| 135 | |
| 136 | class ServerDiskConfigTestXML(ServerDiskConfigTestJSON): |
| 137 | _interface = 'xml' |