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