From 59e43988fd78bc4a5b3ba5e79a59d9936210c62f Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Wed, 13 Jun 2018 14:40:34 -0400 Subject: [PATCH] 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 Co-Authored-By: Vitalii Solodilov --- mistral/tests/unit/services/test_scheduler.py | 8 ++++---- run_tests.sh | 10 ++++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/mistral/tests/unit/services/test_scheduler.py b/mistral/tests/unit/services/test_scheduler.py index 6a1e201a5..0fecc6ec1 100644 --- a/mistral/tests/unit/services/test_scheduler.py +++ b/mistral/tests/unit/services/test_scheduler.py @@ -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)) diff --git a/run_tests.sh b/run_tests.sh index 0bf86127b..da17558c9 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -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 = /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 = /connection = mysql+pymysql:\/\/$username:$password@localhost\/$dbname/g" .mistral.conf + ;; esac }