From 7ba0d5fc8a30473696efb76436e56e6f9ea9ac8f Mon Sep 17 00:00:00 2001 From: Evgeny Antyshev Date: Tue, 28 Apr 2015 13:18:07 +0000 Subject: [PATCH] Image properties in scenario tests Some images require additional properties. This change adds dictionary option "img_properties" to the "scenario" config section. For example, to work with Parallels Containers, specify vm_mode: img_properties = vm_mode:exe By occasion, we fix handling properties in _image_create in scenario/manager.py: disk_format is an x-image-meta-* option, and kernel_id, ramdisk_id are properties. Change-Id: I2d3714eb899faad67a867a630c1d72d1fd8ee74f --- etc/tempest.conf.sample | 4 ++++ tempest/config.py | 2 ++ tempest/scenario/manager.py | 20 ++++++++++---------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/etc/tempest.conf.sample b/etc/tempest.conf.sample index 3f9e70eb4e..0ed78bafa7 100644 --- a/etc/tempest.conf.sample +++ b/etc/tempest.conf.sample @@ -935,6 +935,10 @@ # Image container format (string value) #img_container_format = bare +# Glance image properties. Use for custom images which require them +# (dict value) +#img_properties = + # AMI image file name (string value) #ami_img_file = cirros-0.3.1-x86_64-blank.img diff --git a/tempest/config.py b/tempest/config.py index 3f3e7e7448..4e6747f19a 100644 --- a/tempest/config.py +++ b/tempest/config.py @@ -943,6 +943,8 @@ ScenarioGroup = [ cfg.StrOpt('img_container_format', default='bare', help='Image container format'), + cfg.DictOpt('img_properties', help='Glance image properties. ' + 'Use for custom images which require them'), cfg.StrOpt('ami_img_file', default='cirros-0.3.1-x86_64-blank.img', help='AMI image file name'), diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py index 7e0c3b3b34..a0e59e363e 100644 --- a/tempest/scenario/manager.py +++ b/tempest/scenario/manager.py @@ -318,7 +318,8 @@ class ScenarioTest(tempest.test.BaseTestCase): return linux_client - def _image_create(self, name, fmt, path, properties=None): + def _image_create(self, name, fmt, path, + disk_format=None, properties=None): if properties is None: properties = {} name = data_utils.rand_name('%s-' % name) @@ -327,10 +328,10 @@ class ScenarioTest(tempest.test.BaseTestCase): params = { 'name': name, 'container_format': fmt, - 'disk_format': fmt, + 'disk_format': disk_format or fmt, 'is_public': 'False', } - params.update(properties) + params['properties'] = properties image = self.image_client.create_image(**params) self.addCleanup(self.image_client.delete_image, image['id']) self.assertEqual("queued", image['status']) @@ -344,23 +345,22 @@ class ScenarioTest(tempest.test.BaseTestCase): ami_img_path = CONF.scenario.img_dir + "/" + CONF.scenario.ami_img_file img_container_format = CONF.scenario.img_container_format img_disk_format = CONF.scenario.img_disk_format + img_properties = CONF.scenario.img_properties LOG.debug("paths: img: %s, container_fomat: %s, disk_format: %s, " - "ami: %s, ari: %s, aki: %s" % + "properties: %s, ami: %s, ari: %s, aki: %s" % (img_path, img_container_format, img_disk_format, - ami_img_path, ari_img_path, aki_img_path)) + img_properties, ami_img_path, ari_img_path, aki_img_path)) try: self.image = self._image_create('scenario-img', img_container_format, img_path, - properties={'disk_format': - img_disk_format}) + disk_format=img_disk_format, + properties=img_properties) except IOError: LOG.debug("A qcow2 image was not found. Try to get a uec image.") kernel = self._image_create('scenario-aki', 'aki', aki_img_path) ramdisk = self._image_create('scenario-ari', 'ari', ari_img_path) - properties = { - 'properties': {'kernel_id': kernel, 'ramdisk_id': ramdisk} - } + properties = {'kernel_id': kernel, 'ramdisk_id': ramdisk} self.image = self._image_create('scenario-ami', 'ami', path=ami_img_path, properties=properties)