diff --git a/tests/unit/test_database.py b/tests/unit/test_database.py index 3453f9f728..f9c0366cdb 100644 --- a/tests/unit/test_database.py +++ b/tests/unit/test_database.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +import os import re import subprocess @@ -226,8 +227,9 @@ class TestPostgresqlDatabase(DBBaseTestCase): def test_migration(self): # Test that SQLAlchemy create_all produces the same output as # a full migration run. + pg_dump = os.environ.get("ZUUL_TEST_PG_DUMP", "pg_dump") sqlalchemy_out = subprocess.check_output( - f"pg_dump -h {self.db.host} -U {self.db.name} -s {self.db.name}", + f"{pg_dump} -h {self.db.host} -U {self.db.name} -s {self.db.name}", shell=True, env={'PGPASSWORD': self.db.passwd} ) @@ -246,7 +248,7 @@ class TestPostgresqlDatabase(DBBaseTestCase): self.connection.onLoad(self.zk_client) alembic_out = subprocess.check_output( - f"pg_dump -h {self.db.host} -U {self.db.name} -s {self.db.name}", + f"{pg_dump} -h {self.db.host} -U {self.db.name} -s {self.db.name}", shell=True, env={'PGPASSWORD': self.db.passwd} ) diff --git a/tools/test-setup-docker.sh b/tools/test-setup-docker.sh index 1601b11a7f..bd692d1e52 100755 --- a/tools/test-setup-docker.sh +++ b/tools/test-setup-docker.sh @@ -62,4 +62,8 @@ ${ROOTCMD} ${MYSQL} -e "CREATE USER 'openstack_citest'@'%' identified by 'openst ${ROOTCMD} ${MYSQL} -e "GRANT ALL PRIVILEGES ON *.* TO 'openstack_citest'@'%' WITH GRANT OPTION;" ${ROOTCMD} ${MYSQL} -u openstack_citest -popenstack_citest -e "SET default_storage_engine=MYISAM; DROP DATABASE IF EXISTS openstack_citest; CREATE DATABASE openstack_citest CHARACTER SET utf8;" +set +x echo "Finished" + +echo "Set this variable to use the in-container pg_dump command:" +echo 'export ZUUL_TEST_PG_DUMP="docker exec -t zuul-test-postgres pg_dump"'