This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/test/fulldbtest.sh
2015-11-24 12:44:07 -05:00

61 lines
1.6 KiB
Bash
Executable file

set -e
up_mysql() {
# Run a SQL database on port 3306 inside of Docker.
docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password -d mysql
# Sleep for 5s to get MySQL get started.
echo 'Sleeping for 10...'
sleep 10
# Add the database to mysql.
docker run --rm --link mysql:mysql mysql sh -c 'echo "create database genschema;" | mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -ppassword'
}
down_mysql() {
docker kill mysql
docker rm -v mysql
}
up_postgres() {
# Run a SQL database on port 5432 inside of Docker.
docker run --name postgres -p 5432:5432 -d postgres
# Sleep for 5s to get SQL get started.
echo 'Sleeping for 5...'
sleep 5
# Add the database to postgres.
docker run --rm --link postgres:postgres postgres sh -c 'echo "create database genschema" | psql -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres'
}
down_postgres() {
docker kill postgres
docker rm -v postgres
}
run_tests() {
TEST_DATABASE_URI=$1 TEST=true python -m unittest discover -f
TEST_DATABASE_URI=$1 TEST=true python -m test.queue_threads -f
}
# NOTE: MySQL is currently broken on setup.
# Test (and generate, if requested) via MySQL.
#echo '> Starting MySQL'
#up_mysql
#echo '> Running Full Test Suite (mysql)'
#set +e
#run_tests "mysql+pymysql://root:password@127.0.0.1/genschema"
#set -e
#down_mysql
# Test via Postgres.
echo '> Starting Postgres'
up_postgres
echo '> Running Full Test Suite (postgres)'
set +e
run_tests "postgresql://postgres@192.168.99.100/genschema"
set -e
down_postgres