From 067d07b6845bfde0cefeea2cc031858b3079f0ca Mon Sep 17 00:00:00 2001 From: Yaroslav Lobankov Date: Wed, 18 Jan 2017 20:36:52 +0400 Subject: [PATCH] [Verify] The latest cleanup before new release 1. Small bugs were fixed. 2. Missing doc strings were added. 3. Now verifier cannot have 'configuring' and 'configured' statuses. It was done to support work with a few deployments. Change-Id: I064e863f7597c015e8a8f7c64a4d3049d6baac95 --- etc/rally.bash_completion | 10 +++++----- rally/consts.py | 2 -- .../openstack/verification/tempest/manager.py | 13 +++++++++++-- .../openstack/verification/tempest/test_manager.py | 5 +++++ 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/etc/rally.bash_completion b/etc/rally.bash_completion index 73bb6223..97e1e225 100644 --- a/etc/rally.bash_completion +++ b/etc/rally.bash_completion @@ -43,13 +43,13 @@ _rally() OPTS["task_use"]="--uuid" OPTS["task_validate"]="--deployment --task --task-args --task-args-file" OPTS["verify_add-verifier-ext"]="--id --source --version --extra-settings" - OPTS["verify_configure-verifier"]="--verifier-id --deployment-id --reconfigure --force --extend --override --show" + OPTS["verify_configure-verifier"]="--id --deployment-id --reconfigure --extend --override --show" OPTS["verify_create-verifier"]="--name --type --namespace --source --version --system-wide --extra-settings --no-use" OPTS["verify_delete"]="--uuid" - OPTS["verify_delete-verifier"]="--verifier-id --deployment-id --force" + OPTS["verify_delete-verifier"]="--id --deployment-id --force" OPTS["verify_delete-verifier-ext"]="--id --name" - OPTS["verify_import"]="--verifier-id --deployment-id --file --run-args --no-use" - OPTS["verify_list"]="--verifier-id --deployment-id --status" + OPTS["verify_import"]="--id --deployment-id --file --run-args --no-use" + OPTS["verify_list"]="--id --deployment-id --status" OPTS["verify_list-plugins"]="--namespace" OPTS["verify_list-verifier-exts"]="--id" OPTS["verify_list-verifier-tests"]="--id --pattern" @@ -57,7 +57,7 @@ _rally() OPTS["verify_report"]="--uuid --type --to --open" OPTS["verify_rerun"]="--uuid --deployment-id --failed" OPTS["verify_show"]="--uuid --sort-by --detailed" - OPTS["verify_start"]="--verifier-id --deployment-id --pattern --concurrency --load-list --skip-list --xfail-list --no-use" + OPTS["verify_start"]="--id --deployment-id --pattern --concurrency --load-list --skip-list --xfail-list --no-use" OPTS["verify_update-verifier"]="--id --update-venv --version --system-wide --no-system-wide" OPTS["verify_use"]="--uuid" OPTS["verify_use-verifier"]="--id" diff --git a/rally/consts.py b/rally/consts.py index 494fc9a9..53e7f378 100644 --- a/rally/consts.py +++ b/rally/consts.py @@ -198,8 +198,6 @@ class _VerifierStatus(utils.ImmutableMixin, utils.EnumMixin): INSTALLED = "installed" UPDATING = "updating" EXTENDING = "extending" - CONFIGURING = "configuring" - CONFIGURED = "configured" FAILED = "failed" diff --git a/rally/plugins/openstack/verification/tempest/manager.py b/rally/plugins/openstack/verification/tempest/manager.py index f56e4e27..ec26e314 100644 --- a/rally/plugins/openstack/verification/tempest/manager.py +++ b/rally/plugins/openstack/verification/tempest/manager.py @@ -53,22 +53,31 @@ class TempestManager(testr.TestrLauncher): return os.path.join(self.home_dir, "tempest.conf") def get_configuration(self): + """Get Tempest configuration.""" return config.read_configfile(self.configfile) def configure(self, extra_options=None): + """Configure Tempest.""" if not os.path.isdir(self.home_dir): os.makedirs(self.home_dir) cm = config.TempestConfigfileManager(self.verifier.deployment) raw_configfile = cm.create(self.configfile, extra_options) + return raw_configfile + def is_configured(self): + """Check whether Tempest is configured or not.""" + return os.path.exists(self.configfile) + def extend_configuration(self, extra_options): + """Extend Tempest configuration with extra options.""" return config.extend_configfile(self.configfile, extra_options) - def override_configuration(self, new_content): + def override_configuration(self, new_configuration): + """Override Tempest configuration by new configuration.""" with open(self.configfile, "w") as f: - f.write(new_content) + f.write(new_configuration) def install_extension(self, source, version=None, extra_settings=None): """Install a Tempest plugin.""" diff --git a/tests/unit/plugins/openstack/verification/tempest/test_manager.py b/tests/unit/plugins/openstack/verification/tempest/test_manager.py index 3290dfff..09106af1 100644 --- a/tests/unit/plugins/openstack/verification/tempest/test_manager.py +++ b/tests/unit/plugins/openstack/verification/tempest/test_manager.py @@ -62,6 +62,11 @@ class TempestManagerTestCase(test.TestCase): tempest.verifier.deployment) cm.create.assert_called_once_with(tempest.configfile, extra_options) + @mock.patch("%s.config.os.path.exists" % PATH) + def test_is_configured(self, mock_exists): + tempest = manager.TempestManager(mock.MagicMock(uuid="uuuiiiddd")) + self.assertTrue(tempest.is_configured()) + @mock.patch("%s.config.extend_configfile" % PATH) def test_extend_configuration(self, mock_extend_configfile): tempest = manager.TempestManager(mock.MagicMock(uuid="uuuiiiddd"))