switch mysql functional tests to PyMySQL

The mysql-python library does not support Python 3, so to be able to
run the functional tests under Python 3 we need a new library. The
oslo.db package uses and supports PyMySQL.

In addition to changing the dependency, change the database connection
string used.

Change-Id: Ide944f8df051bb5e011af1c881387a166d041b7c
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
Co-Authored-By: Vitalii Solodilov <mcdkr@yandex.ru>
This commit is contained in:
Doug Hellmann 2018-06-13 14:40:34 -04:00 committed by Brad P. Crochet
parent 821808a1b6
commit 59e43988fd
2 changed files with 12 additions and 6 deletions

View File

@ -241,6 +241,9 @@ class SchedulerServiceTest(base.DbTestCase):
self._assert_single_item(calls, target_method_name=TARGET_METHOD_PATH)
self.queue.get()
eventlet.sleep(0.1)
self.assertRaises(
exc.DBEntityNotFoundError,
db_api.get_delayed_call,
@ -335,7 +338,4 @@ class SchedulerServiceTest(base.DbTestCase):
for _ in range(number_delayed_calls):
self.queue.get()
self.assertEqual(
[2, 2, 1],
processed_calls_at_time
)
self.assertListEqual([1, 2, 2], sorted(processed_calls_at_time))

View File

@ -139,7 +139,7 @@ function setup_db_pylib {
;;
mysql )
echo "Installing python library for MySQL"
${wrapper} pip install mysql-python
${wrapper} pip install PyMySQL
;;
esac
}
@ -149,12 +149,18 @@ function setup_db_cfg {
sqlite )
rm -f .mistral.conf
;;
"postgresql" | "mysql" )
"postgresql" )
oslo-config-generator --config-file \
./tools/config/config-generator.mistral.conf \
--output-file .mistral.conf
sed -i "s/#connection = <None>/connection = $db_type:\/\/$username:$password@localhost\/$dbname/g" .mistral.conf
;;
"mysql" )
oslo-config-generator --config-file \
./tools/config/config-generator.mistral.conf \
--output-file .mistral.conf
sed -i "s/#connection = <None>/connection = mysql+pymysql:\/\/$username:$password@localhost\/$dbname/g" .mistral.conf
;;
esac
}