Fix the errors introduced into smoke-test from the refactor.
This commit is contained in:
parent
ae8bea6eb8
commit
99ff02c6a9
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/bash -x
|
||||||
# Basic integration tests with postgres. Requires docker to work.
|
# Basic integration tests with postgres. Requires docker to work.
|
||||||
|
|
||||||
SOURCE="${BASH_SOURCE[0]}"
|
SOURCE="${BASH_SOURCE[0]}"
|
||||||
|
@ -38,12 +38,12 @@ VERSIONS=( \
|
||||||
wait_for_postgres(){
|
wait_for_postgres(){
|
||||||
local ip=$1
|
local ip=$1
|
||||||
local port=$2
|
local port=$2
|
||||||
if [ -z $ip ]; then
|
if [ -z "$ip" ]; then
|
||||||
echo "No IP specified." 1>&2
|
echo "No IP specified." 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z $port ]; then
|
if [ -z "$port" ]; then
|
||||||
echo "No port specified." 1>&2
|
echo "No port specified." 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -51,26 +51,28 @@ wait_for_postgres(){
|
||||||
local wait_start
|
local wait_start
|
||||||
wait_start=$(date +%s) || exit 1
|
wait_start=$(date +%s) || exit 1
|
||||||
echo "Waiting for postgres to start listening..."
|
echo "Waiting for postgres to start listening..."
|
||||||
while ! pg_isready --host=$ip --port=$port &> /dev/null; do
|
while ! pg_isready --host="$ip" --port="$port" &> /dev/null; do
|
||||||
if [ $(( $(date +%s) - $wait_start )) -gt $TIMEOUT ]; then
|
if [ $(( $(date +%s) - wait_start )) -gt "$TIMEOUT" ]; then
|
||||||
echo "Timed out waiting for postgres to start!" 1>&2
|
echo "Timed out waiting for postgres to start!" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
echo "Postgres is online at $ip:$port"
|
||||||
}
|
}
|
||||||
|
|
||||||
wait_for_exporter() {
|
wait_for_exporter() {
|
||||||
local wait_start
|
local wait_start
|
||||||
wait_start=$(date +%s) || exit 1
|
wait_start=$(date +%s) || exit 1
|
||||||
echo "Waiting for exporter to start..."
|
echo "Waiting for exporter to start..."
|
||||||
while ! nc -z localhost $exporter_port ; do
|
while ! nc -z localhost "$exporter_port" ; do
|
||||||
if [ $(( $(date +%s) - $wait_start )) -gt $TIMEOUT ]; then
|
if [ $(( $(date +%s) - wait_start )) -gt "$TIMEOUT" ]; then
|
||||||
echo "Timed out waiting for exporter!" 1>&2
|
echo "Timed out waiting for exporter!" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
echo "Exporter is online at localhost:$exporter_port"
|
||||||
}
|
}
|
||||||
|
|
||||||
smoketest_postgres() {
|
smoketest_postgres() {
|
||||||
|
@ -89,22 +91,24 @@ smoketest_postgres() {
|
||||||
|
|
||||||
CONTAINER_NAME=$($docker_cmd)
|
CONTAINER_NAME=$($docker_cmd)
|
||||||
standalone_ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $CONTAINER_NAME)
|
standalone_ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $CONTAINER_NAME)
|
||||||
|
# shellcheck disable=SC2064
|
||||||
trap "docker logs $CONTAINER_NAME ; docker kill $CONTAINER_NAME ; docker rm -v $CONTAINER_NAME; exit 1" EXIT INT TERM
|
trap "docker logs $CONTAINER_NAME ; docker kill $CONTAINER_NAME ; docker rm -v $CONTAINER_NAME; exit 1" EXIT INT TERM
|
||||||
wait_for_postgres $standalone_ip 5432
|
wait_for_postgres "$standalone_ip" 5432
|
||||||
|
|
||||||
|
|
||||||
# Run the test binary.
|
# Run the test binary.
|
||||||
DATA_SOURCE_NAME="postgresql://postgres:$POSTGRES_PASSWORD@$standalone_ip:5432/?sslmode=disable" $test_binary || exit $?
|
DATA_SOURCE_NAME="postgresql://postgres:$POSTGRES_PASSWORD@$standalone_ip:5432/?sslmode=disable" $test_binary || exit $?
|
||||||
|
|
||||||
# Extract a raw metric list.
|
# Extract a raw metric list.
|
||||||
DATA_SOURCE_NAME="postgresql://postgres:$POSTGRES_PASSWORD@$standalone_ip:5432/?sslmode=disable" $postgres_exporter --log.level=debug --web.listen-address=:$exporter_port &
|
DATA_SOURCE_NAME="postgresql://postgres:$POSTGRES_PASSWORD@$standalone_ip:5432/?sslmode=disable" $postgres_exporter \
|
||||||
|
--log.level=debug --web.listen-address=:$exporter_port &
|
||||||
exporter_pid=$!
|
exporter_pid=$!
|
||||||
|
# shellcheck disable=SC2064
|
||||||
trap "docker logs $CONTAINER_NAME ; docker kill $CONTAINER_NAME ; docker rm -v $CONTAINER_NAME; kill $exporter_pid; exit 1" EXIT INT TERM
|
trap "docker logs $CONTAINER_NAME ; docker kill $CONTAINER_NAME ; docker rm -v $CONTAINER_NAME; kill $exporter_pid; exit 1" EXIT INT TERM
|
||||||
wait_for_exporter
|
wait_for_exporter
|
||||||
|
|
||||||
# Dump the metrics to a file.
|
# Dump the metrics to a file.
|
||||||
if wget -q -O - http://localhost:$exporter_port/metrics 1> "$METRICS_DIR/.metrics.single.$version.prom" ; then
|
if ! wget -q -O - http://localhost:$exporter_port/metrics 1> "$METRICS_DIR/.metrics.single.$version.prom" ; then
|
||||||
echo "Failed on postgres $version ($DOCKER_IMAGE)" 1>&2
|
echo "Failed on postgres $version (standalone $DOCKER_IMAGE)" 1>&2
|
||||||
kill $exporter_pid
|
kill $exporter_pid
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -117,8 +121,8 @@ smoketest_postgres() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
kill $exporter_pid
|
kill $exporter_pid
|
||||||
docker kill $CONTAINER_NAME
|
docker kill "$CONTAINER_NAME"
|
||||||
docker rm -v $CONTAINER_NAME
|
docker rm -v "$CONTAINER_NAME"
|
||||||
trap - EXIT INT TERM
|
trap - EXIT INT TERM
|
||||||
|
|
||||||
echo "#######################"
|
echo "#######################"
|
||||||
|
@ -127,7 +131,7 @@ smoketest_postgres() {
|
||||||
old_pwd=$(pwd)
|
old_pwd=$(pwd)
|
||||||
cd docker-postgres-replication || exit 1
|
cd docker-postgres-replication || exit 1
|
||||||
|
|
||||||
if VERSION="$version" p2 -t Dockerfile.p2 -o Dockerfile ; then
|
if ! VERSION="$version" p2 -t Dockerfile.p2 -o Dockerfile ; then
|
||||||
echo "Templating failed" 1>&2
|
echo "Templating failed" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -146,14 +150,15 @@ smoketest_postgres() {
|
||||||
|
|
||||||
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 || exit $?
|
||||||
|
|
||||||
DATA_SOURCE_NAME="postgresql://postgres:$POSTGRES_PASSWORD@$master_ip:5432/?sslmode=disable" $postgres_exporter --log.level=debug --web.listen-address=:$exporter_port &
|
DATA_SOURCE_NAME="postgresql://postgres:$POSTGRES_PASSWORD@$master_ip:5432/?sslmode=disable" $postgres_exporter \
|
||||||
|
--log.level=debug --web.listen-address=:$exporter_port &
|
||||||
exporter_pid=$!
|
exporter_pid=$!
|
||||||
# shellcheck disable=SC2064
|
# shellcheck disable=SC2064
|
||||||
trap "docker-compose logs; docker-compose down ; docker-compose rm -v ; kill $exporter_pid; exit 1" EXIT INT TERM
|
trap "docker-compose logs; docker-compose down ; docker-compose rm -v ; kill $exporter_pid; exit 1" EXIT INT TERM
|
||||||
wait_for_exporter
|
wait_for_exporter
|
||||||
|
|
||||||
if wget -q -O - http://localhost:$exporter_port/metrics 1> "$METRICS_DIR/.metrics.replicated.$version.prom" ; then
|
if ! wget -q -O - http://localhost:$exporter_port/metrics 1> "$METRICS_DIR/.metrics.replicated.$version.prom" ; then
|
||||||
echo "Failed on postgres $version ($DOCKER_IMAGE)" 1>&2
|
echo "Failed on postgres $version (replicated $DOCKER_IMAGE)" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue