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