diff --git a/macros.cmake b/macros.cmake index d8f1b7827..79e8482e6 100644 --- a/macros.cmake +++ b/macros.cmake @@ -27,7 +27,7 @@ macro(set_variables) set(TEST_HOST "127.0.0.1" CACHE STRING "hostname or IP address of MaxScale's host") # port of read connection router module - set(TEST_PORT_RW "4008" CACHE STRING "port of read connection router module") + set(TEST_PORT "4008" CACHE STRING "port of read connection router module") # port of read/write split router module set(TEST_PORT_RW "4006" CACHE STRING "port of read/write split router module") @@ -38,6 +38,9 @@ macro(set_variables) # master test server server_id set(TEST_MASTER_ID "3000" CACHE STRING "master test server server_id") + # master test server port + set(MASTER_PORT "3000" CACHE STRING "master test server port") + # username of MaxScale user set(TEST_USER "maxuser" CACHE STRING "username of MaxScale user") diff --git a/server/modules/routing/CMakeLists.txt b/server/modules/routing/CMakeLists.txt index 9d2f25f76..56e86bb96 100644 --- a/server/modules/routing/CMakeLists.txt +++ b/server/modules/routing/CMakeLists.txt @@ -16,3 +16,6 @@ install(TARGETS cli DESTINATION modules) add_subdirectory(readwritesplit) +if(BUILD_TESTS) + add_subdirectory(test) +endif() diff --git a/server/modules/routing/readwritesplit/test/CMakeLists.txt b/server/modules/routing/readwritesplit/test/CMakeLists.txt index 1cd40be63..9b49dac00 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 testrwsplit.log ${TEST_HOST} ${TEST_PORT_RW} ${TEST_MASTER_ID} ${TEST_USER} ${TEST_PASSWORD} ${CMAKE_CURRENT_SOURCE_DIR}) +add_test(NAME ReadWriteSplitLoginTest COMMAND $ 10000 ${TEST_HOST} ${MASTER_PORT} ${TEST_HOST} ${TEST_PORT_RW}) add_subdirectory(test_hints) \ No newline at end of file diff --git a/server/modules/routing/test/CMakeLists.txt b/server/modules/routing/test/CMakeLists.txt new file mode 100644 index 000000000..64f06f98f --- /dev/null +++ b/server/modules/routing/test/CMakeLists.txt @@ -0,0 +1,3 @@ +add_executable(testconnect testconnect.c) +target_link_libraries(testconnect mysql) +add_test(NAME ReadConnRouterLoginTest COMMAND $ 10000 ${TEST_HOST} ${MASTER_PORT} ${TEST_HOST} ${TEST_PORT}) \ No newline at end of file diff --git a/server/modules/routing/test/testconnect.c b/server/modules/routing/test/testconnect.c new file mode 100644 index 000000000..16a770d95 --- /dev/null +++ b/server/modules/routing/test/testconnect.c @@ -0,0 +1,79 @@ +#include +#include +#include +#include +#include +#include +int main(int argc, char** argv) +{ + + MYSQL* server; + char *host; + unsigned int port; + int rval, iterations,i; + clock_t begin,end; + double baseline,test; + + if(argc < 6){ + fprintf(stderr,"Usage: %s \n",argv[0]); + return 1; + } + + iterations = atoi(argv[1]); + host = strdup(argv[2]); + port = atoi(argv[3]); + rval = 0; + + /**Testing direct connection to master*/ + + printf("Connecting to MySQL server through %s:%d.\n",host,port); + begin = clock(); + + for(i = 0;i