Commit 02d23461 authored by Christoph Berg's avatar Christoph Berg

Simplify test

parent 98983ab6
#!/bin/sh
# autopkgtest script for pgbouncer: starts a pgbouncer instance and connects
# through it to a postgres server running on port 5432
# autopkgtest's TMPDIR is not readable for postgres
unset TMPDIR
if [ -z "$WRAPPED" ]; then
WRAPPED=1 pg_virtualenv $0 "$@"
exit
fi
# don't call systemctl, so that we stay within the pg_virtualenv
# otherwise pgbouncer will run and create its socket outside
export _SYSTEMCTL_SKIP_REDIRECT=true
/etc/init.d/pgbouncer stop
set -e
# prepare cleanup at exit
CLEAN_FILES="/etc/pgbouncer/pgbouncer.ini /etc/pgbouncer/userlist.txt /etc/default/pgbouncer"
CLEAN_FILES="/etc/pgbouncer/pgbouncer.ini /etc/pgbouncer/userlist.txt"
cleanup () {
if [ "$PGVERSION" ]; then
pg_ctlcluster $PGVERSION regress stop -m f || :
pg_dropcluster $PGVERSION regress || :
fi
/etc/init.d/pgbouncer stop || :
rm -f /etc/pgbouncer/userlist.txt output
for f in $CLEAN_FILES; do
test -f $f.adt-save && mv -f $f.adt-save $f
done
rm -f /etc/pgbouncer/userlist.txt output
}
trap cleanup 0 2 3 15
# create PostgreSQL cluster
if [ -z "$(pg_lsclusters -h)" ]; then
PGVERSION=$(/usr/share/postgresql-common/supported-versions | tail -n1)
pg_createcluster $PGVERSION regress --start
fi
# set up minimal pgbouncer config
sed -i.adt-save -e '/\[databases\]/ apostgres =' /etc/pgbouncer/pgbouncer.ini
test -e /etc/pgbouncer/userlist.txt &&
cp -a /etc/pgbouncer/userlist.txt /etc/pgbouncer/userlist.txt.adt-save
echo "\"$PGUSER\" \"$PGPASSWORD\"" >> /etc/pgbouncer/userlist.txt
sed -i.adt-save -e 's/START=0/START=1/' /etc/default/pgbouncer
echo "\"postgres\" \"postgres\"" >> /etc/pgbouncer/userlist.txt
# start pgbouncer and test connection
/etc/init.d/pgbouncer start
echo "Trying simple SELECT ..."
result=$(psql -p 6432 -d postgres -c "SELECT 1+2" -tA)
result=$(psql -p 6432 -d postgres -U postgres -c "SELECT 1+2" -tA)
echo "$result"
[ "$result" = "3" ]
echo "Result OK"
......@@ -51,7 +45,7 @@ echo "Trying online restart ..."
/etc/init.d/pgbouncer restart > /dev/null
sleep 1
echo "SELECT 5+6;"
) | psql -p 6432 -d postgres -tA > output
) | psql -p 6432 -U postgres -d postgres -tA > output
cat output
[ "$(cat output)" = "7
11" ]
......
Tests: connect
Depends: @, postgresql
Depends: @, postgresql, postgresql-server-dev-all
Restrictions: needs-root
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment