From 2f0d5796e38864926e5ae2a83ce6efd9a6f60578 Mon Sep 17 00:00:00 2001 From: Felipe Monteiro Date: Fri, 12 Jan 2018 03:28:49 +0000 Subject: [PATCH] Revert fix pifpaf run postgresql failing This reverts https://review.gerrithub.io/#/c/393980/ which was a temporary workaround to unblock the Deckhand gate. pifpaf should be used to run unit tests as having to install Docker just to kick off unit tests is excessive. However, the unit-tests.sh script is maintained in tools/ directory as a fallback. Change-Id: I24a10d4b3ea00006004f27d0086719fb0bf86dd9 --- deckhand/tests/unit/base.py | 6 ++++-- test-requirements.txt | 1 + tools/functional-tests.sh | 3 +++ tools/unit-tests.sh | 3 ++- tox.ini | 4 ++-- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/deckhand/tests/unit/base.py b/deckhand/tests/unit/base.py index 5e9e7f9f..fec6514a 100644 --- a/deckhand/tests/unit/base.py +++ b/deckhand/tests/unit/base.py @@ -105,8 +105,10 @@ class DeckhandWithDBTestCase(DeckhandTestCase): def setUp(self): super(DeckhandWithDBTestCase, self).setUp() + if 'PIFPAF_URL' not in os.environ: + raise RuntimeError('Unit tests must be run using `pifpaf run ' + 'postgresql`.') self.override_config( - 'connection', os.environ.get('DATABASE_URL', 'sqlite://'), - group='database') + 'connection', os.environ['PIFPAF_URL'], group='database') db_api.setup_db() self.addCleanup(db_api.drop_db) diff --git a/test-requirements.txt b/test-requirements.txt index 29ab492e..45e0ed13 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -16,6 +16,7 @@ testtools>=1.4.0 # MIT bandit>=1.1.0 # Apache-2.0 gabbi==1.35.1 pytest-html==1.16.0 +pifpaf==2.0.0 # NOTE(fmontei): The requirement below is only included because readthedocs # depends on it to work, since it runs pip install -rtest-requirements.txt. diff --git a/tools/functional-tests.sh b/tools/functional-tests.sh index a32600ce..5833b7e5 100755 --- a/tools/functional-tests.sh +++ b/tools/functional-tests.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash +# Script intended for running Deckhand functional tests via gabbi. Requires +# Docker CE (at least) to run. + # Meant for capturing output of Deckhand image. This requires that logging # in the image be set up to pipe everything out to stdout/stderr. STDOUT=$(mktemp) diff --git a/tools/unit-tests.sh b/tools/unit-tests.sh index 92836f69..cf710c6e 100755 --- a/tools/unit-tests.sh +++ b/tools/unit-tests.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash # Script for setting up temporary PostgreSQL database for testing unit tests -# against. +# against. Requires Docker CE (at least) to be executed. Fallback in case +# `pifpaf` fails. function cleanup { sudo docker stop $POSTGRES_ID diff --git a/tox.ini b/tox.ini index 702e9a2d..4e1342e3 100644 --- a/tox.ini +++ b/tox.ini @@ -21,12 +21,12 @@ commands = [testenv:py27] commands = {[testenv]commands} - {toxinidir}/tools/unit-tests.sh '{posargs}' + pifpaf run postgresql -- '{toxinidir}'/tools/pretty_tox.sh '--concurrency=1 {posargs}' [testenv:py35] commands = {[testenv]commands} - {toxinidir}/tools/unit-tests.sh '{posargs}' + pifpaf run postgresql -- '{toxinidir}'/tools/pretty_tox.sh '--concurrency=1 {posargs}' [testenv:functional] usedevelop = True