Moved dbshard tests to a separate cmake file
This commit is contained in:
@ -1,8 +1,6 @@
|
|||||||
if(MYSQLCLIENT_FOUND AND BUILD_TESTS)
|
if(MYSQLCLIENT_FOUND AND BUILD_TESTS)
|
||||||
add_executable(testdbshard testdbshard.c)
|
add_executable(testdbshard testdbshard.c)
|
||||||
target_link_libraries(testdbshard ${MYSQLCLIENT_LIBRARIES} ssl crypto dl z m rt pthread)
|
target_link_libraries(testdbshard ${MYSQLCLIENT_LIBRARIES} ssl crypto dl z m rt pthread)
|
||||||
foreach(VAR RANGE 3000 3003)
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/test.cmake @ONLY)
|
||||||
execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/prepare_shard.sh ${TEST_HOST} ${VAR} ${TEST_USER} ${TEST_PASSWORD})
|
add_test(NAME DBShardTest COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/test.cmake)
|
||||||
endforeach()
|
|
||||||
add_test(NAME DBShardTest COMMAND $<TARGET_FILE:testdbshard> ${TEST_HOST} ${TEST_PORT_DB} ${TEST_USER} ${TEST_PASSWORD})
|
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@ -1,13 +1,19 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
if [ $# -lt 3 ]
|
if [ $# -lt 5 ]
|
||||||
then
|
then
|
||||||
echo "usage $0 <host> <port> <username> <password>"
|
printf "Not enough arguments: '"
|
||||||
|
for i in $@
|
||||||
|
do
|
||||||
|
printf "$i "
|
||||||
|
done
|
||||||
|
echo "'given, 5 needed."
|
||||||
|
echo "usage $0 <host> <port> <username> <password> <database name>"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
HOST=$1
|
HOST=$1
|
||||||
PORT=$2
|
PORT=$2
|
||||||
USER=$3
|
USER=$3
|
||||||
PW=$4
|
PW=$4
|
||||||
SHD="shard$RANDOM"
|
SHD=$5
|
||||||
mysql -u $USER -p$PW -P $PORT -h $HOST -e "create database $SHD;"
|
mysql -u $USER -p$PW -P $PORT -h $HOST -e "create database $SHD;"
|
||||||
echo "Created database \"$SHD\" at $HOST:$PORT"
|
echo "Created database \"$SHD\" at $HOST:$PORT"
|
||||||
|
|||||||
10
server/modules/routing/dbshard/test/test.cmake.in
Normal file
10
server/modules/routing/dbshard/test/test.cmake.in
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
set(DBSHARD_TEST_PORTS 3000 3001 3002 3003)
|
||||||
|
foreach(VAR ${DBSHARD_TEST_PORTS})
|
||||||
|
execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/prepare_shard.sh @TEST_HOST@ ${VAR} @TEST_USER@ @TEST_PASSWORD@ "db${VAR}")
|
||||||
|
endforeach()
|
||||||
|
execute_process(COMMAND ${CMAKE_CURRENT_BINARY_DIR}/testdbshard @TEST_HOST@ @TEST_PORT_DB@ @TEST_USER@ @TEST_PASSWORD@ RESULT_VARIABLE RVAL)
|
||||||
|
if(RVAL EQUAL 0)
|
||||||
|
message("Test passed.")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Test failed.")
|
||||||
|
endif()
|
||||||
Reference in New Issue
Block a user