fujioka yuuichi | 636f8db | 2013-08-09 12:05:24 +0900 | [diff] [blame] | 1 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 2 | # not use this file except in compliance with the License. You may obtain |
| 3 | # a copy of the License at |
| 4 | # |
| 5 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | # |
| 7 | # Unless required by applicable law or agreed to in writing, software |
| 8 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 9 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 10 | # License for the specific language governing permissions and limitations |
| 11 | # under the License. |
| 12 | |
Sean Dague | 52abbd9 | 2016-03-01 09:38:09 -0500 | [diff] [blame] | 13 | from oslo_log import log as logging |
zhulingjie | 92b87a5 | 2019-02-21 01:05:54 +0800 | [diff] [blame] | 14 | from oslo_serialization import jsonutils as json |
zhufl | 6b7040a | 2017-01-18 16:38:34 +0800 | [diff] [blame] | 15 | import testtools |
Sean Dague | 52abbd9 | 2016-03-01 09:38:09 -0500 | [diff] [blame] | 16 | |
Andrea Frittoli | cd36841 | 2017-08-14 21:37:56 +0100 | [diff] [blame] | 17 | from tempest.common import utils |
Ken'ichi Ohmichi | 0eb153c | 2015-07-13 02:18:25 +0000 | [diff] [blame] | 18 | from tempest.common import waiters |
Matthew Treinish | 6c07229 | 2014-01-29 19:15:52 +0000 | [diff] [blame] | 19 | from tempest import config |
Ken'ichi Ohmichi | be4fb50 | 2017-03-10 10:04:48 -0800 | [diff] [blame] | 20 | from tempest.lib.common.utils import data_utils |
Ken'ichi Ohmichi | c85a951 | 2017-01-27 18:34:24 -0800 | [diff] [blame] | 21 | from tempest.lib import decorators |
fujioka yuuichi | 636f8db | 2013-08-09 12:05:24 +0900 | [diff] [blame] | 22 | from tempest.scenario import manager |
| 23 | |
Matthew Treinish | 6c07229 | 2014-01-29 19:15:52 +0000 | [diff] [blame] | 24 | CONF = config.CONF |
Sean Dague | 52abbd9 | 2016-03-01 09:38:09 -0500 | [diff] [blame] | 25 | LOG = logging.getLogger(__name__) |
fujioka yuuichi | 636f8db | 2013-08-09 12:05:24 +0900 | [diff] [blame] | 26 | |
Nachi Ueno | 95b4128 | 2014-01-15 06:54:21 -0800 | [diff] [blame] | 27 | |
lkuchlan | 3023e75 | 2017-06-08 12:53:13 +0300 | [diff] [blame] | 28 | class TestVolumeBootPattern(manager.EncryptionScenarioTest): |
fujioka yuuichi | 636f8db | 2013-08-09 12:05:24 +0900 | [diff] [blame] | 29 | |
Sean Dague | 02620fd | 2016-03-02 15:52:51 -0500 | [diff] [blame] | 30 | # Boot from volume scenario is quite slow, and needs extra |
| 31 | # breathing room to get through deletes in the time allotted. |
| 32 | TIMEOUT_SCALING_FACTOR = 2 |
| 33 | |
fujioka yuuichi | 636f8db | 2013-08-09 12:05:24 +0900 | [diff] [blame] | 34 | def _delete_server(self, server): |
Joseph Lanoux | eef192f | 2014-08-01 14:32:53 +0000 | [diff] [blame] | 35 | self.servers_client.delete_server(server['id']) |
Ken'ichi Ohmichi | e91a0c6 | 2015-08-13 02:09:16 +0000 | [diff] [blame] | 36 | waiters.wait_for_server_termination(self.servers_client, server['id']) |
fujioka yuuichi | 636f8db | 2013-08-09 12:05:24 +0900 | [diff] [blame] | 37 | |
melanie witt | ca30e8c | 2018-08-07 21:39:52 +0000 | [diff] [blame] | 38 | def _delete_snapshot(self, snapshot_id): |
| 39 | self.snapshots_client.delete_snapshot(snapshot_id) |
| 40 | self.snapshots_client.wait_for_resource_deletion(snapshot_id) |
| 41 | |
Ken'ichi Ohmichi | c85a951 | 2017-01-27 18:34:24 -0800 | [diff] [blame] | 42 | @decorators.idempotent_id('557cd2c2-4eb8-4dce-98be-f86765ff311b') |
Matt Riedemann | 4b8a7b8 | 2019-02-14 14:07:11 -0500 | [diff] [blame] | 43 | @decorators.attr(type='slow') |
msidana | e1f990b | 2018-06-05 12:10:24 +0530 | [diff] [blame] | 44 | # Note: This test is being skipped based on 'public_network_id'. |
| 45 | # It is being used in create_floating_ip() method which gets called |
| 46 | # from get_server_ip() method |
zhufl | 6b7040a | 2017-01-18 16:38:34 +0800 | [diff] [blame] | 47 | @testtools.skipUnless(CONF.network.public_network_id, |
| 48 | 'The public_network_id option must be specified.') |
zhufl | 36214c5 | 2018-03-02 15:49:41 +0800 | [diff] [blame] | 49 | @testtools.skipUnless(CONF.volume_feature_enabled.snapshot, |
| 50 | 'Cinder volume snapshots are disabled') |
Andrea Frittoli | cd36841 | 2017-08-14 21:37:56 +0100 | [diff] [blame] | 51 | @utils.services('compute', 'volume', 'image') |
fujioka yuuichi | 636f8db | 2013-08-09 12:05:24 +0900 | [diff] [blame] | 52 | def test_volume_boot_pattern(self): |
lkuchlan | 2041cdd | 2016-08-15 13:50:43 +0300 | [diff] [blame] | 53 | """This test case attempts to reproduce the following steps: |
| 54 | |
| 55 | * Create in Cinder some bootable volume importing a Glance image |
| 56 | * Boot an instance from the bootable volume |
| 57 | * Write content to the volume |
| 58 | * Delete an instance and Boot a new instance from the volume |
| 59 | * Check written content in the instance |
| 60 | * Create a volume snapshot while the instance is running |
| 61 | * Boot an additional instance from the new snapshot based volume |
| 62 | * Check written content in the instance booted from snapshot |
| 63 | """ |
| 64 | |
Sean Dague | 52abbd9 | 2016-03-01 09:38:09 -0500 | [diff] [blame] | 65 | LOG.info("Creating keypair and security group") |
fujioka yuuichi | 636f8db | 2013-08-09 12:05:24 +0900 | [diff] [blame] | 66 | keypair = self.create_keypair() |
Yaroslav Lobankov | 0089af5 | 2015-07-02 19:14:40 +0300 | [diff] [blame] | 67 | security_group = self._create_security_group() |
fujioka yuuichi | 636f8db | 2013-08-09 12:05:24 +0900 | [diff] [blame] | 68 | |
| 69 | # create an instance from volume |
Sean Dague | 52abbd9 | 2016-03-01 09:38:09 -0500 | [diff] [blame] | 70 | LOG.info("Booting instance 1 from volume") |
Rajat Dhasmana | a8bfa17 | 2020-01-14 17:34:44 +0000 | [diff] [blame] | 71 | volume_origin = self.create_volume_from_image() |
| 72 | instance_1st = self.boot_instance_from_resource( |
lkuchlan | 8789c55 | 2017-01-08 11:40:27 +0200 | [diff] [blame] | 73 | source_id=volume_origin['id'], |
| 74 | source_type='volume', |
| 75 | keypair=keypair, |
| 76 | security_group=security_group) |
Jordan Pittier | 525ec71 | 2016-12-07 17:51:26 +0100 | [diff] [blame] | 77 | LOG.info("Booted first instance: %s", instance_1st) |
fujioka yuuichi | 636f8db | 2013-08-09 12:05:24 +0900 | [diff] [blame] | 78 | |
| 79 | # write content to volume on instance |
Jordan Pittier | 525ec71 | 2016-12-07 17:51:26 +0100 | [diff] [blame] | 80 | LOG.info("Setting timestamp in instance %s", instance_1st) |
Sean Dague | 20e9861 | 2016-01-06 14:33:28 -0500 | [diff] [blame] | 81 | ip_instance_1st = self.get_server_ip(instance_1st) |
Alexander Gubanov | 59cc303 | 2015-11-05 11:58:03 +0200 | [diff] [blame] | 82 | timestamp = self.create_timestamp(ip_instance_1st, |
Slawek Kaplonski | 79d8b0f | 2018-07-30 22:43:41 +0200 | [diff] [blame] | 83 | private_key=keypair['private_key'], |
| 84 | server=instance_1st) |
fujioka yuuichi | 636f8db | 2013-08-09 12:05:24 +0900 | [diff] [blame] | 85 | |
| 86 | # delete instance |
Jordan Pittier | 525ec71 | 2016-12-07 17:51:26 +0100 | [diff] [blame] | 87 | LOG.info("Deleting first instance: %s", instance_1st) |
fujioka yuuichi | 636f8db | 2013-08-09 12:05:24 +0900 | [diff] [blame] | 88 | self._delete_server(instance_1st) |
| 89 | |
| 90 | # create a 2nd instance from volume |
Rajat Dhasmana | a8bfa17 | 2020-01-14 17:34:44 +0000 | [diff] [blame] | 91 | instance_2nd = self.boot_instance_from_resource( |
lkuchlan | 8789c55 | 2017-01-08 11:40:27 +0200 | [diff] [blame] | 92 | source_id=volume_origin['id'], |
| 93 | source_type='volume', |
| 94 | keypair=keypair, |
| 95 | security_group=security_group) |
Jordan Pittier | 525ec71 | 2016-12-07 17:51:26 +0100 | [diff] [blame] | 96 | LOG.info("Booted second instance %s", instance_2nd) |
fujioka yuuichi | 636f8db | 2013-08-09 12:05:24 +0900 | [diff] [blame] | 97 | |
| 98 | # check the content of written file |
Jordan Pittier | 525ec71 | 2016-12-07 17:51:26 +0100 | [diff] [blame] | 99 | LOG.info("Getting timestamp in instance %s", instance_2nd) |
Sean Dague | 20e9861 | 2016-01-06 14:33:28 -0500 | [diff] [blame] | 100 | ip_instance_2nd = self.get_server_ip(instance_2nd) |
Alexander Gubanov | 59cc303 | 2015-11-05 11:58:03 +0200 | [diff] [blame] | 101 | timestamp2 = self.get_timestamp(ip_instance_2nd, |
Slawek Kaplonski | 79d8b0f | 2018-07-30 22:43:41 +0200 | [diff] [blame] | 102 | private_key=keypair['private_key'], |
| 103 | server=instance_2nd) |
Alexander Gubanov | 59cc303 | 2015-11-05 11:58:03 +0200 | [diff] [blame] | 104 | self.assertEqual(timestamp, timestamp2) |
fujioka yuuichi | 636f8db | 2013-08-09 12:05:24 +0900 | [diff] [blame] | 105 | |
| 106 | # snapshot a volume |
Jordan Pittier | 525ec71 | 2016-12-07 17:51:26 +0100 | [diff] [blame] | 107 | LOG.info("Creating snapshot from volume: %s", volume_origin['id']) |
lkuchlan | 73ed1f3 | 2017-07-06 16:22:12 +0300 | [diff] [blame] | 108 | snapshot = self.create_volume_snapshot(volume_origin['id'], force=True) |
fujioka yuuichi | 636f8db | 2013-08-09 12:05:24 +0900 | [diff] [blame] | 109 | |
| 110 | # create a 3rd instance from snapshot |
Jordan Pittier | 525ec71 | 2016-12-07 17:51:26 +0100 | [diff] [blame] | 111 | LOG.info("Creating third instance from snapshot: %s", snapshot['id']) |
Nuno Santos | da89962 | 2016-11-17 12:32:53 -0500 | [diff] [blame] | 112 | volume = self.create_volume(snapshot_id=snapshot['id'], |
| 113 | size=snapshot['size']) |
| 114 | LOG.info("Booting third instance from snapshot") |
Alexander Gubanov | c8829f8 | 2015-11-12 10:35:13 +0200 | [diff] [blame] | 115 | server_from_snapshot = ( |
Rajat Dhasmana | a8bfa17 | 2020-01-14 17:34:44 +0000 | [diff] [blame] | 116 | self.boot_instance_from_resource(source_id=volume['id'], |
| 117 | source_type='volume', |
| 118 | keypair=keypair, |
| 119 | security_group=security_group)) |
Nuno Santos | da89962 | 2016-11-17 12:32:53 -0500 | [diff] [blame] | 120 | LOG.info("Booted third instance %s", server_from_snapshot) |
fujioka yuuichi | 636f8db | 2013-08-09 12:05:24 +0900 | [diff] [blame] | 121 | |
| 122 | # check the content of written file |
Jordan Pittier | 525ec71 | 2016-12-07 17:51:26 +0100 | [diff] [blame] | 123 | LOG.info("Logging into third instance to get timestamp: %s", |
Sean Dague | 52abbd9 | 2016-03-01 09:38:09 -0500 | [diff] [blame] | 124 | server_from_snapshot) |
Sean Dague | 20e9861 | 2016-01-06 14:33:28 -0500 | [diff] [blame] | 125 | server_from_snapshot_ip = self.get_server_ip(server_from_snapshot) |
Alexander Gubanov | c8829f8 | 2015-11-12 10:35:13 +0200 | [diff] [blame] | 126 | timestamp3 = self.get_timestamp(server_from_snapshot_ip, |
Slawek Kaplonski | 79d8b0f | 2018-07-30 22:43:41 +0200 | [diff] [blame] | 127 | private_key=keypair['private_key'], |
| 128 | server=server_from_snapshot) |
Alexander Gubanov | 59cc303 | 2015-11-05 11:58:03 +0200 | [diff] [blame] | 129 | self.assertEqual(timestamp, timestamp3) |
fujioka yuuichi | 636f8db | 2013-08-09 12:05:24 +0900 | [diff] [blame] | 130 | |
Ken'ichi Ohmichi | c85a951 | 2017-01-27 18:34:24 -0800 | [diff] [blame] | 131 | @decorators.idempotent_id('05795fb2-b2a7-4c9f-8fac-ff25aedb1489') |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 132 | @decorators.attr(type='slow') |
zhufl | 36214c5 | 2018-03-02 15:49:41 +0800 | [diff] [blame] | 133 | @testtools.skipUnless(CONF.volume_feature_enabled.snapshot, |
| 134 | 'Cinder volume snapshots are disabled') |
Andrea Frittoli | cd36841 | 2017-08-14 21:37:56 +0100 | [diff] [blame] | 135 | @utils.services('compute', 'image', 'volume') |
lkuchlan | 8789c55 | 2017-01-08 11:40:27 +0200 | [diff] [blame] | 136 | def test_create_server_from_volume_snapshot(self): |
| 137 | # Create a volume from an image |
Rajat Dhasmana | a8bfa17 | 2020-01-14 17:34:44 +0000 | [diff] [blame] | 138 | boot_volume = self.create_volume_from_image() |
lkuchlan | 8789c55 | 2017-01-08 11:40:27 +0200 | [diff] [blame] | 139 | |
| 140 | # Create a snapshot |
lkuchlan | 73ed1f3 | 2017-07-06 16:22:12 +0300 | [diff] [blame] | 141 | boot_snapshot = self.create_volume_snapshot(boot_volume['id']) |
lkuchlan | 8789c55 | 2017-01-08 11:40:27 +0200 | [diff] [blame] | 142 | |
| 143 | # Create a server from a volume snapshot |
Rajat Dhasmana | a8bfa17 | 2020-01-14 17:34:44 +0000 | [diff] [blame] | 144 | server = self.boot_instance_from_resource( |
lkuchlan | 8789c55 | 2017-01-08 11:40:27 +0200 | [diff] [blame] | 145 | source_id=boot_snapshot['id'], |
| 146 | source_type='snapshot', |
| 147 | delete_on_termination=True) |
| 148 | |
| 149 | server_info = self.servers_client.show_server(server['id'])['server'] |
| 150 | |
| 151 | # The created volume when creating a server from a snapshot |
| 152 | created_volume = server_info['os-extended-volumes:volumes_attached'] |
| 153 | |
lkuchlan | 9e22b85 | 2017-02-05 15:38:29 +0200 | [diff] [blame] | 154 | self.assertNotEmpty(created_volume, "No volume attachment found.") |
| 155 | |
lkuchlan | 8789c55 | 2017-01-08 11:40:27 +0200 | [diff] [blame] | 156 | created_volume_info = self.volumes_client.show_volume( |
| 157 | created_volume[0]['id'])['volume'] |
| 158 | |
| 159 | # Verify the server was created from the snapshot |
| 160 | self.assertEqual( |
| 161 | boot_volume['volume_image_metadata']['image_id'], |
| 162 | created_volume_info['volume_image_metadata']['image_id']) |
| 163 | self.assertEqual(boot_snapshot['id'], |
| 164 | created_volume_info['snapshot_id']) |
| 165 | self.assertEqual(server['id'], |
| 166 | created_volume_info['attachments'][0]['server_id']) |
| 167 | self.assertEqual(created_volume[0]['id'], |
| 168 | created_volume_info['attachments'][0]['volume_id']) |
| 169 | |
Giulio Fidente | 0d2b331 | 2020-03-04 10:15:03 +0100 | [diff] [blame] | 170 | # Delete the server and wait |
| 171 | self._delete_server(server) |
| 172 | |
| 173 | # Assert that the underlying volume is gone before class tearDown |
| 174 | # to prevent snapshot deletion from failing |
| 175 | self.volumes_client.wait_for_resource_deletion(created_volume[0]['id']) |
| 176 | |
Ken'ichi Ohmichi | c85a951 | 2017-01-27 18:34:24 -0800 | [diff] [blame] | 177 | @decorators.idempotent_id('36c34c67-7b54-4b59-b188-02a2f458a63b') |
zhufl | 36214c5 | 2018-03-02 15:49:41 +0800 | [diff] [blame] | 178 | @testtools.skipUnless(CONF.volume_feature_enabled.snapshot, |
| 179 | 'Cinder volume snapshots are disabled') |
Andrea Frittoli | cd36841 | 2017-08-14 21:37:56 +0100 | [diff] [blame] | 180 | @utils.services('compute', 'volume', 'image') |
Matt Riedemann | 2db6c27 | 2018-03-22 18:57:19 -0400 | [diff] [blame] | 181 | def test_image_defined_boot_from_volume(self): |
| 182 | # create an instance from image-backed volume |
Rajat Dhasmana | a8bfa17 | 2020-01-14 17:34:44 +0000 | [diff] [blame] | 183 | volume_origin = self.create_volume_from_image() |
melanie witt | ca30e8c | 2018-08-07 21:39:52 +0000 | [diff] [blame] | 184 | name = data_utils.rand_name(self.__class__.__name__ + |
| 185 | '-volume-backed-server') |
Rajat Dhasmana | a8bfa17 | 2020-01-14 17:34:44 +0000 | [diff] [blame] | 186 | instance1 = self.boot_instance_from_resource( |
lkuchlan | 8789c55 | 2017-01-08 11:40:27 +0200 | [diff] [blame] | 187 | source_id=volume_origin['id'], |
| 188 | source_type='volume', |
melanie witt | ca30e8c | 2018-08-07 21:39:52 +0000 | [diff] [blame] | 189 | delete_on_termination=True, |
| 190 | name=name) |
Matt Riedemann | 2db6c27 | 2018-03-22 18:57:19 -0400 | [diff] [blame] | 191 | # Create a snapshot image from the volume-backed server. |
| 192 | # The compute service will have the block service create a snapshot of |
| 193 | # the root volume and store its metadata in the image. |
melanie witt | ca30e8c | 2018-08-07 21:39:52 +0000 | [diff] [blame] | 194 | image = self.create_server_snapshot(instance1) |
Andrey Pavlov | c8bd4b1 | 2015-08-17 10:20:17 +0300 | [diff] [blame] | 195 | |
Matt Riedemann | 2db6c27 | 2018-03-22 18:57:19 -0400 | [diff] [blame] | 196 | # Create a server from the image snapshot which has an |
| 197 | # "image-defined block device mapping (BDM)" in it, i.e. the metadata |
| 198 | # about the volume snapshot. The compute service will use this to |
| 199 | # create a volume from the volume snapshot and use that as the root |
| 200 | # disk for the server. |
melanie witt | ca30e8c | 2018-08-07 21:39:52 +0000 | [diff] [blame] | 201 | name = data_utils.rand_name(self.__class__.__name__ + |
| 202 | '-image-snapshot-server') |
| 203 | instance2 = self.create_server(image_id=image['id'], name=name) |
lianghao | 2e0ee04 | 2017-10-26 19:38:28 +0800 | [diff] [blame] | 204 | |
Matt Riedemann | 2db6c27 | 2018-03-22 18:57:19 -0400 | [diff] [blame] | 205 | # Verify the server was created from the image-defined BDM. |
melanie witt | ca30e8c | 2018-08-07 21:39:52 +0000 | [diff] [blame] | 206 | volume_attachments = instance2['os-extended-volumes:volumes_attached'] |
Matt Riedemann | 2db6c27 | 2018-03-22 18:57:19 -0400 | [diff] [blame] | 207 | self.assertEqual(1, len(volume_attachments), |
| 208 | "No volume attachment found.") |
| 209 | created_volume = self.volumes_client.show_volume( |
| 210 | volume_attachments[0]['id'])['volume'] |
| 211 | # Assert that the volume service also shows the server attachment. |
| 212 | self.assertEqual(1, len(created_volume['attachments']), |
| 213 | "No server attachment found for volume: %s" % |
| 214 | created_volume) |
melanie witt | ca30e8c | 2018-08-07 21:39:52 +0000 | [diff] [blame] | 215 | self.assertEqual(instance2['id'], |
Matt Riedemann | 2db6c27 | 2018-03-22 18:57:19 -0400 | [diff] [blame] | 216 | created_volume['attachments'][0]['server_id']) |
| 217 | self.assertEqual(volume_attachments[0]['id'], |
| 218 | created_volume['attachments'][0]['volume_id']) |
lianghao | 2e0ee04 | 2017-10-26 19:38:28 +0800 | [diff] [blame] | 219 | self.assertEqual( |
| 220 | volume_origin['volume_image_metadata']['image_id'], |
Matt Riedemann | 2db6c27 | 2018-03-22 18:57:19 -0400 | [diff] [blame] | 221 | created_volume['volume_image_metadata']['image_id']) |
Andrey Pavlov | c8bd4b1 | 2015-08-17 10:20:17 +0300 | [diff] [blame] | 222 | |
Matt Riedemann | 2db6c27 | 2018-03-22 18:57:19 -0400 | [diff] [blame] | 223 | # Delete the second server which should also delete the second volume |
| 224 | # created from the volume snapshot. |
melanie witt | ca30e8c | 2018-08-07 21:39:52 +0000 | [diff] [blame] | 225 | self._delete_server(instance2) |
lkuchlan | 3023e75 | 2017-06-08 12:53:13 +0300 | [diff] [blame] | 226 | |
melanie witt | c50cc24 | 2018-05-01 22:00:39 +0000 | [diff] [blame] | 227 | # Assert that the underlying volume is gone. |
| 228 | self.volumes_client.wait_for_resource_deletion(created_volume['id']) |
| 229 | |
melanie witt | ca30e8c | 2018-08-07 21:39:52 +0000 | [diff] [blame] | 230 | # Delete the volume snapshot. We must do this before deleting the first |
| 231 | # server created in this test because the snapshot depends on the first |
| 232 | # instance's underlying volume (volume_origin). |
| 233 | # In glance v2, the image properties are flattened and in glance v1, |
| 234 | # the image properties are under the 'properties' key. |
| 235 | bdms = image.get('block_device_mapping') |
| 236 | if not bdms: |
| 237 | bdms = image['properties']['block_device_mapping'] |
zhulingjie | 92b87a5 | 2019-02-21 01:05:54 +0800 | [diff] [blame] | 238 | bdms = json.loads(bdms) |
melanie witt | ca30e8c | 2018-08-07 21:39:52 +0000 | [diff] [blame] | 239 | snapshot_id = bdms[0]['snapshot_id'] |
| 240 | self._delete_snapshot(snapshot_id) |
| 241 | |
| 242 | # Now, delete the first server which will also delete the first |
| 243 | # image-backed volume. |
| 244 | self._delete_server(instance1) |
| 245 | |
| 246 | # Assert that the underlying volume is gone. |
| 247 | self.volumes_client.wait_for_resource_deletion(volume_origin['id']) |
| 248 | |
lkuchlan | 3023e75 | 2017-06-08 12:53:13 +0300 | [diff] [blame] | 249 | @decorators.idempotent_id('cb78919a-e553-4bab-b73b-10cf4d2eb125') |
Attila Fazekas | 1c39a2f | 2017-07-18 19:39:06 +0200 | [diff] [blame] | 250 | @testtools.skipUnless(CONF.compute_feature_enabled.attach_encrypted_volume, |
| 251 | 'Encrypted volume attach is not supported') |
Andrea Frittoli | cd36841 | 2017-08-14 21:37:56 +0100 | [diff] [blame] | 252 | @utils.services('compute', 'volume') |
lkuchlan | 3023e75 | 2017-06-08 12:53:13 +0300 | [diff] [blame] | 253 | def test_boot_server_from_encrypted_volume_luks(self): |
| 254 | # Create an encrypted volume |
| 255 | volume = self.create_encrypted_volume('nova.volume.encryptors.' |
| 256 | 'luks.LuksEncryptor', |
| 257 | volume_type='luks') |
| 258 | |
| 259 | self.volumes_client.set_bootable_volume(volume['id'], bootable=True) |
| 260 | |
| 261 | # Boot a server from the encrypted volume |
Rajat Dhasmana | a8bfa17 | 2020-01-14 17:34:44 +0000 | [diff] [blame] | 262 | server = self.boot_instance_from_resource( |
lkuchlan | 3023e75 | 2017-06-08 12:53:13 +0300 | [diff] [blame] | 263 | source_id=volume['id'], |
| 264 | source_type='volume', |
| 265 | delete_on_termination=False) |
| 266 | |
| 267 | server_info = self.servers_client.show_server(server['id'])['server'] |
| 268 | created_volume = server_info['os-extended-volumes:volumes_attached'] |
| 269 | self.assertEqual(volume['id'], created_volume[0]['id']) |