Tests passing for PostgreSQL 9.1. Set semantic version in filename.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
FROM postgres:9.2
|
||||
FROM postgres:9.1
|
||||
MAINTAINER Daniel Dent (https://www.danieldent.com)
|
||||
ENV PG_MAX_WAL_SENDERS 8
|
||||
ENV PG_WAL_KEEP_SEGMENTS 8
|
||||
|
||||
@@ -131,6 +131,9 @@ if [ "$1" = 'postgres' ]; then
|
||||
echo
|
||||
fi
|
||||
|
||||
# We need this health check so we know when it's started up.
|
||||
touch /tmp/.postgres_init_complete
|
||||
|
||||
exec gosu postgres "$@"
|
||||
fi
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
# Read the absolute path to the exporter
|
||||
postgres_exporter=$(readlink -f $1)
|
||||
test_binary=$(readlink -f $2)
|
||||
POSTGRES_PASSWORD=postgres
|
||||
exporter_port=9187
|
||||
exporter_password=password
|
||||
|
||||
cd $DIR
|
||||
|
||||
@@ -26,6 +26,31 @@ VERSIONS=( \
|
||||
9.6 \
|
||||
)
|
||||
|
||||
wait_for_replicated_postgres() {
|
||||
local CONTAINER_NAME=$1
|
||||
if [ -z $CONTAINER_NAME ]; then
|
||||
echo "No container name specified." 1>&2
|
||||
exit 1
|
||||
fi
|
||||
local WAIT_START=$(date +%s)
|
||||
echo "Waiting for postgres to initialize..."
|
||||
while ! docker exec $CONTAINER_NAME bash -c "test -e /tmp/.postgres_init_complete" ; do
|
||||
if [ $(( $(date +%s) - $WAIT_START )) -gt $TIMEOUT ]; then
|
||||
echo "Timed out waiting for postgres!" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
echo "Waiting for postgres to start..."
|
||||
while ! docker exec $CONTAINER_NAME bash -c "psql -U postgres -c \"select 'running'\" > /dev/null 2>&1 " ; do
|
||||
if [ $(( $(date +%s) - $WAIT_START )) -gt $TIMEOUT ]; then
|
||||
echo "Timed out waiting for postgres!" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
wait_for_postgres() {
|
||||
local CONTAINER_NAME=$1
|
||||
if [ -z $CONTAINER_NAME ]; then
|
||||
@@ -63,12 +88,17 @@ smoketest_postgres() {
|
||||
|
||||
local CUR_IMAGE=$IMAGE_NAME:$version
|
||||
|
||||
echo "Test standalone cluster..."
|
||||
CONTAINER_NAME=$(docker run -d -e POSTGRES_PASSWORD=$POSTGRES_PASSWORD -p 127.0.0.1:55432:5432 $CUR_IMAGE)
|
||||
trap "docker logs $CONTAINER_NAME ; docker kill $CONTAINER_NAME ; docker rm $CONTAINER_NAME; exit 1" EXIT INT TERM
|
||||
echo "#######################"
|
||||
echo "Standalone Postgres $version"
|
||||
echo "#######################"
|
||||
local docker_cmd='docker run -d -e POSTGRES_PASSWORD=$POSTGRES_PASSWORD -p 127.0.0.1:55432:5432 $CUR_IMAGE'
|
||||
echo "Docker Cmd: $docker_cmd"
|
||||
|
||||
CONTAINER_NAME=$(eval $docker_cmd)
|
||||
trap "docker logs $CONTAINER_NAME ; docker kill $CONTAINER_NAME ; docker rm -v $CONTAINER_NAME; exit 1" EXIT INT TERM
|
||||
wait_for_postgres $CONTAINER_NAME
|
||||
|
||||
DATA_SOURCE_NAME="postgresql://postgres:$POSTGRES_PASSWORD@localhost:55432/?sslmode=disable" $test_binary || exit $?
|
||||
DATA_SOURCE_NAME="postgresql://postgres:$POSTGRES_PASSWORD@localhost:55432/?sslmode=disable" $test_binary --log.level=debug || exit $?
|
||||
# exporter_pid=$!
|
||||
# trap "docker logs $CONTAINER_NAME ; docker kill $CONTAINER_NAME ; docker rm $CONTAINER_NAME ; kill $exporter_pid; exit 1" EXIT INT TERM
|
||||
# wait_for_exporter
|
||||
@@ -85,7 +115,9 @@ smoketest_postgres() {
|
||||
docker rm $CONTAINER_NAME
|
||||
trap - EXIT INT TERM
|
||||
|
||||
echo "Test replicated cluster..."
|
||||
echo "#######################"
|
||||
echo "Replicated Postgres $version"
|
||||
echo "#######################"
|
||||
old_pwd=$(pwd)
|
||||
cd docker-postgres-replication
|
||||
|
||||
@@ -95,15 +127,18 @@ smoketest_postgres() {
|
||||
exit 1
|
||||
fi
|
||||
trap "docker-compose logs; docker-compose down ; docker-compose rm -v; exit 1" EXIT INT TERM
|
||||
POSTGRES_PASSWORD=$POSTGRES_PASSWORD docker-compose up -d --force-recreate --build
|
||||
local compose_cmd="POSTGRES_PASSWORD=$POSTGRES_PASSWORD docker-compose up -d --force-recreate --build"
|
||||
echo "Compose Cmd: $compose_cmd"
|
||||
eval $compose_cmd
|
||||
|
||||
master_container=$(docker-compose ps -q pg-master)
|
||||
slave_container=$(docker-compose ps -q pg-slave)
|
||||
master_ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $master_container)
|
||||
wait_for_postgres $master_container
|
||||
wait_for_postgres $slave_container
|
||||
echo "Got master IP: $master_ip"
|
||||
wait_for_replicated_postgres $master_container
|
||||
wait_for_replicated_postgres $slave_container
|
||||
|
||||
DATA_SOURCE_NAME="postgresql://postgres:$POSTGRES_PASSWORD@$master_ip:5432/?sslmode=disable" $test_binary || exit $?
|
||||
DATA_SOURCE_NAME="postgresql://postgres:$POSTGRES_PASSWORD@$master_ip:5432/?sslmode=disable" $test_binary --log.level=debug || exit $?
|
||||
# exporter_pid=$!
|
||||
# trap "docker-compose logs; docker-compose down ; docker-compose rm -v ; kill $exporter_pid; exit 1" EXIT INT TERM
|
||||
# wait_for_exporter
|
||||
|
||||
Reference in New Issue
Block a user