Updates to how shards are discovered while the module is running
SHOW DATABASES now takes notice of the state of the backends Added scripts for sharding test preparation and local port blocking
This commit is contained in:
@ -1,5 +1,8 @@
|
||||
if(MYSQLCLIENT_FOUND AND BUILD_TESTS)
|
||||
add_executable(testdbshard testdbshard.c)
|
||||
target_link_libraries(testdbshard ${MYSQLCLIENT_LIBRARIES} ssl crypto dl z m rt pthread)
|
||||
add_test(NAME DBShardTest COMMAND $<TARGET_FILE:testdbshard> ${TEST_HOST} 3000 ${TEST_USER} ${TEST_PASSWORD})
|
||||
foreach(VAR RANGE 3000 3003)
|
||||
execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/prepare_shard.sh ${TEST_HOST} ${VAR} ${TEST_USER} ${TEST_PASSWORD})
|
||||
endforeach()
|
||||
add_test(NAME DBShardTest COMMAND $<TARGET_FILE:testdbshard> ${TEST_HOST} ${TEST_PORT_DB} ${TEST_USER} ${TEST_PASSWORD})
|
||||
endif()
|
||||
|
||||
9
server/modules/routing/dbshard/test/portblock.sh
Executable file
9
server/modules/routing/dbshard/test/portblock.sh
Executable file
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
if [ $# -lt 1 ]
|
||||
then
|
||||
echo "Usage $0 <port to block>"
|
||||
exit 1
|
||||
fi
|
||||
sudo iptables -I INPUT 1 -i lo -p tcp --dport $1 -j DROP
|
||||
sudo iptables -I INPUT 1 -i lo -p tcp --sport $1 -j DROP
|
||||
echo "Traffic to port $1 blocked."
|
||||
13
server/modules/routing/dbshard/test/prepare_shard.sh
Executable file
13
server/modules/routing/dbshard/test/prepare_shard.sh
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
if [ $# -lt 3 ]
|
||||
then
|
||||
echo "usage $0 <host> <port> <username> <password>"
|
||||
exit 1
|
||||
fi
|
||||
HOST=$1
|
||||
PORT=$2
|
||||
USER=$3
|
||||
PW=$4
|
||||
SHD="shard$RANDOM"
|
||||
mysql -u $USER -p$PW -P $PORT -h $HOST -e "create database $SHD;"
|
||||
echo "Created database \"$SHD\" at $HOST:$PORT"
|
||||
@ -39,6 +39,8 @@ int main(int argc, char** argv)
|
||||
password = strdup(argv[4]);
|
||||
rval = 0;
|
||||
|
||||
printf("Connecting to %s:%d as %s/%s\n",host,port,username,password);
|
||||
|
||||
if((server = mysql_init(NULL)) == NULL){
|
||||
fprintf(stderr,"Error : Initialization of MySQL client failed.\n");
|
||||
rval = 1;
|
||||
|
||||
Reference in New Issue
Block a user