From 25f2c5e07954c0e15482c22120031b278e584a1a Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Wed, 20 May 2015 01:03:59 +0000 Subject: [PATCH] Switch from MySQL-python to PyMySQL As discussed in the Liberty Design Summit "Moving apps to Python 3" cross-project workshop, the way forward in the near future is to switch to the pure-python PyMySQL library as a default. https://etherpad.openstack.org/p/liberty-cross-project-python3 Also 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. Change-Id: Icd91a065d3c4f62791ba0dca99a822e3a1a0ad44 Co-Authored-By: Victor Sergeyev --- doc/source/cmds/ironic-dbsync.rst | 2 +- doc/source/deploy/install-guide.rst | 2 +- test-requirements-py3.txt | 22 ---------------------- test-requirements.txt | 2 +- tox.ini | 18 ++++++------------ 5 files changed, 9 insertions(+), 37 deletions(-) delete mode 100644 test-requirements-py3.txt diff --git a/doc/source/cmds/ironic-dbsync.rst b/doc/source/cmds/ironic-dbsync.rst index 8d2892a503..9e9e3ec918 100644 --- a/doc/source/cmds/ironic-dbsync.rst +++ b/doc/source/cmds/ironic-dbsync.rst @@ -69,7 +69,7 @@ The configuration file defines the database backend to use with the *connection* database option:: [database] - connection=mysql://root@localhost/ironic + connection=mysql+pymysql://root@localhost/ironic If no configuration file is specified with the :option:`--config-file` option, :command:`ironic-dbsync` assumes an SQLite database. diff --git a/doc/source/deploy/install-guide.rst b/doc/source/deploy/install-guide.rst index 254352839a..5211db34f6 100644 --- a/doc/source/deploy/install-guide.rst +++ b/doc/source/deploy/install-guide.rst @@ -169,7 +169,7 @@ so that the Bare Metal Service is configured for your needs. # The SQLAlchemy connection string used to connect to the # database (string value) #connection= - connection = mysql://ironic:IRONIC_DBPASSWORD@DB_IP/ironic?charset=utf8 + connection = mysql+pymysql://ironic:IRONIC_DBPASSWORD@DB_IP/ironic?charset=utf8 #. Configure the Bare Metal Service to use the RabbitMQ message broker by setting one or more of these options. Replace RABBIT_HOST with the diff --git a/test-requirements-py3.txt b/test-requirements-py3.txt deleted file mode 100644 index ce0a61d699..0000000000 --- a/test-requirements-py3.txt +++ /dev/null @@ -1,22 +0,0 @@ -# The order of packages is significant, because pip processes them in the order -# of appearance. Changing the order has an impact on the overall integration -# process, which may cause wedges in the gate later. -hacking<0.11,>=0.10.0 -coverage>=3.6 -discover -fixtures>=0.3.14 -mock>=1.0 -Babel>=1.3 -oslotest>=1.5.1 # Apache-2.0 -psycopg2 -PyMySQL>=0.6.2 # MIT License -python-ironicclient>=0.2.1 -python-subunit>=0.0.18 -testrepository>=0.0.18 -testtools>=1.4.0 - -# Doc requirements -sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 -sphinxcontrib-pecanwsme>=0.8 -oslosphinx>=2.5.0 # Apache-2.0 - diff --git a/test-requirements.txt b/test-requirements.txt index e3a2521b61..11b5b4aa96 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -7,7 +7,7 @@ discover fixtures>=0.3.14 mock>=1.0 Babel>=1.3 -MySQL-python +PyMySQL>=0.6.2 # MIT License oslotest>=1.5.1 # Apache-2.0 psycopg2 python-ironicclient>=0.2.1 diff --git a/tox.ini b/tox.ini index 75c72f9611..30b9e3b828 100644 --- a/tox.ini +++ b/tox.ini @@ -7,6 +7,12 @@ envlist = py27,py34,pep8 usedevelop = True install_command = pip install -U {opts} {packages} setenv = VIRTUAL_ENV={envdir} + # NOTE(viktors): we must change default connection string for MySQL + # because we are use PyMySQL as a DB connector, but opportunistic + # migration tests uses MySQLdb by default. + # TODO(viktors): Remove this evn variable, when Ironic will use + # oslo.db>=1.12.0 + OS_TEST_DBAPI_ADMIN_CONNECTION=mysql+pymysql://openstack_citest:openstack_citest@localhost/;postgresql://openstack_citest:openstack_citest@localhost/postgres;sqlite:// PYTHONDONTWRITEBYTECODE = 1 LANGUAGE=en_US deps = -r{toxinidir}/requirements.txt @@ -24,18 +30,6 @@ deps = {[testenv]deps} pydot2 commands = {toxinidir}/tools/states_to_dot.py -f {toxinidir}/doc/source/images/states.svg --format svg -[testenv:py34] -# NOTE(viktors): we must change default connection string for MySQL because -# we use a different DB connector (PyMySQL, not MySQLdb) in py3x -# env. So we should put new DB URLs in the env variable. This -# will allow to run tests, that require MySQL database, -# for example DB migration tests. -setenv = - {[testenv]setenv} - OS_TEST_DBAPI_ADMIN_CONNECTION=mysql+pymysql://openstack_citest:openstack_citest@localhost/;postgresql://openstack_citest:openstack_citest@localhost/postgres;sqlite:// -deps = -r{toxinidir}/requirements.txt - -r{toxinidir}/test-requirements-py3.txt - [testenv:pep8] commands = flake8 {posargs}