From 5a334171255a07cbb166ae3471838064ef4e26aa Mon Sep 17 00:00:00 2001 From: Sam Betts Date: Tue, 6 Dec 2016 17:53:41 +0000 Subject: [PATCH] Switch to new location for oslo.db test cases Oslo.db moved some of their test cases around, they left deprecation warnings on the old locations which needed resolving. This patch switches our migration tests to use the new locations and get rid of the warnings. Also it removes the test_connect_fail tests, as they use the values that are deprecated on the oslo_db side. Change-Id: Idfab443dba26e94d9e50814cf7ffc5624748b476 Closes-Bug: #1647733 Closes-Bug: #1647735 --- .../unit/db/sqlalchemy/test_migrations.py | 27 +------------------ 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/ironic/tests/unit/db/sqlalchemy/test_migrations.py b/ironic/tests/unit/db/sqlalchemy/test_migrations.py index aa9851ff59..4be62fb111 100644 --- a/ironic/tests/unit/db/sqlalchemy/test_migrations.py +++ b/ironic/tests/unit/db/sqlalchemy/test_migrations.py @@ -42,9 +42,9 @@ from alembic import script import mock from oslo_db import exception as db_exc from oslo_db.sqlalchemy import enginefacade -from oslo_db.sqlalchemy import test_base from oslo_db.sqlalchemy import test_migrations from oslo_db.sqlalchemy import utils as db_utils +from oslo_db.tests.sqlalchemy import base as test_base from oslo_log import log as logging from oslo_utils import uuidutils import sqlalchemy @@ -80,21 +80,6 @@ def _get_connect_string(backend, user, passwd, database): 'database': database}) -def _is_backend_avail(backend, user, passwd, database): - try: - connect_uri = _get_connect_string(backend, user, passwd, database) - engine = sqlalchemy.create_engine(connect_uri) - connection = engine.connect() - except Exception: - # intentionally catch all to handle exceptions even if we don't - # have any backend code loaded. - return False - else: - connection.close() - engine.dispose() - return True - - @contextlib.contextmanager def patch_with_engine(engine): with mock.patch.object(enginefacade.get_legacy_facade(), @@ -223,16 +208,6 @@ class MigrationCheckersMixin(object): def test_walk_versions(self): self._walk_versions(self.engine, self.config) - def test_connect_fail(self): - """Test that we can trigger a database connection failure - - Test that we can fail gracefully to ensure we don't break people - without specific database backend - """ - if _is_backend_avail(self.FIXTURE.DRIVER, "openstack_cifail", - self.FIXTURE.USERNAME, self.FIXTURE.DBNAME): - self.fail("Shouldn't have connected") - def _check_21b331f883ef(self, engine, data): nodes = db_utils.get_table(engine, 'nodes') col_names = [column.name for column in nodes.c]