From d355f91a6a12ff5d74a13172274f302edbe9ab11 Mon Sep 17 00:00:00 2001 From: Martin Kopec Date: Wed, 25 Mar 2020 14:26:53 +0000 Subject: [PATCH] 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 --- config_tempest/constants.py | 1 + config_tempest/main.py | 3 --- config_tempest/services/image.py | 14 +++++++++++--- config_tempest/tests/services/test_image.py | 6 +++--- doc/source/user/default.rst | 8 ++------ ...f-scenario.img_dir-option-6d1792a9ab7928de.yaml | 8 ++++++++ 6 files changed, 25 insertions(+), 15 deletions(-) create mode 100644 releasenotes/notes/Remove-setting-of-scenario.img_dir-option-6d1792a9ab7928de.yaml diff --git a/config_tempest/constants.py b/config_tempest/constants.py index c6df515e..38a8203e 100644 --- a/config_tempest/constants.py +++ b/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 diff --git a/config_tempest/main.py b/config_tempest/main.py index 2f2ea09a..eb636bc6 100755 --- a/config_tempest/main.py +++ b/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"), diff --git a/config_tempest/services/image.py b/config_tempest/services/image.py index 020ecf42..72a1e09c 100644 --- a/config_tempest/services/image.py +++ b/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) diff --git a/config_tempest/tests/services/test_image.py b/config_tempest/tests/services/test_image.py index 6ebf9837..e1f64683 100644 --- a/config_tempest/tests/services/test_image.py +++ b/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') diff --git a/doc/source/user/default.rst b/doc/source/user/default.rst index 42bb7669..6f4c702e 100644 --- a/doc/source/user/default.rst +++ b/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 diff --git a/releasenotes/notes/Remove-setting-of-scenario.img_dir-option-6d1792a9ab7928de.yaml b/releasenotes/notes/Remove-setting-of-scenario.img_dir-option-6d1792a9ab7928de.yaml new file mode 100644 index 00000000..f28eeb60 --- /dev/null +++ b/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.