Fix MaxCtrl cluster tests

The configuration used an invalid parameter name which caused the two
MaxScales to use the same directory for persisted configurations.

The test also tried to sync with the wrong server causing the same
listener to be created twice on the same port but on different MaxScales.

Cleaned up the startup and shutdown scripts to always start from a clean
state.
This commit is contained in:
Markus Mäkelä
2018-08-09 06:18:30 +03:00
parent b69fc4d32c
commit 1447ac2eb9
6 changed files with 29 additions and 29 deletions

View File

@ -224,14 +224,12 @@ describe('Cluster Sync', function() {
.then(() => doCommand('create listener RW-Split-Router my-listener-2 5998 --hosts ' + primary_host)) .then(() => doCommand('create listener RW-Split-Router my-listener-2 5998 --hosts ' + primary_host))
// Sync after creation should succeed // Sync after creation should succeed
.then(() => doCommand('cluster sync ' + secondary_host + ' --hosts ' + primary_host)) .then(() => doCommand('cluster sync ' + secondary_host + ' --hosts ' + primary_host))
// Destroy the created server, should succeed // Destroy the created listener, should succeed
.then(() => doCommand('destroy listener RW-Split-Router my-listener-2')) .then(() => doCommand('destroy listener RW-Split-Router my-listener-2 --hosts ' + primary_host))
.then(() => doCommand('cluster sync ' + secondary_host + ' --hosts ' + primary_host)) .then(() => doCommand('cluster sync ' + primary_host + ' --hosts ' + secondary_host))
} else { } else {
// MaxScales are on different machines // MaxScales are on different machines
return doCommand('create listener RW-Split-Router my-listener-2 5999 --hosts ' + secondary_host) return doCommand('create listener RW-Split-Router my-listener-2 5999 --hosts ' + secondary_host)
// As both MaxScales are on the same machine, both can't listen on the same port. The sync should fail due to this
.then(() => doCommand('cluster sync ' + secondary_host + ' --hosts ' + primary_host)) .then(() => doCommand('cluster sync ' + secondary_host + ' --hosts ' + primary_host))
.then(() => doCommand('destroy listener RW-Split-Router my-listener-2')) .then(() => doCommand('destroy listener RW-Split-Router my-listener-2'))
.then(() => doCommand('cluster sync ' + secondary_host + ' --hosts ' + primary_host)) .then(() => doCommand('cluster sync ' + secondary_host + ' --hosts ' + primary_host))

View File

@ -7,7 +7,7 @@ datadir=@CMAKE_INSTALL_PREFIX@/secondary/lib/maxscale
cachedir=@CMAKE_INSTALL_PREFIX@/secondary/cache/maxscale cachedir=@CMAKE_INSTALL_PREFIX@/secondary/cache/maxscale
language=@CMAKE_INSTALL_PREFIX@/secondary/lib/maxscale/ language=@CMAKE_INSTALL_PREFIX@/secondary/lib/maxscale/
piddir=@CMAKE_INSTALL_PREFIX@/secondary/run/maxscale piddir=@CMAKE_INSTALL_PREFIX@/secondary/run/maxscale
config_persistdir=@CMAKE_INSTALL_PREFIX@/secondary/lib/maxscale/ persistdir=@CMAKE_INSTALL_PREFIX@/secondary/lib/maxscale/maxscale.cnf.d/
admin_auth=false admin_auth=false
admin_port=8990 admin_port=8990

View File

@ -9,13 +9,22 @@ maxscaledir=$MAXSCALE_DIR
test -z "$MAXSCALE_DIR" && exit 1 test -z "$MAXSCALE_DIR" && exit 1
# Create directories for the secondary MaxScale # Create directories for both MaxScales
rm -r $maxscaledir/lib/maxscale
rm -r $maxscaledir/cache/maxscale
rm -r $maxscaledir/run/maxscale
rm -r $maxscaledir/secondary/lib/maxscale rm -r $maxscaledir/secondary/lib/maxscale
rm -r $maxscaledir/secondary/cache/maxscale rm -r $maxscaledir/secondary/cache/maxscale
rm -r $maxscaledir/secondary/run/maxscale rm -r $maxscaledir/secondary/run/maxscale
test -f /tmp/maxadmin.sock && rm /tmp/maxadmin.sock
test -f /tmp/maxadmin2.sock && rm /tmp/maxadmin2.sock test -f /tmp/maxadmin2.sock && rm /tmp/maxadmin2.sock
mkdir -m 0755 -p $maxscaledir/secondary/lib/maxscale mkdir -m 0755 -p $maxscaledir/lib/maxscale/maxscale.cnf.d
mkdir -m 0755 -p $maxscaledir/cache/maxscale
mkdir -m 0755 -p $maxscaledir/run/maxscale
mkdir -m 0755 -p $maxscaledir/log/maxscale
mkdir -m 0755 -p $maxscaledir/secondary/lib/maxscale/maxscale.cnf.d
mkdir -m 0755 -p $maxscaledir/secondary/cache/maxscale mkdir -m 0755 -p $maxscaledir/secondary/cache/maxscale
mkdir -m 0755 -p $maxscaledir/secondary/run/maxscale mkdir -m 0755 -p $maxscaledir/secondary/run/maxscale
mkdir -m 0755 -p $maxscaledir/secondary/log/maxscale mkdir -m 0755 -p $maxscaledir/secondary/log/maxscale

View File

@ -9,6 +9,16 @@ maxscaledir=$MAXSCALE_DIR
test -z "$MAXSCALE_DIR" && exit 1 test -z "$MAXSCALE_DIR" && exit 1
rm -r $maxscaledir/lib/maxscale
rm -r $maxscaledir/cache/maxscale
rm -r $maxscaledir/run/maxscale
test -f /tmp/maxadmin.sock && rm /tmp/maxadmin.sock
mkdir -m 0755 -p $maxscaledir/lib/maxscale/maxscale.cnf.d
mkdir -m 0755 -p $maxscaledir/cache/maxscale
mkdir -m 0755 -p $maxscaledir/run/maxscale
mkdir -m 0755 -p $maxscaledir/log/maxscale
# Start MaxScale # Start MaxScale
$maxscaledir/bin/maxscale -df $maxscaledir/maxscale.cnf &>> $maxscaledir/maxscale.output & $maxscaledir/bin/maxscale -df $maxscaledir/maxscale.cnf &>> $maxscaledir/maxscale.output &
pid=$! pid=$!

View File

@ -1,8 +1,7 @@
#!/bin/bash #!/bin/bash
# #
# This script is run after each test block. It kills the two MaxScale processes # This script is run after each test block. It kills the two MaxScale processes.
# and cleans up the directories that contain generated files.
# #
maxscaledir=$MAXSCALE_DIR maxscaledir=$MAXSCALE_DIR
@ -18,12 +17,4 @@ done
# If it wasn't dead before, now it is # If it wasn't dead before, now it is
pkill -9 '^maxscale$' pkill -9 '^maxscale$'
rm -r $maxscaledir/lib/maxscale exit 0
rm -r $maxscaledir/cache/maxscale
rm -r $maxscaledir/run/maxscale
test -f /tmp/maxadmin.sock && rm /tmp/maxadmin.sock
test -f /tmp/maxadmin2.sock && rm /tmp/maxadmin2.sock
mkdir -m 0755 -p $maxscaledir/lib/maxscale
mkdir -m 0755 -p $maxscaledir/cache/maxscale
mkdir -m 0755 -p $maxscaledir/run/maxscale

View File

@ -1,8 +1,7 @@
#!/bin/bash #!/bin/bash
# #
# This script is run after each test block. It kills the MaxScale process # This script is run after each test block. It kills the MaxScale process.
# and cleans up the directories that contain generated files.
# #
maxscaledir=$MAXSCALE_DIR maxscaledir=$MAXSCALE_DIR
@ -18,11 +17,4 @@ done
# If it wasn't dead before, now it is # If it wasn't dead before, now it is
pkill -9 '^maxscale$' pkill -9 '^maxscale$'
rm -r $maxscaledir/lib/maxscale exit 0
rm -r $maxscaledir/cache/maxscale
rm -r $maxscaledir/run/maxscale
test -f /tmp/maxadmin.sock && rm /tmp/maxadmin.sock
mkdir -m 0755 -p $maxscaledir/lib/maxscale
mkdir -m 0755 -p $maxscaledir/cache/maxscale
mkdir -m 0755 -p $maxscaledir/run/maxscale