From 6c8b05f3cfc3d5da54e08050d3f8fc2496bf37ea Mon Sep 17 00:00:00 2001 From: Martin Kopec Date: Mon, 22 Oct 2018 15:25:35 +0000 Subject: [PATCH] Set use_dynamic_credentials with a priority When an accounts.yaml file is used, python-tempestconf has to set use_dynamic_credentials to False, otherwise the generated tempest.conf doesn't work with Tempest. However, values from a deployer input file are set with a priority, so that they are not overriden during discovery. To fix the issue, use_dynamic_credentials has to be set with priority too. The related unit tests checks only a return value from set function. The patch improves them, so that they check if a value was overriden when it was supposed to and the other way around. Story: 2004140 Task: 27606 Depends-On: https://review.openstack.org/#/c/614312/ Change-Id: I76b8cf694116801e36587929bf320e5743534791 --- config_tempest/main.py | 4 ++-- config_tempest/tests/base.py | 4 ++-- config_tempest/tests/test_tempest_conf.py | 13 +++++++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/config_tempest/main.py b/config_tempest/main.py index 0bb9ece8..80acdf93 100755 --- a/config_tempest/main.py +++ b/config_tempest/main.py @@ -184,7 +184,7 @@ def set_options(conf, deployer_input, non_admin, image_path, overrides=[], conf.set("auth", "admin_username", "") conf.set("auth", "admin_project_name", "") conf.set("auth", "admin_password", "") - conf.set("auth", "use_dynamic_credentials", "False") + conf.set("auth", "use_dynamic_credentials", "False", priority=True) # get and set auth data from client's config if cloud_creds: @@ -192,7 +192,7 @@ def set_options(conf, deployer_input, non_admin, image_path, overrides=[], if accounts_path: # new way for running using accounts file - conf.set("auth", "use_dynamic_credentials", "False") + conf.set("auth", "use_dynamic_credentials", "False", priority=True) conf.set("auth", "test_accounts_file", os.path.abspath(accounts_path)) diff --git a/config_tempest/tests/base.py b/config_tempest/tests/base.py index cfbfd649..6e3da0e3 100644 --- a/config_tempest/tests/base.py +++ b/config_tempest/tests/base.py @@ -62,7 +62,7 @@ class BaseConfigTempestTest(base.BaseTestCase): conf.set("auth", "admin_username", "admin") conf.set("auth", "admin_project_name", "adminProject") conf.set("auth", "admin_password", "adminPass") - conf.set("auth", "use_dynamic_credentials", "False") + conf.set("auth", "use_dynamic_credentials", "False", priority=True) return conf def _get_alt_conf(self, V2, V3): @@ -79,7 +79,7 @@ class BaseConfigTempestTest(base.BaseTestCase): conf.set("auth", "admin_username", "admin") conf.set("auth", "admin_project_name", "adminProject") conf.set("auth", "admin_password", "adminPass") - conf.set("auth", "use_dynamic_credentials", "True") + conf.set("auth", "use_dynamic_credentials", "True", priority=True) return conf def _get_creds(self, conf, admin=False, v2=False): diff --git a/config_tempest/tests/test_tempest_conf.py b/config_tempest/tests/test_tempest_conf.py index 9fc5726c..cd76218b 100644 --- a/config_tempest/tests/test_tempest_conf.py +++ b/config_tempest/tests/test_tempest_conf.py @@ -36,23 +36,28 @@ class TestTempestConf(BaseConfigTempestTest): # set value wihout priority (default: priority=False) resp = self.conf.set("section", "key", "value") # value should be overwritten, because it wasn't set with priority - resp = self.conf.set("section", "key", "value") + resp = self.conf.set("section", "key", "new_value") self.assertTrue(resp) + self.assertEqual(self.conf.get("section", "key"), "new_value") def test_set_value_overwrite_priority(self): resp = self.conf.set("sectionPriority", "key", "value", priority=True) - resp = self.conf.set("sectionPriority", "key", "value") + resp = self.conf.set("sectionPriority", "key", "new_value") self.assertFalse(resp) + self.assertEqual(self.conf.get("sectionPriority", "key"), "value") def test_set_value_overwrite_by_priority(self): resp = self.conf.set("section", "key", "value") - resp = self.conf.set("section", "key", "value", priority=True) + resp = self.conf.set("section", "key", "new_value", priority=True) self.assertTrue(resp) + self.assertEqual(self.conf.get("section", "key"), "new_value") def test_set_value_overwrite_priority_by_priority(self): resp = self.conf.set("sectionPriority", "key", "value", priority=True) - resp = self.conf.set("sectionPriority", "key", "value", priority=True) + resp = self.conf.set("sectionPriority", "key", + "new_value", priority=True) self.assertTrue(resp) + self.assertEqual(self.conf.get("sectionPriority", "key"), "new_value") def test_get_bool_value(self): self.assertTrue(self.conf.get_bool_value("True"))