Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: move to containerised postgres DB
partially addresses reanahub/reana#348
- Loading branch information
1 parent
82e0f9f
commit 2656ee5
Showing
7 changed files
with
73 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,72 @@ | ||
#!/bin/sh | ||
#!/bin/bash | ||
# | ||
# This file is part of REANA. | ||
# Copyright (C) 2017, 2018, 2019 CERN. | ||
# Copyright (C) 2017, 2018, 2019, 2020 CERN. | ||
# | ||
# REANA is free software; you can redistribute it and/or modify it | ||
# under the terms of the MIT License; see LICENSE file for more details. | ||
|
||
pydocstyle reana_workflow_controller && \ | ||
black --check . && \ | ||
FLASK_APP=reana_workflow_controller/app.py python ./scripts/generate_openapi_spec.py && \ | ||
diff -q -w temp_openapi.json docs/openapi.json && \ | ||
check-manifest --ignore ".travis-*" && \ | ||
sphinx-build -qnN docs docs/_build/html && \ | ||
python setup.py test && \ | ||
# Quit on errors | ||
set -o errexit | ||
|
||
# Quit on unbound symbols | ||
set -o nounset | ||
|
||
export REANA_SQLALCHEMY_DATABASE_URI=postgresql+psycopg2://postgres:mysecretpassword@localhost/postgres | ||
|
||
# Verify that db container is running before continuing | ||
_check_ready() { | ||
RETRIES=40 | ||
while ! $2 | ||
do | ||
echo "==> [INFO] Waiting for $1, $((RETRIES--)) remaining attempts..." | ||
sleep 2 | ||
if [ $RETRIES -eq 0 ] | ||
then | ||
echo "==> [ERROR] Couldn't reach $1" | ||
exit 1 | ||
fi | ||
done | ||
} | ||
|
||
_db_check() { | ||
docker exec --user postgres reana-postgres bash -c "pg_isready" &>/dev/null; | ||
} | ||
|
||
clean_old_db_container() { | ||
OLD="$(docker ps --all --quiet --filter=name=reana-postgres)" | ||
if [ -n "$OLD" ]; then | ||
echo '==> [INFO] Cleaning old DB container...' | ||
docker stop reana-postgres | ||
fi | ||
} | ||
|
||
start_db_container() { | ||
echo '==> [INFO] Starting DB container...' | ||
docker run --rm --name reana-postgres -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -d postgres:9.6.2 | ||
_check_ready "Postgres" _db_check | ||
} | ||
|
||
stop_db_container() { | ||
echo '==> [INFO] Stopping DB container...' | ||
docker stop reana-postgres | ||
} | ||
|
||
check_black() { | ||
echo '==> [INFO] Checking Black compliance...' | ||
black --check . | ||
} | ||
|
||
pydocstyle reana_workflow_controller | ||
check_black | ||
FLASK_APP=reana_workflow_controller/app.py python ./scripts/generate_openapi_spec.py | ||
diff -q -w temp_openapi.json docs/openapi.json | ||
check-manifest --ignore ".travis-*" | ||
sphinx-build -qnNW docs docs/_build/html | ||
clean_old_db_container | ||
start_db_container | ||
python setup.py test | ||
stop_db_container | ||
sphinx-build -qnNW -b doctest docs docs/_build/doctest | ||
docker build -t reanahub/reana-workflow-controller . | ||
echo '==> [INFO] All tests passed! ✅' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters