scripts: use postgres script with all tests (#3404)

This commit is contained in:
Michal Niewrzal 2019-10-31 07:03:54 -07:00 committed by GitHub
parent 015350e230
commit acc7b116aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 23 deletions

View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source $SCRIPTDIR/../../scripts/postgres-dev.sh
$SCRIPTDIR/test-sim.sh

25
scripts/postgres-dev.sh Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
LOG_FILE=${STORJ_SIM_POSTGRES_LOG:-"storj-sim-postgres.log"}
CONTAINER_NAME=storj_sim_postgres
cleanup(){
docker rm -f $CONTAINER_NAME
}
trap cleanup EXIT
docker run --rm -d -p 5433:5432 --name $CONTAINER_NAME postgres:9.6 -c log_min_duration_statement=0
docker logs -f $CONTAINER_NAME > $LOG_FILE 2>&1 &
STORJ_SIM_DATABASE=${STORJ_SIM_DATABASE:-"teststorj"}
RETRIES=10
until docker exec $CONTAINER_NAME psql -h localhost -U postgres -d postgres -c "select 1" > /dev/null 2>&1 || [ $RETRIES -eq 0 ]; do
echo "Waiting for postgres server, $((RETRIES--)) remaining attempts..."
sleep 1
done
docker exec $CONTAINER_NAME psql -h localhost -U postgres -c "create database $STORJ_SIM_DATABASE;"
export STORJ_SIM_POSTGRES="postgres://postgres@localhost:5433/$STORJ_SIM_DATABASE?sslmode=disable"

View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source $SCRIPTDIR/postgres-dev.sh
$SCRIPTDIR/test-sim-backwards.sh

View File

@ -2,28 +2,6 @@
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
LOG_FILE=${STORJ_SIM_POSTGRES_LOG:-"storj-sim-postgres.log"} source $SCRIPTDIR/postgres-dev.sh
CONTAINER_NAME=storj_sim_postgres
cleanup(){
docker rm -f $CONTAINER_NAME
}
trap cleanup EXIT
docker run --rm -d -p 5433:5432 --name $CONTAINER_NAME postgres:9.6 -c log_min_duration_statement=0
docker logs -f $CONTAINER_NAME > $LOG_FILE 2>&1 &
STORJ_SIM_DATABASE=${STORJ_SIM_DATABASE:-"teststorj"}
RETRIES=10
until docker exec $CONTAINER_NAME psql -h localhost -U postgres -d postgres -c "select 1" > /dev/null 2>&1 || [ $RETRIES -eq 0 ]; do
echo "Waiting for postgres server, $((RETRIES--)) remaining attempts..."
sleep 1
done
docker exec $CONTAINER_NAME psql -h localhost -U postgres -c "create database $STORJ_SIM_DATABASE;"
export STORJ_SIM_POSTGRES="postgres://postgres@localhost:5433/$STORJ_SIM_DATABASE?sslmode=disable"
$SCRIPTDIR/test-sim.sh $SCRIPTDIR/test-sim.sh