From 362ade395374c63ba0f973af5c3ddac4949063a2 Mon Sep 17 00:00:00 2001 From: Tatsuo Ishii Date: Thu, 23 Aug 2018 21:12:29 +0900 Subject: [PATCH] Unbreak pgpool_setup and regression tests against pre-10 PostgreSQL. Commit 26446126f36dcd34ea9032ac934aafe63acc0eee broke pgpool_setup and regression tests against pre-10 PostgreSQL because they unconditionally use feature introduced in PostgreSQL 10, i.e. SCRAM authentication. To fix this, check PostgreSQL version using initdb -v and not use PostgreSQL 10 specific feature if PostgreSQL 9.6 or earlier is used. In this case regression tests 020, 021 and 022 always success. --- src/test/pgpool_setup | 31 ++++++++++++++----- src/test/regression/regress.sh | 12 ++++--- .../test.sh | 6 ++++ .../tests/021.pool_passwd_auth/test.sh | 6 ++++ .../022.pool_passwd_alternative_auth/test.sh | 6 ++++ 5 files changed, 48 insertions(+), 13 deletions(-) diff --git a/src/test/pgpool_setup b/src/test/pgpool_setup index e4a314523..7baf456e9 100755 --- a/src/test/pgpool_setup +++ b/src/test/pgpool_setup @@ -96,6 +96,10 @@ INITDB=$PGBIN/initdb PG_CTL=$PGBIN/pg_ctl PSQL=$PGBIN/psql +# get PostgreSQL major version +PGVERSION=`$INITDB -V|awk '{print $3}'|sed 's/\..*//'` +echo PostgreSQL major version: $PGVERSION + # pgpool-II configuration file localtion. CONF=$BASEDIR/etc/pgpool.conf # failover script @@ -313,12 +317,20 @@ function set_postgresql_conf sed -i '/host.*all.*all.*trust$/s/^/#/g' $PGHBACONF sed -i '/local.*all.*all.*trust$/s/^/#/g' $PGHBACONF - echo "host all scram_user 0/0 scram-sha-256" >> $PGHBACONF - echo "host all md5_user 0/0 md5" >> $PGHBACONF + if [ $PGVERSION -gt 9 ]; + then + echo "host all scram_user 0/0 scram-sha-256" >> $PGHBACONF + echo "host all md5_user 0/0 md5" >> $PGHBACONF + fi + echo "host all all 0/0 trust" >> $PGHBACONF - echo "local all scram_user scram-sha-256" >> $PGHBACONF - echo "local all md5_user md5" >> $PGHBACONF + if [ $PGVERSION -gt 9 ]; + then + echo "local all scram_user scram-sha-256" >> $PGHBACONF + echo "local all md5_user md5" >> $PGHBACONF + fi + echo "local all all trust" >> $PGHBACONF ed $1/pg_hba.conf <> $POOL_HBACONF - echo "host all md5_user 0/0 md5" >> $POOL_HBACONF + if [ $PGVERSION -gt 9 ]; + then + echo "host all scram_user 0/0 scram-sha-256" >> $POOL_HBACONF + echo "host all md5_user 0/0 md5" >> $POOL_HBACONF - echo "local all scram_user scram-sha-256" >> $POOL_HBACONF - echo "local all md5_user md5" >> $POOL_HBACONF + echo "local all scram_user scram-sha-256" >> $POOL_HBACONF + echo "local all md5_user md5" >> $POOL_HBACONF + fi echo "local all all trust" >> $POOL_HBACONF diff --git a/src/test/regression/regress.sh b/src/test/regression/regress.sh index 33ab36074..32f71c60b 100755 --- a/src/test/regression/regress.sh +++ b/src/test/regression/regress.sh @@ -102,16 +102,18 @@ function export_env_vars export JDBC_DRIVER=$JDBC_DRIVER export PGBENCH_PATH=$PGBENCH_PATH export PGSOCKET_DIR=$PGSOCKET_DIR + export PGVERSION=`$PGBIN/initdb -V|awk '{print $3}'|sed 's/\..*//'` } function print_info { echo ${CBLUE}"*************************"${CNORM} - echo "REGRESSION MODE : "${CBLUE}$MODE${CNORM} - echo "PGPOOL-II : "${CBLUE}$PGPOOL_PATH${CNORM} - echo "PostgreSQL bin : "${CBLUE}$PGBIN${CNORM} - echo "pgbench : "${CBLUE}$PGBENCH_PATH${CNORM} - echo "PostgreSQL jdbc : "${CBLUE}$JDBC_DRIVER${CNORM} + echo "REGRESSION MODE : "${CBLUE}$MODE${CNORM} + echo "PGPOOL-II : "${CBLUE}$PGPOOL_PATH${CNORM} + echo "PostgreSQL bin : "${CBLUE}$PGBIN${CNORM} + echo "PostgreSQL Major version : "${CBLUE}$PGVERSION${CNORM} + echo "pgbench : "${CBLUE}$PGBENCH_PATH${CNORM} + echo "PostgreSQL jdbc : "${CBLUE}$JDBC_DRIVER${CNORM} echo ${CBLUE}"*************************"${CNORM} } diff --git a/src/test/regression/tests/020.allow_clear_text_frontend_auth/test.sh b/src/test/regression/tests/020.allow_clear_text_frontend_auth/test.sh index 65109f364..4a3aa2b00 100755 --- a/src/test/regression/tests/020.allow_clear_text_frontend_auth/test.sh +++ b/src/test/regression/tests/020.allow_clear_text_frontend_auth/test.sh @@ -3,6 +3,12 @@ # test script for scram and md5 authentication test # when allow_clear_text_frontend_auth is set # + +# This test is only valid with PostgreSQL 10 or later. +if [ $PGVERSION -le 9 ];then + exit 0 +fi + source $TESTLIBS TESTDIR=testdir PSQL=$PGBIN/psql diff --git a/src/test/regression/tests/021.pool_passwd_auth/test.sh b/src/test/regression/tests/021.pool_passwd_auth/test.sh index f786244e0..bf3e292b0 100755 --- a/src/test/regression/tests/021.pool_passwd_auth/test.sh +++ b/src/test/regression/tests/021.pool_passwd_auth/test.sh @@ -3,6 +3,12 @@ # test script for scram and md5 authentication # where password is stored in pool_passwd file # + +# This test is only valid with PostgreSQL 10 or later. +if [ $PGVERSION -le 9 ];then + exit 0 +fi + source $TESTLIBS TESTDIR=testdir PSQL=$PGBIN/psql diff --git a/src/test/regression/tests/022.pool_passwd_alternative_auth/test.sh b/src/test/regression/tests/022.pool_passwd_alternative_auth/test.sh index ed8bc2296..abf134033 100755 --- a/src/test/regression/tests/022.pool_passwd_alternative_auth/test.sh +++ b/src/test/regression/tests/022.pool_passwd_alternative_auth/test.sh @@ -4,6 +4,12 @@ # where password is stored in pool_passwd file and # frontend uses different auth from backends # + +# This test is only valid with PostgreSQL 10 or later. +if [ $PGVERSION -le 9 ];then + exit 0 +fi + source $TESTLIBS TESTDIR=testdir PSQL=$PGBIN/psql -- 2.39.5