Merge "Remove deprecated scenario image option"

This commit is contained in:
Zuul 2021-02-15 21:42:13 +00:00 committed by Gerrit Code Review
commit 3e690f744e
6 changed files with 25 additions and 15 deletions

View File

@ -25,6 +25,7 @@ DEPLOYER_INPUT = os.path.join(os.path.expanduser("~"),
"tempest-deployer-input.conf")
DEFAULT_IMAGE = ("https://download.cirros-cloud.net/0.4.0/"
"cirros-0.4.0-x86_64-disk.img")
DEFAULT_IMAGE_DIR = 'etc'
DEFAULT_IMAGE_FORMAT = 'qcow2'
DEFAULT_FLAVOR_RAM = 128

View File

@ -89,9 +89,6 @@ def load_basic_defaults(conf):
("alt_password", "secrete"),
("alt_project_name", "alt_demo")
],
"scenario": [
("img_dir", "etc")
],
"auth": [
("tempest_roles", "_member_"),
("admin_username", "admin"),

View File

@ -86,7 +86,16 @@ class ImageService(VersionedService):
:type conf: TempestConf object
"""
img_dir = os.path.join(conf.get("scenario", "img_dir"))
# the absolute path is necessary for supporting older tempest versions,
# which had CONF.scenario.img_dir option, see this line of code:
# https://github.com/openstack/tempest/blob/a0ee8b4ccfc512a09
# e1ddb135950b767110aae9b/tempest/scenario/manager.py#L534
# If the path is not an absolute one, the concatenation of strings ^^
# will result in an invalid path
# Moreover the absolute path is needed so that users can move the
# generated tempest.conf outside of python-tempestconf destination,
# otherwise tempest would fail accessing the CONF.scenario.img_file
img_dir = os.path.abspath(os.path.join(C.DEFAULT_IMAGE_DIR))
image_path = conf.get_defaulted('image', 'image_path')
img_path = os.path.join(img_dir,
os.path.basename(image_path))
@ -112,8 +121,7 @@ class ImageService(VersionedService):
image_source=image_path,
image_dest=img_path)
# get name of the image_id
image_id_name = self._find_image(image_id, '')['name']
conf.set('scenario', 'img_file', image_id_name)
conf.set('scenario', 'img_file', img_path)
conf.set('compute', 'image_ref', image_id)
conf.set('compute', 'image_ref_alt', alt_image_id)

View File

@ -17,6 +17,7 @@ from unittest import mock
from fixtures import MonkeyPatch
from config_tempest import constants as C
from config_tempest.services.image import ImageService
from config_tempest.tempest_conf import TempestConf
from config_tempest.tests.base import BaseServiceTest
@ -43,9 +44,8 @@ class TestImageService(BaseServiceTest):
self.Service.convert = False
self.Service.client = self.FakeServiceClient()
self.dir = "/img/"
C.DEFAULT_IMAGE_DIR = "/img/"
self.conf = TempestConf()
self.conf.set("scenario", "img_dir", self.dir)
self.conf.set("image", "image_path", "my_image.qcow2")
self.conf.set("image", "http_image", "http_image.qcow2")
@ -62,7 +62,7 @@ class TestImageService(BaseServiceTest):
self.assertEqual(self.conf.get('compute', 'image_ref'), 'id_c')
self.assertEqual(self.conf.get('compute', 'image_ref_alt'), 'id_d')
self.assertEqual(self.conf.get('scenario', 'img_file'),
'my_image.qcow2')
'/img/my_image.qcow2')
@mock.patch('config_tempest.services.image.ImageService._find_image')
@mock.patch('config_tempest.services.image.ImageService._download_file')

View File

@ -16,16 +16,12 @@ Here is the list of tempest options, which are set by default:
log_file = tempest.log
[identity]
username = demo
username = demo_tempestconf
password = secrete
project_name = demo
alt_username = alt_demo
alt_username = alt_demo_tempestconf
alt_password = secrete
alt_project_name = alt_demo
disable_ssl_certificate_validation = true
[scenario]
img_dir = etc
[auth]
; if _member_ role is not present in the system, python-tempestconf

View File

@ -0,0 +1,8 @@
---
upgrade:
- |
python-tempestconf follows tempest's deprecation of
``CONF.scenario.img_dir`` option and removes that option from the
automatic tempest.conf generation.
python-tempestconf will set an absolute path to the image in
``CONF.scenario.img_file`` option from now on.