Unbreak pgpool_setup and regression tests against pre-10 PostgreSQL.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Thu, 23 Aug 2018 12:12:29 +0000 (21:12 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Thu, 23 Aug 2018 12:12:29 +0000 (21:12 +0900)
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
src/test/regression/regress.sh
src/test/regression/tests/020.allow_clear_text_frontend_auth/test.sh
src/test/regression/tests/021.pool_passwd_auth/test.sh
src/test/regression/tests/022.pool_passwd_alternative_auth/test.sh

index e4a314523118da42d2f446e4acfc890bdbe33084..7baf456e97c568be018ca491bc47eb467483998a 100755 (executable)
@@ -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 <<EOF
@@ -572,11 +584,14 @@ function set_pool_hba_conf {
     sed -i '/host.*all.*all.*trust$/s/^/#/g' $POOL_HBACONF
     sed -i '/local.*all.*all.*trust$/s/^/#/g' $POOL_HBACONF
 
-    echo "host    all         scram_user  0/0                   scram-sha-256" >> $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
 
index 33ab3607489c05af1aa154264544d1c32a5bfaa3..32f71c60bd65f92b6e66dd8e63a0013e0632fe38 100755 (executable)
@@ -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}
 }
 
index 65109f364908abf8603bafec317c75ffe697bead..4a3aa2b0028372944f752e317310facc55bd7c84 100755 (executable)
@@ -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
index f786244e0560ccdd5d832bd0ca2a3f2e756f803f..bf3e292b0a004cd879e4ebed451ac375a58394af 100755 (executable)
@@ -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
index ed8bc2296d4ef61eb2e464563c30fc4c67a17d55..abf1340330ebefd6605ab07ed6aa3b7183318ef0 100755 (executable)
@@ -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