]> granicus.if.org Git - pgbouncer/commitdiff
Rewrite test_server_connect_timeout_establish using pre_auth_delay
authorPeter Eisentraut <peter@eisentraut.org>
Thu, 1 Aug 2019 07:03:28 +0000 (09:03 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Thu, 1 Aug 2019 07:11:21 +0000 (09:11 +0200)
This avoids having to deal with strange behaviors and portability
issues from netcat.

Since ALTER SYSTEM is being used, this now requires at least
PostgreSQL 9.4 for the test.

test/ssl/test.ini
test/ssl/test.sh
test/test.ini
test/test.sh

index 029920c0ea2802ff340f86c0d5d0b05c24d6c7eb..a3aa2477716c2f68ece421fc816c444e712ae71a 100644 (file)
@@ -3,7 +3,6 @@
 
 p0 = port=6666 host=localhost dbname=p0 user=bouncer pool_size=2
 p1 = port=6666 host=localhost dbname=p1 user=bouncer
-p2 = port=6668 host=localhost dbname=p2 user=bouncer
 
 ;; Configuation section
 [pgbouncer]
index fabd15b20a9047c6b0501ab55bee5af7efc479ac..35c57c4dd9e6218e659c07c68feeade085d196b2 100755 (executable)
@@ -24,7 +24,6 @@ BOUNCER_PORT=`sed -n '/^listen_port/s/listen_port.*=[^0-9]*//p' $BOUNCER_INI`
 BOUNCER_EXE="../../pgbouncer"
 
 LOGDIR=tmp
-NC_PORT=6668
 PG_PORT=6666
 PG_LOG=$LOGDIR/pg.log
 
index 374bc26c334d5b5d6f5a7eb0b1c93e8752ba21d2..7355d720f94053f89841c98d44dd3bf32ae44c32 100644 (file)
@@ -3,7 +3,6 @@
 
 p0 = port=6666 host=127.0.0.1 dbname=p0 user=bouncer pool_size=2
 p1 = port=6666 host=127.0.0.1 dbname=p1 user=bouncer
-p2 = port=6668 host=127.0.0.1 dbname=p2 user=bouncer
 p3 = port=6666 host=127.0.0.1 dbname=p0 user=bouncer pool_mode=session
 
 authdb = port=6666 host=127.0.0.1 dbname=p1 auth_user=pswcheck
index 6877d228807f69110cb55e55eb70932f929ed01b..67f22fbbc01280f9f8a93cc1d6b3030e10d44708 100755 (executable)
@@ -19,7 +19,6 @@ BOUNCER_PORT=`sed -n '/^listen_port/s/listen_port.*=[^0-9]*//p' $BOUNCER_INI`
 BOUNCER_EXE="../pgbouncer"
 
 LOGDIR=log
-NC_PORT=6668
 PG_PORT=6666
 PG_LOG=$LOGDIR/pg.log
 
@@ -68,7 +67,7 @@ Linux)
 esac
 
 stopit() {
-       test -f "$1" && { kill `cat "$1"`; rm -f "$1"; }
+       test -f "$1" && { kill `head -n1 "$1"`; rm -f "$1"; }
 }
 
 stopit test.pid
@@ -263,27 +262,23 @@ test_server_login_retry() {
        return $rc
 }
 
-# server_connect_timeout - uses netcat to start dummy server
+# server_connect_timeout
 test_server_connect_timeout_establish() {
-       which nc >/dev/null || return 1
-       if nc -h 2>&1 | grep -q 'nc -l -p port'; then
-               # traditional or GNU style
-               set -- nc -l -p $NC_PORT
-       else
-               # BSD style
-               set -- nc -l $NC_PORT
-       fi
-       echo "$@"
-       "$@" >/dev/null &
-       sleep 2
+       psql -X -p $PG_PORT -c "alter system set pre_auth_delay to '60s'" p0
+       kill -HUP `head -n1 pgdata/postmaster.pid`
+       sleep 1
 
        admin "set query_timeout=3"
        admin "set server_connect_timeout=2"
-       psql -X -c "select now()" p2
+       psql -X -c "select now()" p0
        # client will always see query_timeout, need to grep for connect timeout
        grep "closing because: connect timeout" $BOUNCER_LOG
        rc=$?
-       killall nc
+
+       rm -f pgdata/postgresql.auto.conf
+       kill -HUP `head -n1 pgdata/postmaster.pid`
+       sleep 1
+
        return $rc
 }