Fix full database test script to not fail randomly

- Switches database schema creation to alembic, which solves the MySQL issue (and makes sure we test migrations as well)
- Adds a few time.sleep(1) to work around MySQL's second-precision issue when adding items to queues and then immediately retrieving them
- Disables the storage proxy tests when running against non-SQLite databases, as it causes failures with the multiple process and multiple transactions
- Changes initdb to support only populating the database, as well as fixing a few small items around the test data when working with non-SQLite data
This commit is contained in:
Joseph Schorr 2016-11-30 16:54:04 -05:00
parent 244bf2a070
commit e6ee538e15
5 changed files with 41 additions and 19 deletions

View file

@ -4,7 +4,7 @@ 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.
# Sleep for 10s to get MySQL get started.
echo 'Sleeping for 10...'
sleep 10
@ -21,9 +21,9 @@ 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
# Sleep for 10s to get SQL get started.
echo 'Sleeping for 10...'
sleep 10
# 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'
@ -35,20 +35,23 @@ down_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
# Initialize the database with schema.
PYTHONPATH=. TEST_DATABASE_URI=$1 TEST=true alembic upgrade head
# Run the full test suite.
SKIP_DB_SCHEMA=true TEST_DATABASE_URI=$1 TEST=true python -m unittest discover -f
}
# NOTE: MySQL is currently broken on setup.
# Test (and generate, if requested) via MySQL.
#echo '> Starting MySQL'
#up_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
echo '> Running Full Test Suite (mysql)'
set +e
run_tests "mysql+pymysql://root:password@192.168.99.100/genschema"
set -e
down_mysql
# Test via Postgres.
echo '> Starting Postgres'