From 7f191e9bc6a0e3fc577ad903a3d02a08c9d3bca3 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Fri, 3 May 2019 11:54:14 +0200 Subject: [PATCH 2/2] tests: use pg_virtualenv with on jenkins (#27083) --- jenkins.sh | 2 +- tests/settings.py | 5 +++++ tox.ini | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/jenkins.sh b/jenkins.sh index 2c4fca0..25932f9 100755 --- a/jenkins.sh +++ b/jenkins.sh @@ -11,4 +11,4 @@ done virtualenv venv venv/bin/pip install tox -venv/bin/tox -rv +PGPORT=`python -c 'import struct; import socket; s=socket.socket(); s.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, struct.pack("ii", 1, 0)); s.bind(("", 0)); print(s.getsockname()[1]); s.close()'` pg_virtualenv -o fsync=off venv/bin/tox -rv diff --git a/tests/settings.py b/tests/settings.py index 2e48c94..f08a2dd 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -9,3 +9,8 @@ DATABASES = { }, } } + +if 'postgres' in DATABASES['default']['ENGINE']: + for key in ('PGPORT', 'PGHOST', 'PGUSER', 'PGPASSWORD'): + if key in os.environ: + DATABASES['default'][key[2:]] = os.environ[key] diff --git a/tox.ini b/tox.ini index b84d055..f287687 100644 --- a/tox.ini +++ b/tox.ini @@ -18,6 +18,10 @@ setenv = pg: DB_ENGINE=django.db.backends.postgresql_psycopg2 coverage: COVERAGE=--junitxml=junit-{envname}.xml --cov-report xml --cov-report html --cov=src/ --cov-config .coveragerc fast: FAST=--nomigrations + PGPORT={env:PGPORT:} + PGHOST={env:PGHOST:} + PGUSER={env:PGUSER:} + PGPASSWORD={env:PGPASSWORD:} usedevelop = coverage: True nocoverage: False -- 2.20.1