MXS-1300: Add docker based cluster for REST API testing
The REST API test suite now starts a four node MariaDB cluster with docker-compose. This allows quick and easy local testing.
This commit is contained in:
parent
d59d3ab638
commit
6479788283
43
maxctrl/test/docker-compose.yml
Normal file
43
maxctrl/test/docker-compose.yml
Normal file
@ -0,0 +1,43 @@
|
||||
version: '2'
|
||||
services:
|
||||
server1:
|
||||
image: mariadb:10.0
|
||||
network_mode: "host"
|
||||
environment:
|
||||
MYSQL_ALLOW_EMPTY_PASSWORD: Y
|
||||
volumes:
|
||||
- ./sql/master:/docker-entrypoint-initdb.d
|
||||
command: mysqld --log-bin=binlog --binlog-format=ROW --server-id=3000 --port=3000 --log-slave-updates
|
||||
|
||||
server2:
|
||||
image: mariadb:10.0
|
||||
network_mode: "host"
|
||||
depends_on:
|
||||
- server1
|
||||
environment:
|
||||
MYSQL_ALLOW_EMPTY_PASSWORD: Y
|
||||
volumes:
|
||||
- ./sql/slave:/docker-entrypoint-initdb.d
|
||||
command: mysqld --log-bin=binlog --binlog-format=ROW --server-id=3001 --port=3001 --log-slave-updates
|
||||
|
||||
server3:
|
||||
image: mariadb:10.0
|
||||
network_mode: "host"
|
||||
depends_on:
|
||||
- server1
|
||||
environment:
|
||||
MYSQL_ALLOW_EMPTY_PASSWORD: Y
|
||||
volumes:
|
||||
- ./sql/slave:/docker-entrypoint-initdb.d
|
||||
command: mysqld --log-bin=binlog --binlog-format=ROW --server-id=3002 --port=3002 --log-slave-updates
|
||||
|
||||
server4:
|
||||
image: mariadb:10.0
|
||||
network_mode: "host"
|
||||
depends_on:
|
||||
- server1
|
||||
environment:
|
||||
MYSQL_ALLOW_EMPTY_PASSWORD: Y
|
||||
volumes:
|
||||
- ./sql/slave:/docker-entrypoint-initdb.d
|
||||
command: mysqld --log-bin=binlog --binlog-format=ROW --server-id=3003 --port=3003 --log-slave-updates
|
13
maxctrl/test/sql/master/users.sql
Normal file
13
maxctrl/test/sql/master/users.sql
Normal file
@ -0,0 +1,13 @@
|
||||
CREATE DATABASE test;
|
||||
|
||||
CREATE USER 'maxuser'@'127.0.0.1' IDENTIFIED BY 'maxpwd';
|
||||
CREATE USER 'maxuser'@'%' IDENTIFIED BY 'maxpwd';
|
||||
GRANT ALL ON *.* TO 'maxuser'@'127.0.0.1' WITH GRANT OPTION;
|
||||
GRANT ALL ON *.* TO 'maxuser'@'%' WITH GRANT OPTION;
|
||||
|
||||
CREATE USER 'skysql'@'127.0.0.1' IDENTIFIED BY 'skysql';
|
||||
CREATE USER 'skysql'@'%' IDENTIFIED BY 'skysql';
|
||||
GRANT ALL ON *.* TO 'skysql'@'127.0.0.1' WITH GRANT OPTION;
|
||||
GRANT ALL ON *.* TO 'skysql'@'%' WITH GRANT OPTION;
|
||||
|
||||
SET GLOBAL max_connections=10000;
|
3
maxctrl/test/sql/slave/replication.sql
Normal file
3
maxctrl/test/sql/slave/replication.sql
Normal file
@ -0,0 +1,3 @@
|
||||
CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=3000, MASTER_USER='maxuser', MASTER_PASSWORD='maxpwd', MASTER_LOG_POS=4, MASTER_CONNECT_RETRY=1;
|
||||
START SLAVE;
|
||||
SET GLOBAL max_connections=10000;
|
@ -50,12 +50,32 @@ chmod 0755 $maxscaledir/lib/maxscale
|
||||
chmod 0755 $maxscaledir/cache/maxscale
|
||||
chmod 0755 $maxscaledir/run/maxscale
|
||||
|
||||
# Go to the test directory
|
||||
cd $testdir
|
||||
|
||||
# This variable is used to start and stop MaxScale before each test
|
||||
export MAXSCALE_DIR=$maxscaledir
|
||||
|
||||
# Start MariaDB servers
|
||||
docker-compose up -d
|
||||
|
||||
# Wait until the servers are up
|
||||
for node in server1 server2 server3 server4
|
||||
do
|
||||
printf "Waiting for $node to start... "
|
||||
for ((i=0; i<60; i++))
|
||||
do
|
||||
docker-compose exec $node mysql -umaxuser -pmaxpwd -e "select 1" >& /dev/null && break
|
||||
sleep 1
|
||||
done
|
||||
echo "Done!"
|
||||
done
|
||||
|
||||
# Run tests
|
||||
cd $testdir
|
||||
npm test
|
||||
rval=$?
|
||||
|
||||
# Stop MariaDB servers
|
||||
docker-compose down -v
|
||||
|
||||
exit $rval
|
||||
|
Loading…
x
Reference in New Issue
Block a user