Added a check for MySQL client libraries for the connection tests and re-enabled the tests.

This commit is contained in:
Markus Makela 2014-11-09 21:01:39 +02:00
parent 5490954e43
commit 37fa9668a9
5 changed files with 43 additions and 18 deletions

View File

@ -205,6 +205,16 @@ debugmsg("Search returned: ${MYSQL_DIR_LOC}")
unset(DEB_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
if(BUILD_RABBITMQ)
include(CheckCSourceCompiles)

View File

@ -1,3 +1,7 @@
if(BUILD_TESTS)
add_subdirectory(test)
endif()
add_library(testroute SHARED testroute.c)
target_link_libraries(testroute log_manager utils)
install(TARGETS testroute DESTINATION modules)
@ -16,6 +20,3 @@ install(TARGETS cli DESTINATION modules)
add_subdirectory(readwritesplit)
#if(BUILD_TESTS)
# add_subdirectory(test)
#endif()

View File

@ -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})
#find_library(MYSQLCLIENT_LIBARIES NAMES mysqlclient PATH_SUFFIXES mysql mariadb)
#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)
#endif()
if(MYSQLCLIENT_FOUND)
add_test(NAME ReadWriteSplitLoginTest COMMAND $<TARGET_FILE:testconnect> 10000 ${TEST_HOST} ${MASTER_PORT} ${TEST_HOST} ${TEST_PORT_RW} 1.10)
endif()
add_subdirectory(test_hints)

View File

@ -1,8 +1,6 @@
find_library(MYSQLCLIENT_LIBARIES NAMES mysqlclient PATH_SUFFIXES mysql mariadb)
if(MYSQLCLIENT_LIBRARIES MATCHES "NOTFOUND")
message(WARNING "Cannot find libmysqlclient. Login tests disabled.")
else()
if(MYSQLCLIENT_FOUND)
add_executable(testconnect testconnect.c)
target_link_libraries(testconnect ${MYSQLCLIENT_LIBARIES})
add_test(NAME ReadConnRouterLoginTest COMMAND $<TARGET_FILE:testconnect> 10000 ${TEST_HOST} ${MASTER_PORT} ${TEST_HOST} ${TEST_PORT})
message(STATUS "Linking against: ${MYSQLCLIENT_LIBRARIES}")
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()

View File

@ -4,6 +4,7 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
int main(int argc, char** argv)
{
@ -12,17 +13,24 @@ int main(int argc, char** argv)
unsigned int port;
int rval, iterations,i;
clock_t begin,end;
double baseline,test;
double baseline,test, ratio, result, minimum;
if(argc < 6){
fprintf(stderr,"Usage: %s <iterations> <baseline host> <baseline port> <test host> <test port>\n",argv[0]);
if(argc < 7){
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;
}
iterations = atoi(argv[1]);
host = strdup(argv[2]);
port = atoi(argv[3]);
ratio = atof(argv[6]);
rval = 0;
if(ratio <= 0.0){
return 1;
}
/**Testing direct connection to master*/
@ -73,7 +81,17 @@ int main(int argc, char** argv)
test = (double)(end - begin)/CLOCKS_PER_SEC;
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);
return rval;
}