From 79baaf077f798c22642619a135058a7fbfd051be Mon Sep 17 00:00:00 2001 From: Tatsuo Ishii Date: Tue, 10 Oct 2017 15:45:18 +0900 Subject: [PATCH] Add new test case "node_js.data" to extended-query-test. - Allow test.sh to specify subset of tests. - Let ignore source code line numbers in pgproto output data so that tests won't fail if source code line has been changed. - Fix bug with timeout. - Change timeout from 300 seconds to 60 seconds. - Change expected/sql-error.data so that it won't be affected previous test results. --- src/test/extended-query-test/README | 12 ++++++++++-- .../extended-query-test/expected/sql-error.data | 8 +------- src/test/extended-query-test/test.sh | 17 ++++++++++++----- src/test/extended-query-test/tests/node_js.data | 13 +++++++++++++ .../extended-query-test/tests/sql-error.data | 6 ------ 5 files changed, 36 insertions(+), 20 deletions(-) create mode 100644 src/test/extended-query-test/tests/node_js.data diff --git a/src/test/extended-query-test/README b/src/test/extended-query-test/README index ea649beee..506e7876c 100644 --- a/src/test/extended-query-test/README +++ b/src/test/extended-query-test/README @@ -17,12 +17,20 @@ The script runs each pgproto test data under "tests" directory using pgproto command. The each result is compared with data under "expected" directory. +Optional argument can be specified if you want to run only some of +tests. The argument should be the test file name under "tests" +directory. You can only specify part of the name, or you can use +regular expressions. + 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. +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. 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. \ No newline at end of file +can see examples in parse-before-bind.data. diff --git a/src/test/extended-query-test/expected/sql-error.data b/src/test/extended-query-test/expected/sql-error.data index a62387616..31fbf7698 100644 --- a/src/test/extended-query-test/expected/sql-error.data +++ b/src/test/extended-query-test/expected/sql-error.data @@ -1,9 +1,3 @@ -FE=> Query(query="DROP TABLE IF EXISTS pgproto_test1") -<= BE CommandComplete(DROP TABLE) -<= BE ReadyForQuery(I) -FE=> Query(query="CREATE TABLE pgproto_test1(i INT)") -<= BE CommandComplete(CREATE TABLE) -<= BE ReadyForQuery(I) FE=> Parse(stmt="S1", query="BEGIN") FE=> Bind(stmt="S1", portal="") FE=> Execute(portal="") @@ -21,6 +15,6 @@ FE=> Sync <= BE BindComplete <= BE CommandComplete(BEGIN) <= BE CloseComplete -<= BE ErrorResponse(S ERROR V ERROR C 42P01 M relation "non_existsing_table" does not exist P 15 F parse_relation.c L 1160 R parserOpenTable ) +<= 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 ) <= BE ReadyForQuery(I) FE=> Terminate diff --git a/src/test/extended-query-test/test.sh b/src/test/extended-query-test/test.sh index 506f1966b..35c64a3ba 100755 --- a/src/test/extended-query-test/test.sh +++ b/src/test/extended-query-test/test.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -timeout=300 +timeout=30 export PGPORT=11000 export PGDATABASE=test export PGPOOL_INSTALL_DIR=$HOME/work/pgpool-II/current @@ -11,12 +11,16 @@ testdir=`pwd`/tests expected=`pwd`/expected results=`pwd`/results rm -f $results/* -mkdir $results +test ! -d $result && mkdir $results diffs=`pwd`/diffs rm -f $diffs -tests=`(cd tests;ls)` +if [ $# -gt 0 ];then + tests=`(cd tests;ls |grep $1)` +else + tests=`(cd tests;ls)` +fi rm -fr testdata mkdir testdata cd testdata @@ -58,9 +62,11 @@ do if [ $? = 124 ] then echo "timeout." - timeoutcnt=`expr $timeout + 1` + timeoutcnt=`expr $timeoutcnt + 1` else - cmp $expected/$i $results/$i >/dev/null 2>&1 + sed -e 's/L [0-9]* R/L xxx R/' $expected/$i > expected_tmp + sed -e 's/L [0-9]* R/L xxx R/' $results/$i > results_tmp + cmp expected_tmp results_tmp >/dev/null 2>&1 if [ $? != 0 ] then echo "failed." @@ -71,6 +77,7 @@ do echo "ok." okcnt=`expr $okcnt + 1` fi + rm expected_tmp results_tmp fi grep pool_check_pending_message_and_reply log/pgpool.log ./shutdownall >/dev/null 2>&1 diff --git a/src/test/extended-query-test/tests/node_js.data b/src/test/extended-query-test/tests/node_js.data new file mode 100644 index 000000000..1f8c01719 --- /dev/null +++ b/src/test/extended-query-test/tests/node_js.data @@ -0,0 +1,13 @@ +# Test data for 0000345: pgpool node.js prepared statement The purpose +# for this test is 'y' after 'H' (frontend wants response of H +# message). + +# Issue SELECT +'P' "" "SELECT 1" 0 +'B' "" "" 0 0 0 +'E' "" 0 +'H' +'y' +'S' +'Y' +'X' diff --git a/src/test/extended-query-test/tests/sql-error.data b/src/test/extended-query-test/tests/sql-error.data index 801621892..e5703eaa9 100644 --- a/src/test/extended-query-test/tests/sql-error.data +++ b/src/test/extended-query-test/tests/sql-error.data @@ -1,12 +1,6 @@ # Test data for error case. # -# Create test table -'Q' "DROP TABLE IF EXISTS pgproto_test1" -'Y' -'Q' "CREATE TABLE pgproto_test1(i INT)" -'Y' - # Start a transaction 'P' "S1" "BEGIN" 0 'B' "" "S1" 0 0 0 -- 2.39.5