]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Override opportunistic database tests to PyMySQL
authorJeremy Stanley <fungi@yuggoth.org>
Thu, 18 Jun 2015 19:09:05 +0000 (19:09 +0000)
committerCedric Brandily <zzelle@gmail.com>
Tue, 23 Jun 2015 19:04:06 +0000 (21:04 +0200)
Set the OS_TEST_DBAPI_ADMIN_CONNECTION override variable so that
oslo.db opportunistic detection will know to use PyMySQL until
I12b32dc097a121bd43991bc38dd4d289b65e86c1 makes it the default
behavior.

This change removes previous code[1] enabling PyMySQL use.

[1] Ic5c1d12ab75443e1cc290a7447eeb4b452b4a9dd

Change-Id: Ic39feee0248f2ffabdba26f3779ab40a8f3838e6
Co-Authored-By: Victor Sergeyev <vsergeyev@mirantis.com>
Co-Authored-By: Cedric Brandily <zzelle@gmail.com>
neutron/tests/common/base.py
tox.ini

index 8c89f9be76ef5be6dceca369b8a3bf1d1cbe1622..eff4a0bf44c878a764fe8790af572082ee1c50cd 100644 (file)
@@ -14,7 +14,6 @@
 import functools
 import unittest.case
 
-from oslo_db.sqlalchemy import provision
 from oslo_db.sqlalchemy import test_base
 import testtools.testcase
 
@@ -71,49 +70,12 @@ def no_skip_on_missing_deps(wrapped):
     return wrapper
 
 
-# NOTE(cbrandily): Define mysql+pymysql backend implementation
-@provision.BackendImpl.impl.dispatch_for("mysql+pymysql")
-class PyMySQLBackendImpl(provision.BackendImpl):
-
-    default_engine_kwargs = {'mysql_sql_mode': 'TRADITIONAL'}
-
-    def create_opportunistic_driver_url(self):
-        return "mysql+pymysql://openstack_citest:openstack_citest@localhost/"
-
-    def create_named_database(self, engine, ident, conditional=False):
-        with engine.connect() as conn:
-            if not conditional or not self.database_exists(conn, ident):
-                conn.execute("CREATE DATABASE %s" % ident)
-
-    def drop_named_database(self, engine, ident, conditional=False):
-        with engine.connect() as conn:
-            if not conditional or self.database_exists(conn, ident):
-                conn.execute("DROP DATABASE %s" % ident)
-
-    def database_exists(self, engine, ident):
-        return bool(engine.scalar("SHOW DATABASES LIKE '%s'" % ident))
-
-
-impl = provision.BackendImpl.impl("mysql+pymysql")
-url = impl.create_opportunistic_driver_url()
-# NOTE(cbrandily): Declare mysql+pymysql backend implementation
-provision.Backend("mysql+pymysql", url)
-
-
-# NOTE(cbrandily): Define mysql+pymysql db fixture
-class PyMySQLFixture(test_base.DbFixture):
-    DRIVER = 'mysql+pymysql'
-
-
-# NOTE(cbrandily): Define mysql+pymysql base testcase
-class MySQLTestCase(test_base.DbTestCase):
+class MySQLTestCase(test_base.MySQLOpportunisticTestCase):
     """Base test class for MySQL tests.
 
-    Enforce the supported driver, which is PyMySQL.
     If the MySQL db is unavailable then this test is skipped, unless
     OS_FAIL_ON_MISSING_DEPS is enabled.
     """
-    FIXTURE = PyMySQLFixture
     SKIP_ON_UNAVAILABLE_DB = not base.bool_from_env('OS_FAIL_ON_MISSING_DEPS')
 
 
diff --git a/tox.ini b/tox.ini
index 75eb74c243b4cab103ed66cf59f5a77de9bd4d26..070d983a2af73db0535eb86c135d53c254f760f2 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -5,6 +5,7 @@ skipsdist = True
 
 [testenv]
 setenv = VIRTUAL_ENV={envdir}
+         OS_TEST_DBAPI_ADMIN_CONNECTION=mysql+pymysql://openstack_citest:openstack_citest@localhost/;postgresql://openstack_citest:openstack_citest@localhost/postgres;sqlite://
 passenv = TRACE_FAILONLY
 usedevelop = True
 install_command = pip install -U {opts} {packages}