diff --git a/rally_openstack/common/osclients.py b/rally_openstack/common/osclients.py index 7367fbea..c161293e 100644 --- a/rally_openstack/common/osclients.py +++ b/rally_openstack/common/osclients.py @@ -315,6 +315,7 @@ class Keystone(OSClient): version = str(discover.Discover( temp_session, password_args["auth_url"]).version_data()[0]["version"][0]) + temp_session.session.close() if "v2.0" not in password_args["auth_url"] and version != "2": password_args.update({ @@ -868,7 +869,7 @@ class Clients(object): @classmethod def create_from_env(cls): from rally_openstack.common import credential - from rally_openstack.platforms import existing + from rally_openstack.environment.platforms import existing spec = existing.OpenStack.create_spec_from_sys_environ(os.environ) if not spec["available"]: diff --git a/tests/functional/utils.py b/tests/functional/utils.py index f96d9783..efff9b83 100644 --- a/tests/functional/utils.py +++ b/tests/functional/utils.py @@ -23,7 +23,7 @@ import shutil import subprocess import tempfile -from oslo_utils import encodeutils +from rally.utils import encodeutils class RallyCliError(Exception): @@ -217,7 +217,7 @@ class Rally(object): except subprocess.CalledProcessError as e: output = e.output - raise RallyCliError(cmd, e.returncode, e.output) + raise RallyCliError(cmd, e.returncode, e.output) from None finally: if write_report: if not report_path: diff --git a/tests/unit/common/test_osclients.py b/tests/unit/common/test_osclients.py index b3c67594..0d4e9114 100644 --- a/tests/unit/common/test_osclients.py +++ b/tests/unit/common/test_osclients.py @@ -251,10 +251,12 @@ class TestCreateKeystoneClient(test.TestCase, OSClientTestCaseUtils): tenant_name="tenant", username="user", domain_name=None, project_domain_name=None, user_domain_name=None) - self.ksa_session.Session.assert_has_calls( + self.assertEqual( [mock.call(timeout=180.0, verify=True, cert=None), mock.call(auth=self.ksa_identity_plugin, timeout=180.0, - verify=True, cert=None)]) + verify=True, cert=None)], + self.ksa_session.Session.call_args_list + ) def test_keystone_property(self): keystone = osclients.Keystone(self.credential, None) diff --git a/tests/unit/environment/platforms/test_existing.py b/tests/unit/environment/platforms/test_existing.py index 99a1adf6..3b4bd74a 100644 --- a/tests/unit/environment/platforms/test_existing.py +++ b/tests/unit/environment/platforms/test_existing.py @@ -21,7 +21,7 @@ from rally.env import env_mgr from rally.env import platform from rally import exceptions -from rally_openstack.platforms import existing +from rally_openstack.environment.platforms import existing from tests.unit import test diff --git a/tests/unit/task/cleanup/test_base.py b/tests/unit/task/cleanup/test_base.py index 305ada0f..d2c03d41 100644 --- a/tests/unit/task/cleanup/test_base.py +++ b/tests/unit/task/cleanup/test_base.py @@ -19,7 +19,7 @@ from rally_openstack.task.cleanup import base from tests.unit import test -BASE = "rally_openstack.cleanup.base" +BASE = "rally_openstack.task.cleanup.base" class ResourceDecoratorTestCase(test.TestCase): diff --git a/tests/unit/task/cleanup/test_manager.py b/tests/unit/task/cleanup/test_manager.py index 0bf0e642..67d89a1e 100644 --- a/tests/unit/task/cleanup/test_manager.py +++ b/tests/unit/task/cleanup/test_manager.py @@ -22,7 +22,7 @@ from rally_openstack.task.cleanup import manager from tests.unit import test -BASE = "rally_openstack.cleanup.manager" +BASE = "rally_openstack.task.cleanup.manager" class SeekAndDestroyTestCase(test.TestCase): diff --git a/tests/unit/task/cleanup/test_resources.py b/tests/unit/task/cleanup/test_resources.py index 1ede686d..19c6bee3 100644 --- a/tests/unit/task/cleanup/test_resources.py +++ b/tests/unit/task/cleanup/test_resources.py @@ -24,7 +24,7 @@ from watcherclient.common.apiclient import exceptions as watcher_exceptions from rally_openstack.task.cleanup import resources from tests.unit import test -BASE = "rally_openstack.cleanup.resources" +BASE = "rally_openstack.task.cleanup.resources" GLANCE_V2_PATH = ("rally_openstack.common.services.image.glance_v2." "GlanceV2Service") diff --git a/tests/unit/task/contexts/manila/test_manila_shares.py b/tests/unit/task/contexts/manila/test_manila_shares.py index 4442ae40..dcf67af8 100644 --- a/tests/unit/task/contexts/manila/test_manila_shares.py +++ b/tests/unit/task/contexts/manila/test_manila_shares.py @@ -182,7 +182,7 @@ class SharesTestCase(test.TestCase): mock_calls, any_order=True) @mock.patch(MANILA_UTILS_PATH + "_create_share") - @mock.patch("rally_openstack.cleanup.manager.cleanup") + @mock.patch("rally_openstack.task.cleanup.manager.cleanup") def test_cleanup( self, mock_cleanup_manager_cleanup, diff --git a/tests/unit/task/test_scenario.py b/tests/unit/task/test_scenario.py index 076e55fc..f838e1dd 100644 --- a/tests/unit/task/test_scenario.py +++ b/tests/unit/task/test_scenario.py @@ -104,8 +104,8 @@ class OpenStackScenarioTestCase(test.TestCase): ([("admin", CREDENTIAL_WITHOUT_HMAC), ("user", CREDENTIAL_WITHOUT_HMAC)], 0)) @ddt.unpack - @mock.patch("rally_openstack.scenario.profiler.init") - @mock.patch("rally_openstack.scenario.profiler.get") + @mock.patch("rally_openstack.task.scenario.profiler.init") + @mock.patch("rally_openstack.task.scenario.profiler.get") def test_profiler_init(self, users_credentials, expected_call_count, mock_profiler_get, diff --git a/tests/unit/test.py b/tests/unit/test.py index b47cca2b..5af46df2 100644 --- a/tests/unit/test.py +++ b/tests/unit/test.py @@ -126,14 +126,14 @@ class ScenarioTestCase(TestCase): return key in self._clients def get_client_mocks(self): - base_path = "rally_openstack" + base_path = "rally_openstack.task" return [ mock.patch( - "%s.scenario.OpenStackScenario.clients" % base_path, + f"{base_path}.scenario.OpenStackScenario.clients", mock.Mock(side_effect=self.clients)), mock.patch( - "%s.scenario.OpenStackScenario.admin_clients" % base_path, + f"{base_path}.scenario.OpenStackScenario.admin_clients", mock.Mock(side_effect=self.admin_clients)) ] diff --git a/tests/unit/test__compat.py b/tests/unit/test__compat.py new file mode 100644 index 00000000..896ec833 --- /dev/null +++ b/tests/unit/test__compat.py @@ -0,0 +1,43 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import warnings + +from tests.unit import test + + +class CompatibilityTestCase(test.TestCase): + def test_old_imports_work(self): + + with warnings.catch_warnings(record=True) as ctx: + warnings.simplefilter("always") + + from rally_openstack import osclients + + if not ctx: + self.fail("`rally_openstack._compat` should raise a warning.") + self.assertEqual(1, len(ctx)) + catched_warning = ctx[0] + self.assertEqual( + "Module rally_openstack.osclients is deprecated since " + "rally-openstack 2.0.0. Use rally_openstack.common.osclients " + "instead.", + # catched_warning.message is an instance of an exception + str(catched_warning.message)) + + from rally_openstack.common import osclients as right_osclients + + expected = set(o for o in dir(right_osclients) + if not o.startswith("_")) + actual = set(o for o in dir(osclients) if not o.startswith("_")) + self.assertEqual(expected, actual) + self.assertEqual(right_osclients.Clients, osclients.Clients) diff --git a/tox.ini b/tox.ini index dbcc549c..a53b1ce6 100644 --- a/tox.ini +++ b/tox.ini @@ -115,4 +115,20 @@ commands = bindep commands = {toxinidir}/tests/ci/rally_self_job.sh {toxinidir}/rally-jobs/self-rally.yaml [pytest] -addopts = -p no:warnings +filterwarnings = + error + ignore:.*EngineFacade is deprecated; please use oslo_db.sqlalchemy.enginefacade*: + # instead of ignoring all modules, let's list only libraries that are failing + ignore:invalid escape sequence:DeprecationWarning:.*netaddr.* + ignore:invalid escape sequence:DeprecationWarning:.*prettytable + ignore:invalid escape sequence:DeprecationWarning:.*subunit.* + ignore:invalid escape sequence:DeprecationWarning:.*testtools.* + # new to rally-openstack + ignore:Using or importing the ABCs:DeprecationWarning:.*oslo_context.* + ignore:the imp module is deprecated in favour of importlib.*:DeprecationWarning + # should be fixed soon + ignore:Module rally_openstack.credential is deprecated.*: + # python 3.7 + ignore:Using or importing the ABCs:DeprecationWarning:unittest2.* + # python 3.8 + ignore:::.*netaddr.strategy.* \ No newline at end of file