From 0f07c9f08cb4b7902e09921a1958d6e2042c32b9 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Mon, 15 Sep 2014 09:27:47 +0300 Subject: [PATCH] Added hint tests Fixed readwritesplit tests looking for test input in the wrong directory Updated the canonical query test expected output --- macros.cmake | 1 + .../test/canonical_tests/expected.sql | 10 ++-- .../readwritesplit/test/CMakeLists.txt | 5 +- .../routing/readwritesplit/test/rwsplit.sh | 53 ++++++++----------- .../test/test_hints/CMakeLists.txt | 3 ++ .../test/test_hints/rwsplit_hints.sh | 26 ++++----- server/test/CMakeLists.txt | 10 ++-- server/test/startmaxscale.sh | 6 ++- 8 files changed, 59 insertions(+), 55 deletions(-) create mode 100644 server/modules/routing/readwritesplit/test/test_hints/CMakeLists.txt mode change 100644 => 100755 server/test/startmaxscale.sh diff --git a/macros.cmake b/macros.cmake index 0a422262d..2311d00c1 100644 --- a/macros.cmake +++ b/macros.cmake @@ -42,4 +42,5 @@ macro(set_variables) # Install init.d scripts and ldconf configuration files set(INSTALL_SYSTEM_FILES TRUE CACHE BOOL "Install init.d scripts and ldconf configuration files") + endmacro() \ No newline at end of file diff --git a/query_classifier/test/canonical_tests/expected.sql b/query_classifier/test/canonical_tests/expected.sql index fabb27dc7..1126f6016 100755 --- a/query_classifier/test/canonical_tests/expected.sql +++ b/query_classifier/test/canonical_tests/expected.sql @@ -1,7 +1,7 @@ -select md5(?) =?, sleep(?), rand(?); -select * from my1 where md5(?) =?; -select md5(?) =?; -select * from my1 where md5(?) =?; +select md5("?") =?, sleep(?), rand(?) +select * from my1 where md5("?") =? +select md5("?") =? +select * from my1 where md5("?") =? select sleep(?) select * from tst where lname='?' select ?,?,?,?,?,? from tst @@ -13,5 +13,5 @@ create table tst(fname varchar(30), lname varchar(30)) update tst set lname="?" where fname like '?' or lname like '?' delete from tst where lname like '?' and fname like '?' select ? from tst where fname='?' or lname like '?' -select ?,?,?,? from tst where name='?' or name='?' or name='?' +select ?,?,?,? from tst where name='?' or name='?' or name='?' or name='?' select count(?),count(?),count(?),count(?),count (?),count(?) from tst diff --git a/server/modules/routing/readwritesplit/test/CMakeLists.txt b/server/modules/routing/readwritesplit/test/CMakeLists.txt index cf5806ff1..e114a890f 100644 --- a/server/modules/routing/readwritesplit/test/CMakeLists.txt +++ b/server/modules/routing/readwritesplit/test/CMakeLists.txt @@ -1,2 +1,3 @@ -add_test(NAME ReadWriteSplitTest COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/rwsplit.sh ${TEST_HOST} ${TEST_PORT_RW} ${TEST_MASTER_ID} ${TEST_USER} ${TEST_PASSWORD}) -set_tests_properties(ReadWriteSplitTest PROPERTIES DEPENDS WaitForExecutable) \ No newline at end of file +add_test(NAME ReadWriteSplitTest COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/rwsplit.sh ${TEST_HOST} ${TEST_PORT_RW} ${TEST_MASTER_ID} ${TEST_USER} ${TEST_PASSWORD} ${CMAKE_CURRENT_SOURCE_DIR}) +set_tests_properties(ReadWriteSplitTest PROPERTIES DEPENDS RunExecutable) +add_subdirectory(test_hints) \ No newline at end of file diff --git a/server/modules/routing/readwritesplit/test/rwsplit.sh b/server/modules/routing/readwritesplit/test/rwsplit.sh index 8d4d64234..d68d14283 100755 --- a/server/modules/routing/readwritesplit/test/rwsplit.sh +++ b/server/modules/routing/readwritesplit/test/rwsplit.sh @@ -1,10 +1,11 @@ #!/bin/sh -NARGS=5 +NARGS=6 THOST=$1 TPORT=$2 TMASTER_ID=$3 TUSER=$4 TPWD=$5 +DIR=$6 if [ $# != $NARGS ] ; then @@ -20,7 +21,7 @@ fi RUNCMD=mysql\ --host=$THOST\ -P$TPORT\ -u$TUSER\ -p$TPWD\ --unbuffered=true\ --disable-reconnect\ --silent -TINPUT=$PWD/test_transaction_routing2.sql +TINPUT=$DIR/test_transaction_routing2.sql TRETVAL=0 a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then @@ -29,7 +30,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/test_transaction_routing2b.sql +TINPUT=$DIR/test_transaction_routing2b.sql TRETVAL=0 a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then @@ -38,7 +39,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/test_transaction_routing3.sql +TINPUT=$DIR/test_transaction_routing3.sql TRETVAL=2 a=`$RUNCMD < $TINPUT` if [ "$a" = "$TMASTER_ID" ]; then @@ -47,7 +48,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/test_transaction_routing3b.sql +TINPUT=$DIR/test_transaction_routing3b.sql TRETVAL=2 a=`$RUNCMD < $TINPUT` if [ "$a" = "$TMASTER_ID" ]; then @@ -57,7 +58,7 @@ else fi # test implicit transaction, that is, not started explicitly, autocommit=0 -TINPUT=$PWD/test_transaction_routing4.sql +TINPUT=$DIR/test_transaction_routing4.sql TRETVAL=0 a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then @@ -66,7 +67,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/test_transaction_routing4b.sql +TINPUT=$DIR/test_transaction_routing4b.sql TRETVAL=0 a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then @@ -76,7 +77,7 @@ else fi # set a var via SELECT INTO @, get data from master, returning server-id: put master server-id value in TRETVAL -TINPUT=$PWD/select_for_var_set.sql +TINPUT=$DIR/select_for_var_set.sql TRETVAL=$TMASTER_ID a=`$RUNCMD < $TINPUT` @@ -86,7 +87,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/test_implicit_commit1.sql +TINPUT=$DIR/test_implicit_commit1.sql TRETVAL=$TMASTER_ID a=`$RUNCMD < $TINPUT` @@ -96,7 +97,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/test_implicit_commit2.sql +TINPUT=$DIR/test_implicit_commit2.sql TRETVAL=$TMASTER_ID a=`$RUNCMD < $TINPUT` if [ "$a" = "$TRETVAL" ]; then @@ -105,7 +106,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/test_implicit_commit3.sql +TINPUT=$DIR/test_implicit_commit3.sql TRETVAL=$TMASTER_ID a=`$RUNCMD < $TINPUT` if [ "$a" = "$TRETVAL" ]; then @@ -114,7 +115,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/test_implicit_commit4.sql +TINPUT=$DIR/test_implicit_commit4.sql TRETVAL=$TMASTER_ID a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then @@ -132,7 +133,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/test_implicit_commit6.sql +TINPUT=$DIR/test_implicit_commit6.sql TRETVAL=$TMASTER_ID a=`$RUNCMD < $TINPUT` if [ "$a" = "$TRETVAL" ]; then @@ -141,7 +142,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/test_implicit_commit7.sql +TINPUT=$DIR/test_implicit_commit7.sql TRETVAL=$TMASTER_ID a=`$RUNCMD < $TINPUT` if [ "$a" = "$TRETVAL" ]; then @@ -150,7 +151,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/test_autocommit_disabled1.sql +TINPUT=$DIR/test_autocommit_disabled1.sql TRETVAL=1 a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then @@ -159,7 +160,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/test_autocommit_disabled1b.sql +TINPUT=$DIR/test_autocommit_disabled1b.sql TRETVAL=1 a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then @@ -170,7 +171,7 @@ fi # Disable autocommit in the first session and then test in new session that # it is again enabled. -TINPUT=$PWD/test_autocommit_disabled2.sql +TINPUT=$DIR/test_autocommit_disabled2.sql TRETVAL=1 a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then @@ -179,7 +180,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/set_autocommit_disabled.sql +TINPUT=$DIR/set_autocommit_disabled.sql `$RUNCMD < $TINPUT` TINPUT=test_after_autocommit_disabled.sql TRETVAL=$TMASTER_ID @@ -191,7 +192,7 @@ else fi -TINPUT=$PWD/test_sescmd.sql +TINPUT=$DIR/test_sescmd.sql TRETVAL=2 a=`$RUNCMD < $TINPUT` if [ "$a" != "$TRETVAL" ]; then @@ -230,7 +231,7 @@ else echo "$TINPUT PASSED" ; fi -TINPUT=$PWD/test_temporary_table.sql +TINPUT=$DIR/test_temporary_table.sql a=`$RUNCMD < $TINPUT` TRETVAL=1 if [ "$a" != "$TRETVAL" ]; then @@ -244,13 +245,9 @@ echo "Session variables: Stress Test 1" echo "-----------------------------------" RUNCMD=mysql\ --host=$THOST\ -P$TPORT\ -u$TUSER\ -p$TPWD\ --unbuffered=true\ --disable-reconnect\ -q\ -r -TINPUT=$PWD/test_sescmd2.sql +TINPUT=$DIR/test_sescmd2.sql for ((i = 0;i<1000;i++)) do - if [[ $(( i % 50 )) -eq 0 ]] - then - printf "." - fi a=`$RUNCMD < $TINPUT 2>&1` if [[ "`echo "$a"|grep -i 'error'`" != "" ]] then @@ -270,13 +267,9 @@ echo "Session variables: Stress Test 2" echo "-----------------------------------" echo "" err="" -TINPUT=$PWD/test_sescmd3.sql +TINPUT=$DIR/test_sescmd3.sql for ((j = 0;j<1000;j++)) do - if [[ $(( j % 50 )) -eq 0 ]] - then - printf "." - fi b=`$RUNCMD < $TINPUT 2>&1` if [[ "`echo "$b"|grep -i 'null\|error'`" != "" ]] then diff --git a/server/modules/routing/readwritesplit/test/test_hints/CMakeLists.txt b/server/modules/routing/readwritesplit/test/test_hints/CMakeLists.txt new file mode 100644 index 000000000..410a9fad6 --- /dev/null +++ b/server/modules/routing/readwritesplit/test/test_hints/CMakeLists.txt @@ -0,0 +1,3 @@ +add_test(NAME SimpleHintTest COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/rwsplit_hints.sh ${TEST_HOST} ${TEST_PORT_RW_HINT} ${TEST_MASTER_ID} ${TEST_USER} ${TEST_PASSWORD} ${CMAKE_CURRENT_SOURCE_DIR}/simple_tests ${CMAKE_CURRENT_SOURCE_DIR}) +add_test(NAME ComplexHintTest COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/rwsplit_hints.sh ${TEST_HOST} ${TEST_PORT_RW_HINT} ${TEST_MASTER_ID} ${TEST_USER} ${TEST_PASSWORD} ${CMAKE_CURRENT_SOURCE_DIR}/complex_tests ${CMAKE_CURRENT_SOURCE_DIR}) +add_test(NAME StackHintTest COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/rwsplit_hints.sh ${TEST_HOST} ${TEST_PORT_RW_HINT} ${TEST_MASTER_ID} ${TEST_USER} ${TEST_PASSWORD} ${CMAKE_CURRENT_SOURCE_DIR}/stack_tests ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/server/modules/routing/readwritesplit/test/test_hints/rwsplit_hints.sh b/server/modules/routing/readwritesplit/test/test_hints/rwsplit_hints.sh index cdbfb335b..8db83cafa 100755 --- a/server/modules/routing/readwritesplit/test/test_hints/rwsplit_hints.sh +++ b/server/modules/routing/readwritesplit/test/test_hints/rwsplit_hints.sh @@ -1,12 +1,12 @@ #!/bin/bash NARGS=7 -TLOG=$1 -THOST=$2 -TPORT=$3 -TMASTER_ID=$4 -TUSER=$5 -TPWD=$6 -TESTINPUT=$7 +THOST=$1 +TPORT=$2 +TMASTER_ID=$3 +TUSER=$4 +TPWD=$5 +TESTINPUT=$6 +DIR=$7 if [ $# != $NARGS ] ; then @@ -14,7 +14,7 @@ echo"" echo "Wrong number of arguments, gave "$#" but "$NARGS" is required" echo "" echo "Usage :" -echo " rwsplit_hints.sh " +echo " rwsplit_hints.sh