Browse Source

Remove deprecated scenario image option

Deprecated scenario image options are being removed from tempest,
see [1]. The tempest change makes img_dir obsolete
therefore CONF.scenario.img_file needs to contain the full path to
the image now.
CONF.scenario.img_dir will be removed entirely from tempest in the
near future by [2].

[1] https://review.opendev.org/c/openstack/tempest/+/710996
[2] https://review.opendev.org/c/openstack/tempest/+/754927

Change-Id: Icf7ac92807873d0a5cd8ccaf75033003adb21c0a
changes/93/720093/7
Martin Kopec 2 years ago
parent
commit
d355f91a6a
  1. 1
      config_tempest/constants.py
  2. 3
      config_tempest/main.py
  3. 14
      config_tempest/services/image.py
  4. 6
      config_tempest/tests/services/test_image.py
  5. 8
      doc/source/user/default.rst
  6. 8
      releasenotes/notes/Remove-setting-of-scenario.img_dir-option-6d1792a9ab7928de.yaml

1
config_tempest/constants.py

@ -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

3
config_tempest/main.py

@ -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"),

14
config_tempest/services/image.py

@ -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)

6
config_tempest/tests/services/test_image.py

@ -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')

8
doc/source/user/default.rst

@ -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

8
releasenotes/notes/Remove-setting-of-scenario.img_dir-option-6d1792a9ab7928de.yaml

@ -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.
Loading…
Cancel
Save