forked from pypi/warehouse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: run postgres via pytest (pypi#15365)
Co-authored-by: Ee Durbin <ewdurbin@gmail.com>
- Loading branch information
1 parent
150e137
commit 51d7c35
Showing
8 changed files
with
26 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ node_modules/ | |
dev/example.sql | ||
dev/prod.sql | ||
dev/prod.sql.xz | ||
dev/.coverage | ||
./data/ | ||
|
||
warehouse/.commit | ||
|
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,38 +1,6 @@ | ||
#!/bin/bash | ||
set -e | ||
set -ex | ||
|
||
# Click requires us to ensure we have a well configured environment to run | ||
# our click commands. So we'll set our environment to ensure our locale is | ||
# correct. | ||
export LC_ALL="${ENCODING:-en_US.UTF-8}" | ||
export LANG="${ENCODING:-en_US.UTF-8}" | ||
|
||
COMMAND_ARGS="$@" | ||
|
||
# Test the postgres connection | ||
while [ $# -gt 0 ]; do | ||
case $1 in | ||
"--postgresql-host") POSTGRES_HOST="$2" | ||
esac | ||
shift | ||
done | ||
|
||
# Test the postgres connection | ||
ATTEMPTS=0 | ||
until [ $ATTEMPTS -eq 5 ] || pg_isready -t 10 -h $POSTGRES_HOST; do | ||
>&2 echo "Postgres is unavailable, sleeping" | ||
sleep $(( ATTEMPTS++ )) | ||
done | ||
|
||
if [ $ATTEMPTS -eq 5 ]; then | ||
>&2 echo "Postgres is unavailable, exiting" | ||
exit 1 | ||
fi | ||
|
||
# Print all the following commands | ||
set -x | ||
|
||
# Actually run our tests. | ||
python -m coverage run -m pytest --strict-markers $COMMAND_ARGS | ||
python -m coverage run -m pytest --strict-markers "$@" | ||
python -m coverage html --show-contexts | ||
python -m coverage report -m --fail-under 100 |
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