Added a check for MySQL client libraries for the connection tests and re-enabled the tests.
This commit is contained in:
10
macros.cmake
10
macros.cmake
@ -205,6 +205,16 @@ debugmsg("Search returned: ${MYSQL_DIR_LOC}")
|
|||||||
unset(DEB_FNC)
|
unset(DEB_FNC)
|
||||||
unset(RPM_FNC)
|
unset(RPM_FNC)
|
||||||
|
|
||||||
|
#Find the MySQL client library
|
||||||
|
find_library(MYSQLCLIENT_LIBRARIES NAMES mysqlclient PATH_SUFFIXES mysql mariadb)
|
||||||
|
if(${MYSQLCLIENT_LIBRARIES} MATCHES "NOTFOUND")
|
||||||
|
set(MYSQLCLIENT_FOUND FALSE CACHE INTERNAL "")
|
||||||
|
message(STATUS "Cannot find MySQL client library: Login tests disabled.")
|
||||||
|
else()
|
||||||
|
set(MYSQLCLIENT_FOUND TRUE CACHE INTERNAL "")
|
||||||
|
message(STATUS "Found MySQL client library: ${MYSQLCLIENT_LIBRARIES}")
|
||||||
|
endif()
|
||||||
|
|
||||||
#Check RabbitMQ headers and libraries
|
#Check RabbitMQ headers and libraries
|
||||||
if(BUILD_RABBITMQ)
|
if(BUILD_RABBITMQ)
|
||||||
include(CheckCSourceCompiles)
|
include(CheckCSourceCompiles)
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
|
if(BUILD_TESTS)
|
||||||
|
add_subdirectory(test)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_library(testroute SHARED testroute.c)
|
add_library(testroute SHARED testroute.c)
|
||||||
target_link_libraries(testroute log_manager utils)
|
target_link_libraries(testroute log_manager utils)
|
||||||
install(TARGETS testroute DESTINATION modules)
|
install(TARGETS testroute DESTINATION modules)
|
||||||
@ -16,6 +20,3 @@ install(TARGETS cli DESTINATION modules)
|
|||||||
|
|
||||||
add_subdirectory(readwritesplit)
|
add_subdirectory(readwritesplit)
|
||||||
|
|
||||||
#if(BUILD_TESTS)
|
|
||||||
# add_subdirectory(test)
|
|
||||||
#endif()
|
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
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 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})
|
||||||
|
|
||||||
#find_library(MYSQLCLIENT_LIBARIES NAMES mysqlclient PATH_SUFFIXES mysql mariadb)
|
if(MYSQLCLIENT_FOUND)
|
||||||
#if( NOT (MYSQLCLIENT_LIBRARIES MATCHES "NOTFOUND"))
|
add_test(NAME ReadWriteSplitLoginTest COMMAND $<TARGET_FILE:testconnect> 10000 ${TEST_HOST} ${MASTER_PORT} ${TEST_HOST} ${TEST_PORT_RW} 1.10)
|
||||||
# add_test(NAME ReadWriteSplitLoginTest COMMAND $<TARGET_FILE:testconnect> 10000 ${TEST_HOST} ${MASTER_PORT} ${TEST_HOST} ${TEST_PORT_RW} 1.10)
|
endif()
|
||||||
#endif()
|
|
||||||
|
|
||||||
|
|
||||||
add_subdirectory(test_hints)
|
add_subdirectory(test_hints)
|
||||||
@ -1,8 +1,6 @@
|
|||||||
find_library(MYSQLCLIENT_LIBARIES NAMES mysqlclient PATH_SUFFIXES mysql mariadb)
|
if(MYSQLCLIENT_FOUND)
|
||||||
if(MYSQLCLIENT_LIBRARIES MATCHES "NOTFOUND")
|
|
||||||
message(WARNING "Cannot find libmysqlclient. Login tests disabled.")
|
|
||||||
else()
|
|
||||||
add_executable(testconnect testconnect.c)
|
add_executable(testconnect testconnect.c)
|
||||||
target_link_libraries(testconnect ${MYSQLCLIENT_LIBARIES})
|
message(STATUS "Linking against: ${MYSQLCLIENT_LIBRARIES}")
|
||||||
add_test(NAME ReadConnRouterLoginTest COMMAND $<TARGET_FILE:testconnect> 10000 ${TEST_HOST} ${MASTER_PORT} ${TEST_HOST} ${TEST_PORT})
|
target_link_libraries(testconnect ${MYSQLCLIENT_LIBRARIES} ssl crypto dl z m)
|
||||||
|
add_test(NAME ReadConnRouterLoginTest COMMAND $<TARGET_FILE:testconnect> 10000 ${TEST_HOST} ${MASTER_PORT} ${TEST_HOST} ${TEST_PORT} 1.10)
|
||||||
endif()
|
endif()
|
||||||
@ -4,6 +4,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -12,18 +13,25 @@ int main(int argc, char** argv)
|
|||||||
unsigned int port;
|
unsigned int port;
|
||||||
int rval, iterations,i;
|
int rval, iterations,i;
|
||||||
clock_t begin,end;
|
clock_t begin,end;
|
||||||
double baseline,test;
|
double baseline,test, ratio, result, minimum;
|
||||||
|
|
||||||
if(argc < 6){
|
if(argc < 7){
|
||||||
fprintf(stderr,"Usage: %s <iterations> <baseline host> <baseline port> <test host> <test port>\n",argv[0]);
|
fprintf(stderr,"Usage: %s <iterations> <baseline host> <baseline port> <test host> <test port> <max result ratio>\n",argv[0]);
|
||||||
|
fprintf(stderr,"The ratio is measured as:\ntest CPU time / baseline CPU time\n");
|
||||||
|
fprintf(stderr,"The test fails if this ratio is exceeded.\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
iterations = atoi(argv[1]);
|
iterations = atoi(argv[1]);
|
||||||
host = strdup(argv[2]);
|
host = strdup(argv[2]);
|
||||||
port = atoi(argv[3]);
|
port = atoi(argv[3]);
|
||||||
|
ratio = atof(argv[6]);
|
||||||
rval = 0;
|
rval = 0;
|
||||||
|
|
||||||
|
if(ratio <= 0.0){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/**Testing direct connection to master*/
|
/**Testing direct connection to master*/
|
||||||
|
|
||||||
printf("Connecting to MySQL server through %s:%d.\n",host,port);
|
printf("Connecting to MySQL server through %s:%d.\n",host,port);
|
||||||
@ -74,6 +82,16 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
printf("CPU time used in seconds:\nDirect connection: %f\nThrough MaxScale: %f\n",baseline,test);
|
printf("CPU time used in seconds:\nDirect connection: %f\nThrough MaxScale: %f\n",baseline,test);
|
||||||
|
|
||||||
|
result = test / baseline;
|
||||||
|
if(rval){
|
||||||
|
printf("Test failed: Errors during test run.");
|
||||||
|
}else if(result > ratio){
|
||||||
|
printf("Test failed: CPU time ratio was %f which exceeded the limit of %f.\n", result, ratio);
|
||||||
|
rval = 1;
|
||||||
|
}else{
|
||||||
|
printf("Test passed: CPU time ratio was %f.\n",result);
|
||||||
|
}
|
||||||
|
|
||||||
free(host);
|
free(host);
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user