From: Peter Eisentraut Date: Thu, 26 Jul 2018 11:56:30 +0000 (+0200) Subject: test.sh: Sort out netcat zoo X-Git-Tag: pgbouncer_1_9_0~18 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d9bb905fa5939bf21969717a1b0dc5c7d53f844e;p=pgbouncer test.sh: Sort out netcat zoo The previous code distinguished between Linux and non-Linux netcat. This didn't stand the test of time, since Linux distributions now ship multiple variants of netcat and other operating systems also provide multiple options. So instead try to detect the variant from the help output. Also, the previous uses of the -q and -w options behaved strangely with some versions and/or were inconsistent with the documentation. So abandon those options and just rely on the existing killall call. The test_server_connect_timeout_establish test should now pass again on hopefully most configurations. --- diff --git a/test/test.sh b/test/test.sh index b1d16ff..00dc62c 100755 --- a/test/test.sh +++ b/test/test.sh @@ -61,11 +61,9 @@ fi # System configuration checks SED_ERE_OP='-E' -NC_WAIT_OP='-w 5' case `uname` in Linux) SED_ERE_OP='-r' - NC_WAIT_OP='-q 5' ;; esac @@ -237,17 +235,23 @@ test_server_login_retry() { # server_connect_timeout - uses netcat to start dummy server test_server_connect_timeout_establish() { which nc >/dev/null || return 1 - - echo nc $NC_WAIT_OP -l $NC_PORT - nc $NC_WAIT_OP -l $NC_PORT >/dev/null & + 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 + admin "set query_timeout=3" admin "set server_connect_timeout=2" psql -X -c "select now()" p2 # client will always see query_timeout, need to grep for connect timeout grep "closing because: connect timeout" $BOUNCER_LOG rc=$? - # didnt seem to die otherwise killall nc return $rc }