9cae8f3b2b
stestr is actively maintained. OpenStack is migrating to stestr, so we should follow suit. Change-Id: I1b958681cbf53281c9da91c747c9a2cfe2beccf3
41 lines
895 B
Bash
Executable File
41 lines
895 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Script for setting up temporary PostgreSQL database for testing unit tests
|
|
# against. Requires Docker CE (at least) to be executed. Fallback in case
|
|
# `pifpaf` fails.
|
|
|
|
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
|
|
stestr run --concurrency=1 ${posargs}
|
|
else
|
|
stestr run --concurrency=1
|
|
fi
|
|
set +e
|