Overview:
-The objective the test suites is testing behaviors of Pgpool-II
+The objective of the test suites is testing behaviors of Pgpool-II
running in streaming replication with extended queries. The reason
pgproto used here is, it is very difficult to implement that kind of
tests using standard drivers such as libpq and Java because no low
How to add tests:
-Add pgproto data under "tests" directory. Also you need to add
-expected output of pgproto to "expected" directory. The file name must
-be identical to the file name added to tests directory. Note that
-source files lines like "1186" below
-<= BE ErrorResponse(S ERROR V ERROR C 42P01 M relation "non_existsing_table" does not exist P 15 F parse_relation.c L 1186 R parserOpenTable )
-will be replaced with "xxx" to avoid the source code version differences.
+Add pgproto data under "tests" directory. File names do not matter. By
+a historical reason, ".data" is used but you can choose arbitrary
+names. Next you need to add expected output of pgproto to "expected"
+directory. The file name must be identical to the file name added to
+the tests directory. Note that source files lines like "1186" below <=
+BE ErrorResponse(S ERROR V ERROR C 42P01 M relation
+"non_existsing_table" does not exist P 15 F parse_relation.c L 1186 R
+parserOpenTable ) will be replaced with "xxx" to avoid the source code
+version differences.
If you need to add special directives to pgpool.conf, include those
configuration directives to the pgproto data starting with "##". You
can see examples in parse-before-bind.data.
+
+Optional tests:
+
+An optional extra test script can be added to "extra_scripts"
+directory. The file name must be identical to the file name added to
+the tests directory. Those files must be executable and are executed
+after pgproto run. The test only succeeds when both pgproto test is ok
+and the extra script returns 0 status. Typical usage of the script is
+checking the load balance behavior by looking at Pgpool-II log. Note
+that the log file name is exported as an environment variable
+"$PGPOOLLOG".
FE=> Query(query="DROP TABLE IF EXISTS pgproto_test1")
-<= BE NoticeResponse(S NOTICE V NOTICE C 00000 M table "pgproto_test1" does not exist, skipping F tablecmds.c L 764 R DropErrorMsgNonExistent )
+<= BE NoticeResponse(S NOTICE V NOTICE C 00000 M table "pgproto_test1" does not exist, skipping F tablecmds.c L 914 R DropErrorMsgNonExistent )
<= BE CommandComplete(DROP TABLE)
<= BE ReadyForQuery(I)
FE=> Query(query="CREATE TABLE pgproto_test1(i INT)")
<= BE CommandComplete(COMMIT)
<= BE CloseComplete
<= BE ReadyForQuery(I)
+FE=> Query(query="DROP TABLE pgproto_test1")
+<= BE CommandComplete(DROP TABLE)
+<= BE ReadyForQuery(I)
FE=> Terminate
FE=> Query(query="DROP TABLE IF EXISTS pgproto_test1")
+<= BE NoticeResponse(S NOTICE V NOTICE C 00000 M table "pgproto_test1" does not exist, skipping F tablecmds.c L 914 R DropErrorMsgNonExistent )
<= BE CommandComplete(DROP TABLE)
<= BE ReadyForQuery(I)
FE=> Query(query="CREATE TABLE pgproto_test1(i INT)")
<= BE CommandComplete(COMMIT)
<= BE CloseComplete
<= BE ReadyForQuery(I)
+FE=> Query(query="DROP TABLE pgproto_test1")
+<= BE CommandComplete(DROP TABLE)
+<= BE ReadyForQuery(I)
FE=> Terminate
FE=> Query(query="DROP TABLE IF EXISTS pgproto_test1")
+<= BE NoticeResponse(S NOTICE V NOTICE C 00000 M table "pgproto_test1" does not exist, skipping F tablecmds.c L 914 R DropErrorMsgNonExistent )
<= BE CommandComplete(DROP TABLE)
<= BE ReadyForQuery(I)
FE=> Query(query="CREATE TABLE pgproto_test1(i INT)")
<= BE CommandComplete(SELECT 1)
<= BE CloseComplete
<= BE ReadyForQuery(I)
+FE=> Query(query="DROP TABLE pgproto_test1")
+<= BE CommandComplete(DROP TABLE)
+<= BE ReadyForQuery(I)
FE=> Terminate
FE=> Query(query="DROP TABLE IF EXISTS pgproto_test1")
+<= BE NoticeResponse(S NOTICE V NOTICE C 00000 M table "pgproto_test1" does not exist, skipping F tablecmds.c L 914 R DropErrorMsgNonExistent )
<= BE CommandComplete(DROP TABLE)
<= BE ReadyForQuery(I)
FE=> Query(query="CREATE TABLE pgproto_test1(i INT)")
<= BE CommandComplete(SELECT 1)
<= BE CloseComplete
<= BE ReadyForQuery(I)
+FE=> Query(query="DROP TABLE pgproto_test1")
+<= BE CommandComplete(DROP TABLE)
+<= BE ReadyForQuery(I)
FE=> Terminate
--- /dev/null
+#!/usr/bin/env bash
+
+set 1 0 0 # expected results: Parse:1 Parse:0 Execute: 0
+grep "SELECT 1" $PGPOOLLOG |awk '{print $9}' | while read node
+do
+ if [ $1 -ne $node ]
+ then
+ echo "expected: $1 result: $node"
+ exit 99
+ fi
+ shift
+done
+
+if [ $? = 99 ]
+then
+ exit 1
+fi
+
+exit 0
+
--- /dev/null
+#!/usr/bin/env bash
+
+set 1 0 0 # expected results: Parse:1 Parse:0 Execute: 0
+grep "SELECT 1" $PGPOOLLOG |awk '{print $9}' | while read node
+do
+ if [ $1 -ne $node ]
+ then
+ echo "expected: $1 result: $node"
+ exit 99
+ fi
+ shift
+done
+
+if [ $? = 99 ]
+then
+ exit 1
+fi
+
+exit 0
+
testdir=`pwd`/tests
expected=`pwd`/expected
+extra_scripts=`pwd`/extra_scripts
+export PGPOOLLOG=`pwd`/testdata/log/pgpool.log
results=`pwd`/results
rm -f $results/*
test ! -d $results && mkdir $results
diff -N $expected/$i $results/$i >> $diffs
failcnt=`expr $failcnt + 1`
else
- echo "ok."
- okcnt=`expr $okcnt + 1`
+ extra_fail=0
+ # excute extra scripts if exists.
+ if [ -x $extra_scripts/$i ]
+ then
+ $extra_scripts/$i > $results/$i.extra 2>&1
+
+ if [ $? != 0 ]
+ then
+ echo "extra test failed."
+ extra_fail=1
+ failcnt=`expr $failcnt + 1`
+ fi
+ fi
+
+ if [ $extra_fail = 0 ]
+ then
+ echo "ok."
+ okcnt=`expr $okcnt + 1`
+ fi
fi
rm expected_tmp results_tmp
fi
# Test data for bug271.
# In an explicit transaction, SELECT is parsed, DML issued, same SELECT/bind issued.
-# In this case Pgpool-II should parse resend to primary node.
+# In this case Pgpool-II should resend parse message to primary node.
# Similar to pgproto.data but in this case SELECT uses "S1" statement.
# As of 2017/2/14, this fails.
# <= BE ErrorResponse(S ERROR C XX000 M unable to bind D cannot get parse message "S1" F pool_proto_modules.c L 1317 )
# Moreover, Pgpool-II does not close the idle connection.
+##backend_weight0 = 0
+##backend_weight1 = 1
+
# Create test table
'Q' "DROP TABLE IF EXISTS pgproto_test1"
'Y'
'C' 'S' "S1"
'S'
'Y'
+
+# DROP test table
+'Q' "DROP TABLE pgproto_test1"
+'Y'
+
'X'
'C' 'S' "S1"
'S'
'Y'
+
+# DROP test table
+'Q' "DROP TABLE pgproto_test1"
+'Y'
+
'X'
'S'
'Y'
+
+# DROP test table
+'Q' "DROP TABLE pgproto_test1"
+'Y'
+
'X'
'S'
'Y'
+
+# DROP test table
+'Q' "DROP TABLE pgproto_test1"
+'Y'
+
'X'