diff --git a/server/modules/routing/readwritesplit/test/makefile b/server/modules/routing/readwritesplit/test/makefile new file mode 100644 index 000000000..92374c5cb --- /dev/null +++ b/server/modules/routing/readwritesplit/test/makefile @@ -0,0 +1,39 @@ +# cleantests - clean local and subdirectories' tests +# buildtests - build all local and subdirectories' tests +# runtests - run all local tests +# testall - clean, build and run local and subdirectories' tests + +include ../../../../build_gateway.inc +include ../../../../makefile.inc + +CC=cc +TESTLOG := $(shell pwd)/testrouters.log +RET := -1 + +cleantests: + - $(DEL) *.o + - $(DEL) *~ + +testall: + $(MAKE) cleantests + $(MAKE) DEBUG=Y buildtests + $(MAKE) runtests + +buildtests : + +runtests: + @echo "" >> $(TESTLOG) + @echo "-------------------------------" >> $(TESTLOG) + @echo $(shell date) >> $(TESTLOG) + @echo "Test MaxScale R/W Split" >> $(TESTLOG) + @echo "-------------------------------" >> $(TESTLOG) + +ifeq ($(shell ./rwsplit.sh; echo $$?), 0) + @echo "MaxScale core PASSED" >> $(TESTLOG) +else + @echo "MaxScale core FAILED" >> $(TESTLOG) ; exit 1 +endif + @echo "" >> $(TESTLOG) + +pesce: + @echo "fine" diff --git a/server/modules/routing/readwritesplit/test/rwsplit.sh b/server/modules/routing/readwritesplit/test/rwsplit.sh new file mode 100755 index 000000000..8a6eba356 --- /dev/null +++ b/server/modules/routing/readwritesplit/test/rwsplit.sh @@ -0,0 +1,12 @@ +#! /bin/sh + + +a=`mysql --host=127.0.0.1 -P 4606 -umassi -pmassi --unbuffered=true --disable-reconnect --silent < ./transaction_with_set.sql` +#a=`mysql --host=107.170.19.59 -P 4606 -uvai -pvai --unbuffered=true --disable-reconnect --silent < ./transaction_with_set.sql` + +if [ "$a" -eq 2 ]; then + exit 0 +else + exit 1 +fi + diff --git a/server/modules/routing/readwritesplit/test/transaction_with_set.sql b/server/modules/routing/readwritesplit/test/transaction_with_set.sql new file mode 100644 index 000000000..a6ef719c5 --- /dev/null +++ b/server/modules/routing/readwritesplit/test/transaction_with_set.sql @@ -0,0 +1,19 @@ +USE test; +SET autocommit = 0; +SET @a= -1; +SET @b = -2; +START TRANSACTION; +CREATE TABLE IF NOT EXISTS myCity (a int, b char(20)); +INSERT INTO myCity VALUES (1, 'Milan'); +INSERT INTO myCity VALUES (2, 'London'); +COMMIT; +START TRANSACTION; +DELETE FROM myCity; +SET @a = (SELECT COUNT(1) FROM myCity); +ROLLBACK; +START TRANSACTION; +SET @b = (SELECT COUNT(*) FROM myCity); +START TRANSACTION; +DROP TABLE myCity; +SELECT (@a+@b) AS res; +COMMIT;