ZhiQiang Fan | 39f9722 | 2013-09-20 04:49:44 +0800 | [diff] [blame] | 1 | # Copyright 2012 OpenStack Foundation |
Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [diff] [blame] | 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 | |
ivan-zhu | 1feeb38 | 2013-01-24 10:14:39 +0800 | [diff] [blame] | 16 | import testtools |
Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [diff] [blame] | 17 | |
Sean Dague | 1937d09 | 2013-05-17 16:36:38 -0400 | [diff] [blame] | 18 | from tempest.api.compute import base |
Ken'ichi Ohmichi | 0eb153c | 2015-07-13 02:18:25 +0000 | [diff] [blame] | 19 | from tempest.common import waiters |
Sean Dague | 86bd842 | 2013-12-20 09:56:44 -0500 | [diff] [blame] | 20 | from tempest import config |
Yuiko Takada | e9999d6 | 2014-03-06 09:22:54 +0000 | [diff] [blame] | 21 | from tempest import test |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 22 | |
Sean Dague | 86bd842 | 2013-12-20 09:56:44 -0500 | [diff] [blame] | 23 | CONF = config.CONF |
| 24 | |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 25 | |
ivan-zhu | f2b0050 | 2013-10-18 10:06:52 +0800 | [diff] [blame] | 26 | class ServerDiskConfigTestJSON(base.BaseV2ComputeTest): |
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 |
Rohan Kanade | 60b7309 | 2015-02-04 17:58:19 +0530 | [diff] [blame] | 29 | def skip_checks(cls): |
| 30 | super(ServerDiskConfigTestJSON, cls).skip_checks() |
Sean Dague | 86bd842 | 2013-12-20 09:56:44 -0500 | [diff] [blame] | 31 | if not CONF.compute_feature_enabled.disk_config: |
Jay Pipes | f38eaac | 2012-06-21 13:37:35 -0400 | [diff] [blame] | 32 | msg = "DiskConfig extension not enabled." |
ivan-zhu | 1feeb38 | 2013-01-24 10:14:39 +0800 | [diff] [blame] | 33 | raise cls.skipException(msg) |
Rohan Kanade | 60b7309 | 2015-02-04 17:58:19 +0530 | [diff] [blame] | 34 | |
| 35 | @classmethod |
| 36 | def setup_clients(cls): |
| 37 | super(ServerDiskConfigTestJSON, cls).setup_clients() |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 38 | cls.client = cls.os.servers_client |
Rohan Kanade | 60b7309 | 2015-02-04 17:58:19 +0530 | [diff] [blame] | 39 | |
| 40 | @classmethod |
| 41 | def resource_setup(cls): |
| 42 | super(ServerDiskConfigTestJSON, cls).resource_setup() |
David Kranz | 0fb1429 | 2015-02-11 15:55:20 -0500 | [diff] [blame] | 43 | server = cls.create_test_server(wait_until='ACTIVE') |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame] | 44 | cls.server_id = server['id'] |
| 45 | |
| 46 | def _update_server_with_disk_config(self, disk_config): |
Ken'ichi Ohmichi | 7680024 | 2015-07-03 05:12:31 +0000 | [diff] [blame] | 47 | server = self.client.show_server(self.server_id) |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame] | 48 | if disk_config != server['OS-DCF:diskConfig']: |
David Kranz | 0fb1429 | 2015-02-11 15:55:20 -0500 | [diff] [blame] | 49 | server = self.client.update_server(self.server_id, |
| 50 | disk_config=disk_config) |
Ken'ichi Ohmichi | 0eb153c | 2015-07-13 02:18:25 +0000 | [diff] [blame] | 51 | waiters.wait_for_server_status(self.client, server['id'], 'ACTIVE') |
Ken'ichi Ohmichi | 7680024 | 2015-07-03 05:12:31 +0000 | [diff] [blame] | 52 | server = self.client.show_server(server['id']) |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame] | 53 | self.assertEqual(disk_config, server['OS-DCF:diskConfig']) |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 54 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 55 | @test.idempotent_id('bef56b09-2e8c-4883-a370-4950812f430e') |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 56 | def test_rebuild_server_with_manual_disk_config(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 57 | # A server should be rebuilt using the manual disk config option |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame] | 58 | self._update_server_with_disk_config(disk_config='AUTO') |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 59 | |
David Kranz | ae99b9a | 2015-02-16 13:37:01 -0500 | [diff] [blame] | 60 | server = self.client.rebuild(self.server_id, |
| 61 | self.image_ref_alt, |
| 62 | disk_config='MANUAL') |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 63 | |
Attila Fazekas | f7f34f9 | 2013-08-01 17:01:44 +0200 | [diff] [blame] | 64 | # Wait for the server to become active |
Ken'ichi Ohmichi | 0eb153c | 2015-07-13 02:18:25 +0000 | [diff] [blame] | 65 | waiters.wait_for_server_status(self.client, server['id'], 'ACTIVE') |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 66 | |
Attila Fazekas | f7f34f9 | 2013-08-01 17:01:44 +0200 | [diff] [blame] | 67 | # Verify the specified attributes are set correctly |
Ken'ichi Ohmichi | 7680024 | 2015-07-03 05:12:31 +0000 | [diff] [blame] | 68 | server = self.client.show_server(server['id']) |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 69 | self.assertEqual('MANUAL', server['OS-DCF:diskConfig']) |
| 70 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 71 | @test.idempotent_id('9c9fae77-4feb-402f-8450-bf1c8b609713') |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 72 | def test_rebuild_server_with_auto_disk_config(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 73 | # A server should be rebuilt using the auto disk config option |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame] | 74 | self._update_server_with_disk_config(disk_config='MANUAL') |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 75 | |
David Kranz | ae99b9a | 2015-02-16 13:37:01 -0500 | [diff] [blame] | 76 | server = self.client.rebuild(self.server_id, |
| 77 | self.image_ref_alt, |
| 78 | disk_config='AUTO') |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 79 | |
Attila Fazekas | f7f34f9 | 2013-08-01 17:01:44 +0200 | [diff] [blame] | 80 | # Wait for the server to become active |
Ken'ichi Ohmichi | 0eb153c | 2015-07-13 02:18:25 +0000 | [diff] [blame] | 81 | waiters.wait_for_server_status(self.client, server['id'], 'ACTIVE') |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 82 | |
Attila Fazekas | f7f34f9 | 2013-08-01 17:01:44 +0200 | [diff] [blame] | 83 | # Verify the specified attributes are set correctly |
Ken'ichi Ohmichi | 7680024 | 2015-07-03 05:12:31 +0000 | [diff] [blame] | 84 | server = self.client.show_server(server['id']) |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 85 | self.assertEqual('AUTO', server['OS-DCF:diskConfig']) |
| 86 | |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame] | 87 | def _get_alternative_flavor(self): |
Ken'ichi Ohmichi | 7680024 | 2015-07-03 05:12:31 +0000 | [diff] [blame] | 88 | server = self.client.show_server(self.server_id) |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame] | 89 | |
Chang Ye Wang | eb4b53e | 2013-12-03 00:49:17 -0600 | [diff] [blame] | 90 | if server['flavor']['id'] == self.flavor_ref: |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame] | 91 | return self.flavor_ref_alt |
| 92 | else: |
| 93 | return self.flavor_ref |
| 94 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 95 | @test.idempotent_id('414e7e93-45b5-44bc-8e03-55159c6bfc97') |
Sean Dague | 86bd842 | 2013-12-20 09:56:44 -0500 | [diff] [blame] | 96 | @testtools.skipUnless(CONF.compute_feature_enabled.resize, |
| 97 | 'Resize not available.') |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 98 | def test_resize_server_from_manual_to_auto(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 99 | # A server should be resized from manual to auto disk config |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame] | 100 | self._update_server_with_disk_config(disk_config='MANUAL') |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 101 | |
Attila Fazekas | f7f34f9 | 2013-08-01 17:01:44 +0200 | [diff] [blame] | 102 | # Resize with auto option |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame] | 103 | flavor_id = self._get_alternative_flavor() |
| 104 | self.client.resize(self.server_id, flavor_id, disk_config='AUTO') |
Ken'ichi Ohmichi | 0eb153c | 2015-07-13 02:18:25 +0000 | [diff] [blame] | 105 | waiters.wait_for_server_status(self.client, self.server_id, |
| 106 | 'VERIFY_RESIZE') |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame] | 107 | self.client.confirm_resize(self.server_id) |
Ken'ichi Ohmichi | 0eb153c | 2015-07-13 02:18:25 +0000 | [diff] [blame] | 108 | waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE') |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 109 | |
Ken'ichi Ohmichi | 7680024 | 2015-07-03 05:12:31 +0000 | [diff] [blame] | 110 | server = self.client.show_server(self.server_id) |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 111 | self.assertEqual('AUTO', server['OS-DCF:diskConfig']) |
| 112 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 113 | @test.idempotent_id('693d16f3-556c-489a-8bac-3d0ca2490bad') |
Sean Dague | 86bd842 | 2013-12-20 09:56:44 -0500 | [diff] [blame] | 114 | @testtools.skipUnless(CONF.compute_feature_enabled.resize, |
| 115 | 'Resize not available.') |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 116 | def test_resize_server_from_auto_to_manual(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 117 | # A server should be resized from auto to manual disk config |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame] | 118 | self._update_server_with_disk_config(disk_config='AUTO') |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 119 | |
Attila Fazekas | f7f34f9 | 2013-08-01 17:01:44 +0200 | [diff] [blame] | 120 | # Resize with manual option |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame] | 121 | flavor_id = self._get_alternative_flavor() |
| 122 | self.client.resize(self.server_id, flavor_id, disk_config='MANUAL') |
Ken'ichi Ohmichi | 0eb153c | 2015-07-13 02:18:25 +0000 | [diff] [blame] | 123 | waiters.wait_for_server_status(self.client, self.server_id, |
| 124 | 'VERIFY_RESIZE') |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame] | 125 | self.client.confirm_resize(self.server_id) |
Ken'ichi Ohmichi | 0eb153c | 2015-07-13 02:18:25 +0000 | [diff] [blame] | 126 | waiters.wait_for_server_status(self.client, self.server_id, 'ACTIVE') |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 127 | |
Ken'ichi Ohmichi | 7680024 | 2015-07-03 05:12:31 +0000 | [diff] [blame] | 128 | server = self.client.show_server(self.server_id) |
Daryl Walleck | e36d500 | 2012-03-28 09:56:10 -0500 | [diff] [blame] | 129 | self.assertEqual('MANUAL', server['OS-DCF:diskConfig']) |
| 130 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 131 | @test.idempotent_id('5ef18867-358d-4de9-b3c9-94d4ba35742f') |
ivan-zhu | 72d7d5b | 2013-10-16 17:30:58 +0800 | [diff] [blame] | 132 | def test_update_server_from_auto_to_manual(self): |
| 133 | # A server should be updated from auto to manual disk config |
Ken'ichi Ohmichi | b1f6483 | 2013-10-29 13:29:54 +0900 | [diff] [blame] | 134 | self._update_server_with_disk_config(disk_config='AUTO') |
ivan-zhu | 72d7d5b | 2013-10-16 17:30:58 +0800 | [diff] [blame] | 135 | |
| 136 | # Update the disk_config attribute to manual |
David Kranz | 0fb1429 | 2015-02-11 15:55:20 -0500 | [diff] [blame] | 137 | server = self.client.update_server(self.server_id, |
| 138 | disk_config='MANUAL') |
Ken'ichi Ohmichi | 0eb153c | 2015-07-13 02:18:25 +0000 | [diff] [blame] | 139 | waiters.wait_for_server_status(self.client, server['id'], 'ACTIVE') |
ivan-zhu | 72d7d5b | 2013-10-16 17:30:58 +0800 | [diff] [blame] | 140 | |
| 141 | # Verify the disk_config attribute is set correctly |
Ken'ichi Ohmichi | 7680024 | 2015-07-03 05:12:31 +0000 | [diff] [blame] | 142 | server = self.client.show_server(server['id']) |
ivan-zhu | 72d7d5b | 2013-10-16 17:30:58 +0800 | [diff] [blame] | 143 | self.assertEqual('MANUAL', server['OS-DCF:diskConfig']) |