summaryrefslogtreecommitdiff
path: root/oslo_db/tests/sqlalchemy/test_sqlalchemy.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-01-07 17:43:30 -0500
committerRoman Podoliaka <rpodolyaka@mirantis.com>2015-01-08 11:59:47 +0200
commitcfbe5c56340c0e4a3b18902d7e55bb18a45857ec (patch)
tree5fc05d5bdadda51b1460ebb07ff9227a54185b32 /oslo_db/tests/sqlalchemy/test_sqlalchemy.py
parent98b434db7d1b52aee32782065df155988918cc3f (diff)
downloadoslo-db-cfbe5c56340c0e4a3b18902d7e55bb18a45857ec.tar.gz
Ensure mysql_sql_mode is set for MySQLOpportunisticTests
The default setting for oslo.db is TRADITIONAL for mysql_sql_mode; this is set up in oslo_db/options.py as well as in EngineFacade; however, the provisioning system currently does not use these options or EngineFacade, and the default for mysql_sql_mode in the base session.create_engine() is None. For a MySQL/MariaDB database where this is not established in my.cnf, tests will run without TRADITIONAL SQL mode and some tests will fail, including some Nova migration tests that rely upon this. This patch resolves that as well as the warning we see in tests regarding the empty SQL mode. Change-Id: I3acdc0fb30327f56a76ee299cc6bade7c5a7e312
Diffstat (limited to 'oslo_db/tests/sqlalchemy/test_sqlalchemy.py')
-rw-r--r--oslo_db/tests/sqlalchemy/test_sqlalchemy.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/oslo_db/tests/sqlalchemy/test_sqlalchemy.py b/oslo_db/tests/sqlalchemy/test_sqlalchemy.py
index 26cda61..28ae411 100644
--- a/oslo_db/tests/sqlalchemy/test_sqlalchemy.py
+++ b/oslo_db/tests/sqlalchemy/test_sqlalchemy.py
@@ -209,6 +209,16 @@ class FakeDB2Engine(object):
pass
+class MySQLDefaultModeTestCase(test_base.MySQLOpportunisticTestCase):
+ def test_default_is_traditional(self):
+ with self.engine.connect() as conn:
+ sql_mode = conn.execute(
+ "SHOW VARIABLES LIKE 'sql_mode'"
+ ).first()[1]
+
+ self.assertTrue("TRADITIONAL" in sql_mode)
+
+
class MySQLModeTestCase(test_base.MySQLOpportunisticTestCase):
def __init__(self, *args, **kwargs):
@@ -441,8 +451,11 @@ class MysqlConnectTest(test_base.MySQLOpportunisticTestCase):
# If _mysql_set_mode_callback is called with sql_mode=None, then
# the SQL mode is NOT set on the connection.
+ # get the GLOBAL sql_mode, not the @@SESSION, so that
+ # we get what is configured for the MySQL database, as opposed
+ # to what our own session.create_engine() has set it to.
expected = self.engine.execute(
- "SHOW VARIABLES LIKE 'sql_mode'").fetchone()[1]
+ "SELECT @@GLOBAL.sql_mode").scalar()
engine = self._fixture(sql_mode=None)
self._assert_sql_mode(engine, expected, None)