add 'boot from ebs' scenario test
test that boots from a snapshot of a volume backed instance
(instance that was booted from bootable volume that was created from image).
Recent changes in nova and cinder broke booting from EBS instance.
For example last change in cinder is here
(that broke booting) - https://review.openstack.org/#/c/182994/
Change-Id: I3915e2f04163568f758bb9e98bd5394af80aa431
Closes-Bug: #1485424
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 27f145b..7bc8ee8 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -18,6 +18,7 @@
import netaddr
from oslo_log import log
+from oslo_serialization import jsonutils as json
import six
from tempest_lib.common.utils import misc as misc_utils
from tempest_lib import exceptions as lib_exc
@@ -411,6 +412,19 @@
cleanup_callable=self.delete_wrapper,
cleanup_args=[_image_client.delete_image, image_id])
snapshot_image = _image_client.get_image_meta(image_id)
+
+ bdm = snapshot_image.get('properties', {}).get('block_device_mapping')
+ if bdm:
+ bdm = json.loads(bdm)
+ if bdm and 'snapshot_id' in bdm[0]:
+ snapshot_id = bdm[0]['snapshot_id']
+ self.addCleanup(
+ self.snapshots_client.wait_for_resource_deletion,
+ snapshot_id)
+ self.addCleanup(
+ self.delete_wrapper, self.snapshots_client.delete_snapshot,
+ snapshot_id)
+
image_name = snapshot_image['name']
self.assertEqual(name, image_name)
LOG.debug("Created snapshot image %s for server %s",
diff --git a/tempest/scenario/test_volume_boot_pattern.py b/tempest/scenario/test_volume_boot_pattern.py
index 3809831..c7ce5f2 100644
--- a/tempest/scenario/test_volume_boot_pattern.py
+++ b/tempest/scenario/test_volume_boot_pattern.py
@@ -48,7 +48,7 @@
vol_name = data_utils.rand_name('volume-origin')
return self.create_volume(name=vol_name, imageRef=img_uuid)
- def _boot_instance_from_volume(self, vol_id, keypair, security_group):
+ def _get_bdm(self, vol_id, delete_on_termination=False):
# NOTE(gfidente): the syntax for block_device_mapping is
# dev_name=id:type:size:delete_on_terminate
# where type needs to be "snap" if the server is booted
@@ -56,12 +56,20 @@
bd_map = [{
'device_name': 'vda',
'volume_id': vol_id,
- 'delete_on_termination': '0'}]
- create_kwargs = {
- 'block_device_mapping': bd_map,
- 'key_name': keypair['name'],
- 'security_groups': [{'name': security_group['name']}]
- }
+ 'delete_on_termination': str(int(delete_on_termination))}]
+ return {'block_device_mapping': bd_map}
+
+ def _boot_instance_from_volume(self, vol_id, keypair=None,
+ security_group=None,
+ delete_on_termination=False):
+ create_kwargs = dict()
+ if keypair:
+ create_kwargs['key_name'] = keypair['name']
+ if security_group:
+ create_kwargs['security_groups'] = [
+ {'name': security_group['name']}]
+ create_kwargs.update(self._get_bdm(
+ vol_id, delete_on_termination=delete_on_termination))
return self.create_server(image='', create_kwargs=create_kwargs)
def _create_snapshot_from_volume(self, vol_id):
@@ -174,18 +182,34 @@
# deletion operations to succeed
self._stop_instances([instance_2nd, instance_from_snapshot])
+ @test.idempotent_id('36c34c67-7b54-4b59-b188-02a2f458a63b')
+ @test.services('compute', 'volume', 'image')
+ def test_create_ebs_image_and_check_boot(self):
+ # create an instance from volume
+ volume_origin = self._create_volume_from_image()
+ instance = self._boot_instance_from_volume(volume_origin['id'],
+ delete_on_termination=True)
+ # create EBS image
+ name = data_utils.rand_name('image')
+ image = self.create_server_snapshot(instance, name=name)
+
+ # delete instance
+ self._delete_server(instance)
+
+ # boot instance from EBS image
+ instance = self.create_server(image=image['id'])
+ # just ensure that instance booted
+
+ # delete instance
+ self._delete_server(instance)
+
class TestVolumeBootPatternV2(TestVolumeBootPattern):
- def _boot_instance_from_volume(self, vol_id, keypair, security_group):
+ def _get_bdm(self, vol_id, delete_on_termination=False):
bd_map_v2 = [{
'uuid': vol_id,
'source_type': 'volume',
'destination_type': 'volume',
'boot_index': 0,
- 'delete_on_termination': False}]
- create_kwargs = {
- 'block_device_mapping_v2': bd_map_v2,
- 'key_name': keypair['name'],
- 'security_groups': [{'name': security_group['name']}]
- }
- return self.create_server(image='', create_kwargs=create_kwargs)
+ 'delete_on_termination': delete_on_termination}]
+ return {'block_device_mapping_v2': bd_map_v2}