From e1ad05c781fdabd013d81277b459caf6db1a4279 Mon Sep 17 00:00:00 2001 From: Xing Zhang Date: Tue, 12 May 2020 15:50:39 +0800 Subject: [PATCH] Make config parser case sensitivity in configure-verifier Options in config file should be case sensitive, some projects like octavia-tempest-plugin can't set some value as expected: [load_balancer] RBAC_test_type = owner_or_admin Use `conf.optionxform = str` to prevent case transformation[1]. [1] https://docs.python.org/3/library/configparser.html Change-Id: I34d85b835aaa7a3737577b75ec9e6f2b02f90ead Closes-Bug: #1877930 --- CHANGELOG.rst | 11 +++++++++++ rally/cli/commands/verify.py | 1 + rally/verification/utils.py | 2 ++ tests/unit/verification/test_utils.py | 7 +++++-- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2df7339e6b..fef6764214 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -17,6 +17,17 @@ Changelog .. Release notes for existing releases are MUTABLE! If there is something that was missed or can be improved, feel free to change it! +[unreleased] +------------ + +Fixed +~~~~~ + +* [verification component] Make config parser case sensitivity in + configure-verifier + + `Launchpad-bug #1877930 `_ + [3.1.0] - 2020-05-08 -------------------- diff --git a/rally/cli/commands/verify.py b/rally/cli/commands/verify.py index 923b537eec..7ee27e200d 100644 --- a/rally/cli/commands/verify.py +++ b/rally/cli/commands/verify.py @@ -333,6 +333,7 @@ class VerifyCommands(object): if extra_options: if os.path.isfile(extra_options): conf = configparser.ConfigParser() + conf.optionxform = str conf.read(extra_options) extra_options = dict(conf._sections) for s in extra_options: diff --git a/rally/verification/utils.py b/rally/verification/utils.py index 2ca452462c..ae75c238e3 100644 --- a/rally/verification/utils.py +++ b/rally/verification/utils.py @@ -73,6 +73,7 @@ def create_dir(dir_path): def extend_configfile(extra_options, conf_path): conf_object = configparser.ConfigParser() + conf_object.optionxform = str conf_object.read(conf_path) conf_object = add_extra_options(extra_options, conf_object) @@ -86,6 +87,7 @@ def extend_configfile(extra_options, conf_path): def add_extra_options(extra_options, conf_object): + conf_object.optionxform = str for section in extra_options: if section not in (conf_object.sections() + ["DEFAULT"]): conf_object.add_section(section) diff --git a/tests/unit/verification/test_utils.py b/tests/unit/verification/test_utils.py index 1b10edda1d..ef1773c82a 100644 --- a/tests/unit/verification/test_utils.py +++ b/tests/unit/verification/test_utils.py @@ -80,11 +80,14 @@ class UtilsTestCase(test.TestCase): def test_add_extra_options(self): conf = configparser.ConfigParser() extra_options = {"section": {"foo": "bar"}, - "section2": {"option": "value"}} + "section2": {"option": "value"}, + "section3": {"CamelCaseOption": "CamelCaseValue"}} conf = utils.add_extra_options(extra_options, conf) - expected = {"section": ("foo", "bar"), "section2": ("option", "value")} + expected = {"section": ("foo", "bar"), + "section2": ("option", "value"), + "section3": ("CamelCaseOption", "CamelCaseValue")} for section, option in expected.items(): result = conf.items(section) self.assertIn(option, result)