[Gate fix] Fix pifpaf run postgresql failing.
This PS unblocks the gate by replacing pifpaf to run postgresql for unit tests with docker, as a workaround. This is because "pifpaf run postgresql" is failing with pifpaf not being able to find the command "pifpaf run". Steps to reproduce: python3 -m virtualenv -p python3 /tmp/venv source /tmp/venv/bin/activate pip install -U pip wheel devpi-client setuptools pip install pifpaf $pifpaf run postgresql >> pifpaf: 'run' is not a pifpaf command. See 'pifpaf --help'. >> Did you mean one of these? help The unit test script for spinning up the docker postgresql container and then running unit tests is very similar to the pre-existing script for running functional tests located in tools/ directory. Change-Id: Ib0f414ff58007037ac12161876dcd7a10e91f48c
This commit is contained in:
parent
904000391a
commit
2bfb16e44d
@ -106,7 +106,7 @@ class DeckhandWithDBTestCase(DeckhandTestCase):
|
||||
def setUp(self):
|
||||
super(DeckhandWithDBTestCase, self).setUp()
|
||||
self.override_config(
|
||||
'connection', os.environ.get('PIFPAF_URL', 'sqlite://'),
|
||||
'connection', os.environ.get('DATABASE_URL', 'sqlite://'),
|
||||
group='database')
|
||||
db_api.setup_db()
|
||||
self.addCleanup(db_api.drop_db)
|
||||
|
@ -15,7 +15,6 @@ testrepository>=0.0.18 # Apache-2.0/BSD
|
||||
testtools>=1.4.0 # MIT
|
||||
bandit>=1.1.0 # Apache-2.0
|
||||
gabbi==1.35.1
|
||||
pifpaf==0.10.0
|
||||
pytest-html==1.16.0
|
||||
|
||||
# NOTE(fmontei): The requirement below is only included because readthedocs
|
||||
|
39
tools/unit-tests.sh
Executable file
39
tools/unit-tests.sh
Executable file
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Script for setting up temporary PostgreSQL database for testing unit tests
|
||||
# against.
|
||||
|
||||
function cleanup {
|
||||
sudo docker stop $POSTGRES_ID
|
||||
}
|
||||
|
||||
trap cleanup EXIT
|
||||
|
||||
|
||||
POSTGRES_ID=$(
|
||||
sudo docker run \
|
||||
--detach \
|
||||
--publish :5432 \
|
||||
-e POSTGRES_DB=deckhand \
|
||||
-e POSTGRES_USER=$(whoami) \
|
||||
-e POSTGRES_PASSWORD=password \
|
||||
postgres:9.5
|
||||
)
|
||||
|
||||
POSTGRES_IP=$(
|
||||
sudo docker inspect \
|
||||
--format='{{ .NetworkSettings.Networks.bridge.IPAddress }}' \
|
||||
$POSTGRES_ID
|
||||
)
|
||||
|
||||
# Used by unit tests to interact with DB.
|
||||
export DATABASE_URL=postgresql+psycopg2://$(whoami):password@$POSTGRES_IP:5432/deckhand
|
||||
|
||||
set -e
|
||||
posargs=$@
|
||||
if [ ${#posargs} -ge 1 ]; then
|
||||
ostestr --concurrency 1 --regex ${posargs}
|
||||
else
|
||||
ostestr --concurrency 1
|
||||
fi
|
||||
set +e
|
6
tox.ini
6
tox.ini
@ -24,10 +24,9 @@ commands =
|
||||
ostestr '{posargs}'
|
||||
|
||||
[testenv:py27-postgresql]
|
||||
#package required in ubuntu: libpq-dev
|
||||
commands =
|
||||
{[testenv]commands}
|
||||
pifpaf run postgresql -- '{toxinidir}'/tools/pretty_tox.sh '--concurrency=1 {posargs}'
|
||||
{toxinidir}/tools/unit-tests.sh '{posargs}'
|
||||
|
||||
[testenv:py35]
|
||||
commands =
|
||||
@ -35,10 +34,9 @@ commands =
|
||||
ostestr '{posargs}'
|
||||
|
||||
[testenv:py35-postgresql]
|
||||
#package required in ubuntu: libpq-dev
|
||||
commands =
|
||||
{[testenv]commands}
|
||||
pifpaf run postgresql -- '{toxinidir}'/tools/pretty_tox.sh '--concurrency=1 {posargs}'
|
||||
{toxinidir}/tools/unit-tests.sh '{posargs}'
|
||||
|
||||
[testenv:functional]
|
||||
usedevelop = True
|
||||
|
Loading…
x
Reference in New Issue
Block a user