From 835aaa767da5652fbc36029c4aca6ebbf5ecc4d6 Mon Sep 17 00:00:00 2001 From: Prabhjyot Singh Sodhi Date: Fri, 2 Jan 2015 01:03:29 -0800 Subject: [PATCH] Refactoring structure of rally/verification Removing the verifiers directory to make the code more readable and reduce unnecessary complexity Change-Id: I2f1c4b7fe3ce9372b6d422c1d3c00e8128f59865 --- rally/api.py | 2 +- rally/benchmark/context/tempest.py | 4 ++-- rally/benchmark/validation.py | 2 +- rally/cmd/commands/verify.py | 4 ++-- rally/cmd/manage.py | 2 +- .../{verifiers => tempest}/__init__.py | 0 .../{verifiers => }/tempest/compare2html.py | 0 .../{verifiers => }/tempest/config.ini | 0 .../{verifiers => }/tempest/config.py | 0 .../{verifiers => }/tempest/diff.py | 2 +- .../{verifiers => }/tempest/json2html.py | 2 +- .../tempest/report_templates/compare.mako | 0 .../{verifiers => }/tempest/subunit2json.py | 0 .../{verifiers => }/tempest/tempest.py | 4 ++-- .../verifiers/tempest/__init__.py | 0 tests/unit/benchmark/context/test_tempest.py | 6 +++--- .../scenarios/tempest/test_tempest.py | 4 ++-- tests/unit/benchmark/test_validation.py | 2 +- tests/unit/cmd/commands/test_verify.py | 4 ++-- tests/unit/cmd/test_manage.py | 2 +- tests/unit/objects/test_verification.py | 2 +- tests/unit/test_api.py | 4 ++-- .../verification/{verifiers => }/fake_log.xml | 0 .../verification/{verifiers => }/fakes.py | 0 .../{verifiers => }/test_compare2html.py | 2 +- .../{verifiers => }/test_config.py | 20 +++++++++---------- .../verification/{verifiers => }/test_diff.py | 2 +- .../{verifiers => }/test_json2html.py | 4 ++-- .../{verifiers => }/test_tempest.py | 6 +++--- tests/unit/verification/verifiers/__init__.py | 0 30 files changed, 40 insertions(+), 40 deletions(-) rename rally/verification/{verifiers => tempest}/__init__.py (100%) rename rally/verification/{verifiers => }/tempest/compare2html.py (100%) rename rally/verification/{verifiers => }/tempest/config.ini (100%) rename rally/verification/{verifiers => }/tempest/config.py (100%) rename rally/verification/{verifiers => }/tempest/diff.py (98%) rename rally/verification/{verifiers => }/tempest/json2html.py (96%) rename rally/verification/{verifiers => }/tempest/report_templates/compare.mako (100%) rename rally/verification/{verifiers => }/tempest/subunit2json.py (100%) rename rally/verification/{verifiers => }/tempest/tempest.py (98%) delete mode 100644 rally/verification/verifiers/tempest/__init__.py rename tests/unit/verification/{verifiers => }/fake_log.xml (100%) rename tests/unit/verification/{verifiers => }/fakes.py (100%) rename tests/unit/verification/{verifiers => }/test_compare2html.py (96%) rename tests/unit/verification/{verifiers => }/test_config.py (95%) rename tests/unit/verification/{verifiers => }/test_diff.py (98%) rename tests/unit/verification/{verifiers => }/test_json2html.py (97%) rename tests/unit/verification/{verifiers => }/test_tempest.py (98%) delete mode 100644 tests/unit/verification/verifiers/__init__.py diff --git a/rally/api.py b/rally/api.py index 08683c115b..6d71e53acb 100644 --- a/rally/api.py +++ b/rally/api.py @@ -22,7 +22,7 @@ from rally import deploy from rally import exceptions from rally import log as logging from rally import objects -from rally.verification.verifiers.tempest import tempest +from rally.verification.tempest import tempest LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/context/tempest.py b/rally/benchmark/context/tempest.py index a95e93cd1c..13e0eb6a3e 100644 --- a/rally/benchmark/context/tempest.py +++ b/rally/benchmark/context/tempest.py @@ -23,8 +23,8 @@ from rally.common.i18n import _ from rally.common import utils from rally import exceptions from rally import log as logging -from rally.verification.verifiers.tempest import config -from rally.verification.verifiers.tempest import tempest +from rally.verification.tempest import config +from rally.verification.tempest import tempest LOG = logging.getLogger(__name__) diff --git a/rally/benchmark/validation.py b/rally/benchmark/validation.py index a0565d3437..d88e768432 100644 --- a/rally/benchmark/validation.py +++ b/rally/benchmark/validation.py @@ -24,7 +24,7 @@ from rally.benchmark import types as types from rally.common.i18n import _ from rally import consts from rally import exceptions -from rally.verification.verifiers.tempest import tempest +from rally.verification.tempest import tempest class ValidationResult(object): diff --git a/rally/cmd/commands/verify.py b/rally/cmd/commands/verify.py index 9937da6852..0c53f6e0e8 100644 --- a/rally/cmd/commands/verify.py +++ b/rally/cmd/commands/verify.py @@ -31,8 +31,8 @@ from rally import db from rally import exceptions from rally import objects from rally.openstack.common import cliutils as common_cliutils -from rally.verification.verifiers.tempest import diff -from rally.verification.verifiers.tempest import json2html +from rally.verification.tempest import diff +from rally.verification.tempest import json2html class VerifyCommands(object): diff --git a/rally/cmd/manage.py b/rally/cmd/manage.py index 4b026a884b..4bb2315357 100644 --- a/rally/cmd/manage.py +++ b/rally/cmd/manage.py @@ -22,7 +22,7 @@ import sys from rally.cmd import cliutils from rally.cmd import envutils from rally import db -from rally.verification.verifiers.tempest import tempest +from rally.verification.tempest import tempest class DBCommands(object): diff --git a/rally/verification/verifiers/__init__.py b/rally/verification/tempest/__init__.py similarity index 100% rename from rally/verification/verifiers/__init__.py rename to rally/verification/tempest/__init__.py diff --git a/rally/verification/verifiers/tempest/compare2html.py b/rally/verification/tempest/compare2html.py similarity index 100% rename from rally/verification/verifiers/tempest/compare2html.py rename to rally/verification/tempest/compare2html.py diff --git a/rally/verification/verifiers/tempest/config.ini b/rally/verification/tempest/config.ini similarity index 100% rename from rally/verification/verifiers/tempest/config.ini rename to rally/verification/tempest/config.ini diff --git a/rally/verification/verifiers/tempest/config.py b/rally/verification/tempest/config.py similarity index 100% rename from rally/verification/verifiers/tempest/config.py rename to rally/verification/tempest/config.py diff --git a/rally/verification/verifiers/tempest/diff.py b/rally/verification/tempest/diff.py similarity index 98% rename from rally/verification/verifiers/tempest/diff.py rename to rally/verification/tempest/diff.py index c85c49b463..da4d73f7e1 100644 --- a/rally/verification/verifiers/tempest/diff.py +++ b/rally/verification/tempest/diff.py @@ -15,7 +15,7 @@ import json -import compare2html +from rally.verification.tempest import compare2html class Diff(object): diff --git a/rally/verification/verifiers/tempest/json2html.py b/rally/verification/tempest/json2html.py similarity index 96% rename from rally/verification/verifiers/tempest/json2html.py rename to rally/verification/tempest/json2html.py index b13b3fcf55..2f5ef27f10 100644 --- a/rally/verification/verifiers/tempest/json2html.py +++ b/rally/verification/tempest/json2html.py @@ -11,7 +11,7 @@ # under the License. from rally.ui import utils as ui_utils -from rally.verification.verifiers.tempest import subunit2json +from rally.verification.tempest import subunit2json STATUS_MAP = {subunit2json.STATUS_PASS: "pass", diff --git a/rally/verification/verifiers/tempest/report_templates/compare.mako b/rally/verification/tempest/report_templates/compare.mako similarity index 100% rename from rally/verification/verifiers/tempest/report_templates/compare.mako rename to rally/verification/tempest/report_templates/compare.mako diff --git a/rally/verification/verifiers/tempest/subunit2json.py b/rally/verification/tempest/subunit2json.py similarity index 100% rename from rally/verification/verifiers/tempest/subunit2json.py rename to rally/verification/tempest/subunit2json.py diff --git a/rally/verification/verifiers/tempest/tempest.py b/rally/verification/tempest/tempest.py similarity index 98% rename from rally/verification/verifiers/tempest/tempest.py rename to rally/verification/tempest/tempest.py index 2a9629e378..6234113744 100644 --- a/rally/verification/verifiers/tempest/tempest.py +++ b/rally/verification/tempest/tempest.py @@ -25,8 +25,8 @@ from rally.common.i18n import _ from rally.common import utils from rally import exceptions from rally import log as logging -from rally.verification.verifiers.tempest import config -from rally.verification.verifiers.tempest import subunit2json +from rally.verification.tempest import config +from rally.verification.tempest import subunit2json LOG = logging.getLogger(__name__) diff --git a/rally/verification/verifiers/tempest/__init__.py b/rally/verification/verifiers/tempest/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/unit/benchmark/context/test_tempest.py b/tests/unit/benchmark/context/test_tempest.py index 8031ba9ed9..825c450d3b 100644 --- a/tests/unit/benchmark/context/test_tempest.py +++ b/tests/unit/benchmark/context/test_tempest.py @@ -19,13 +19,13 @@ import mock from rally.benchmark.context import tempest from rally import exceptions -from rally.verification.verifiers.tempest import config -from rally.verification.verifiers.tempest import tempest as tempest_verifier +from rally.verification.tempest import config +from rally.verification.tempest import tempest as tempest_verifier from tests.unit import test CONTEXT = "rally.benchmark.context.tempest" -TEMPEST = "rally.verification.verifiers.tempest.tempest" +TEMPEST = "rally.verification.tempest.tempest" class TempestContextTestCase(test.TestCase): diff --git a/tests/unit/benchmark/scenarios/tempest/test_tempest.py b/tests/unit/benchmark/scenarios/tempest/test_tempest.py index 9a2dd9febc..15515b0e5d 100644 --- a/tests/unit/benchmark/scenarios/tempest/test_tempest.py +++ b/tests/unit/benchmark/scenarios/tempest/test_tempest.py @@ -16,10 +16,10 @@ import mock from rally.benchmark.scenarios.tempest import tempest -from rally.verification.verifiers.tempest import tempest as verifier +from rally.verification.tempest import tempest as verifier from tests.unit import test -VERIFIER = "rally.verification.verifiers.tempest.tempest" +VERIFIER = "rally.verification.tempest.tempest" TS = "rally.benchmark.scenarios.tempest" diff --git a/tests/unit/benchmark/test_validation.py b/tests/unit/benchmark/test_validation.py index e2985b7d64..1a3ef56be5 100644 --- a/tests/unit/benchmark/test_validation.py +++ b/tests/unit/benchmark/test_validation.py @@ -20,7 +20,7 @@ from novaclient import exceptions as nova_exc from rally.benchmark import validation from rally import consts from rally import exceptions -from rally.verification.verifiers.tempest import tempest +from rally.verification.tempest import tempest from tests.unit import test diff --git a/tests/unit/cmd/commands/test_verify.py b/tests/unit/cmd/commands/test_verify.py index 65dc871f03..1c7ff83862 100644 --- a/tests/unit/cmd/commands/test_verify.py +++ b/tests/unit/cmd/commands/test_verify.py @@ -175,7 +175,7 @@ class VerifyCommandsTestCase(test.TestCase): @mock.patch("rally.cmd.commands.verify.open", create=True) @mock.patch("rally.db.verification_result_get") - @mock.patch("rally.verification.verifiers.tempest.json2html.HtmlOutput") + @mock.patch("rally.verification.tempest.json2html.HtmlOutput") def test_results_with_output_html_and_output_file(self, mock_html, mock_db_result_get, @@ -267,7 +267,7 @@ class VerifyCommandsTestCase(test.TestCase): @mock.patch("rally.cmd.commands.verify.open", create=True) @mock.patch("rally.db.verification_result_get") - @mock.patch(("rally.verification.verifiers.tempest." + @mock.patch(("rally.verification.tempest." "compare2html.create_report"), return_value="") def test_compare_with_output_html_and_output_file(self, mock_compare2html_create, diff --git a/tests/unit/cmd/test_manage.py b/tests/unit/cmd/test_manage.py index 04804ec2a5..c669c59e1c 100644 --- a/tests/unit/cmd/test_manage.py +++ b/tests/unit/cmd/test_manage.py @@ -53,7 +53,7 @@ class TempestCommandsTestCase(test.TestCase): @mock.patch("rally.cmd.manage.db.deployment_get", return_value={"uuid": "e24b5af0-0e2a-4a70-9443-b30a88ab152e"}) - @mock.patch("rally.verification.verifiers.tempest.tempest.Tempest") + @mock.patch("rally.verification.tempest.tempest.Tempest") def test_install(self, mock_tempest, mock_d_get): deployment_id = mock_d_get.return_value["uuid"] mock_tempest.return_value = self.tempest diff --git a/tests/unit/objects/test_verification.py b/tests/unit/objects/test_verification.py index 10ebefb16d..81666360d8 100644 --- a/tests/unit/objects/test_verification.py +++ b/tests/unit/objects/test_verification.py @@ -17,7 +17,7 @@ import mock from rally import objects from tests.unit import test -from tests.unit.verification.verifiers import fakes +from tests.unit.verification import fakes class VerificationTestCase(test.TestCase): diff --git a/tests/unit/test_api.py b/tests/unit/test_api.py index 7e31403ea3..40226b62e0 100644 --- a/tests/unit/test_api.py +++ b/tests/unit/test_api.py @@ -224,7 +224,7 @@ class APITestCase(test.TestCase): @mock.patch("rally.objects.Deployment.get") @mock.patch("rally.api.objects.Verification") - @mock.patch("rally.verification.verifiers.tempest.tempest.Tempest") + @mock.patch("rally.verification.tempest.tempest.Tempest") def test_verify(self, mock_tempest, mock_verification, mock_d_get): mock_d_get.return_value = {"uuid": self.deploy_uuid} @@ -238,7 +238,7 @@ class APITestCase(test.TestCase): @mock.patch("rally.api.objects.Deployment.get") @mock.patch("rally.api.objects.Verification") - @mock.patch("rally.verification.verifiers.tempest.tempest.Tempest") + @mock.patch("rally.verification.tempest.tempest.Tempest") def test_verify_tempest_not_installed(self, mock_tempest, mock_verification, mock_d_get): mock_d_get.return_value = {"uuid": self.deploy_uuid} diff --git a/tests/unit/verification/verifiers/fake_log.xml b/tests/unit/verification/fake_log.xml similarity index 100% rename from tests/unit/verification/verifiers/fake_log.xml rename to tests/unit/verification/fake_log.xml diff --git a/tests/unit/verification/verifiers/fakes.py b/tests/unit/verification/fakes.py similarity index 100% rename from tests/unit/verification/verifiers/fakes.py rename to tests/unit/verification/fakes.py diff --git a/tests/unit/verification/verifiers/test_compare2html.py b/tests/unit/verification/test_compare2html.py similarity index 96% rename from tests/unit/verification/verifiers/test_compare2html.py rename to tests/unit/verification/test_compare2html.py index c2d8754505..6679679912 100644 --- a/tests/unit/verification/verifiers/test_compare2html.py +++ b/tests/unit/verification/test_compare2html.py @@ -12,7 +12,7 @@ import mock -from rally.verification.verifiers.tempest import compare2html +from rally.verification.tempest import compare2html from tests.unit import test diff --git a/tests/unit/verification/verifiers/test_config.py b/tests/unit/verification/test_config.py similarity index 95% rename from tests/unit/verification/verifiers/test_config.py rename to tests/unit/verification/test_config.py index e2c170c748..1065fea4a4 100644 --- a/tests/unit/verification/verifiers/test_config.py +++ b/tests/unit/verification/test_config.py @@ -18,7 +18,7 @@ import os import mock from oslo.config import cfg -from rally.verification.verifiers.tempest import config +from rally.verification.tempest import config from tests.unit import fakes from tests.unit import test @@ -31,7 +31,7 @@ class ConfigTestCase(test.TestCase): @mock.patch("rally.osclients.Clients.services", return_value={"test_service_type": "test_service"}) @mock.patch("rally.osclients.Clients.verified_keystone") - @mock.patch("rally.verification.verifiers.tempest.config.os.path.isfile", + @mock.patch("rally.verification.tempest.config.os.path.isfile", return_value=True) def setUp(self, mock_isfile, mock_verified_keystone, mock_services, mock_get): @@ -57,8 +57,8 @@ class ConfigTestCase(test.TestCase): ("use_stderr", "False")) return [item for item in items if item not in defaults] - @mock.patch("rally.verification.verifiers.tempest.config.requests") - @mock.patch("rally.verification.verifiers.tempest.config.os.rename") + @mock.patch("rally.verification.tempest.config.requests") + @mock.patch("rally.verification.tempest.config.os.rename") @mock.patch("six.moves.builtins.open") def test__load_img_success(self, mock_open, mock_rename, mock_requests): mock_result = mock.MagicMock() @@ -72,7 +72,7 @@ class ConfigTestCase(test.TestCase): CONF.image.cirros_image)) mock_requests.get.assert_called_once_with(cirros_url, stream=True) - @mock.patch("rally.verification.verifiers.tempest.config.requests") + @mock.patch("rally.verification.tempest.config.requests") def test__load_img_notfound(self, mock_requests): mock_result = mock.MagicMock() mock_result.status_code = 404 @@ -93,7 +93,7 @@ class ConfigTestCase(test.TestCase): }]} self.assertEqual(self.conf_generator._get_url(service), url) - @mock.patch("rally.verification.verifiers.tempest.config.TempestConf" + @mock.patch("rally.verification.tempest.config.TempestConf" "._get_url") def test__set_boto(self, mock_get_url): url = "test_url" @@ -206,9 +206,9 @@ class ConfigTestCase(test.TestCase): self.conf_generator.conf.get("compute", "ssh_connect_method")) - @mock.patch("rally.verification.verifiers.tempest.config.os.path.exists", + @mock.patch("rally.verification.tempest.config.os.path.exists", return_value=False) - @mock.patch("rally.verification.verifiers.tempest.config.os.makedirs") + @mock.patch("rally.verification.tempest.config.os.makedirs") def test__set_default(self, mock_makedirs, mock_exists): self.conf_generator._set_default() lock_path = os.path.join(self.conf_generator.data_path, "lock_files_%s" @@ -273,7 +273,7 @@ class ConfigTestCase(test.TestCase): self.conf_generator.conf.get("network", "default_network")) - @mock.patch("rally.verification.verifiers.tempest.config.requests") + @mock.patch("rally.verification.tempest.config.requests") def test__set_service_available(self, mock_requests): mock_result = mock.MagicMock() mock_result.status_code = 404 @@ -289,7 +289,7 @@ class ConfigTestCase(test.TestCase): self.conf_generator.conf.items("service_available")) self.assertEqual(sorted(expected), sorted(options)) - @mock.patch("rally.verification.verifiers.tempest.config.requests") + @mock.patch("rally.verification.tempest.config.requests") def test__set_service_available_horizon(self, mock_requests): mock_result = mock.MagicMock() mock_result.status_code = 200 diff --git a/tests/unit/verification/verifiers/test_diff.py b/tests/unit/verification/test_diff.py similarity index 98% rename from tests/unit/verification/verifiers/test_diff.py rename to tests/unit/verification/test_diff.py index 1dc1b92c9b..8928c02aed 100644 --- a/tests/unit/verification/verifiers/test_diff.py +++ b/tests/unit/verification/test_diff.py @@ -9,7 +9,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -from rally.verification.verifiers.tempest import diff +from rally.verification.tempest import diff from tests.unit import test diff --git a/tests/unit/verification/verifiers/test_json2html.py b/tests/unit/verification/test_json2html.py similarity index 97% rename from tests/unit/verification/verifiers/test_json2html.py rename to tests/unit/verification/test_json2html.py index a46f2a987e..7417a191aa 100644 --- a/tests/unit/verification/verifiers/test_json2html.py +++ b/tests/unit/verification/test_json2html.py @@ -12,10 +12,10 @@ import mock -from rally.verification.verifiers.tempest import json2html +from rally.verification.tempest import json2html from tests.unit import test -BASE = "rally.verification.verifiers.tempest" +BASE = "rally.verification.tempest" class HtmlOutputTestCase(test.TestCase): diff --git a/tests/unit/verification/verifiers/test_tempest.py b/tests/unit/verification/test_tempest.py similarity index 98% rename from tests/unit/verification/verifiers/test_tempest.py rename to tests/unit/verification/test_tempest.py index 80bb4e6a39..eccc7874a8 100644 --- a/tests/unit/verification/verifiers/test_tempest.py +++ b/tests/unit/verification/test_tempest.py @@ -23,12 +23,12 @@ from oslo.serialization import jsonutils import testtools from rally import exceptions -from rally.verification.verifiers.tempest import subunit2json -from rally.verification.verifiers.tempest import tempest +from rally.verification.tempest import subunit2json +from rally.verification.tempest import tempest from tests.unit import test -TEMPEST_PATH = "rally.verification.verifiers.tempest" +TEMPEST_PATH = "rally.verification.tempest" class BaseTestCase(test.TestCase): diff --git a/tests/unit/verification/verifiers/__init__.py b/tests/unit/verification/verifiers/__init__.py deleted file mode 100644 index e69de29bb2..0000000000