From 1447ac2eb9f2803024863f50ce4e541f00cf493a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 9 Aug 2018 06:18:30 +0300 Subject: [PATCH] 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. --- maxctrl/test/cluster.js | 8 +++----- test/maxscale_test_secondary.cnf | 2 +- test/start_double_maxscale.sh | 13 +++++++++++-- test/start_maxscale.sh | 10 ++++++++++ test/stop_double_maxscale.sh | 13 ++----------- test/stop_maxscale.sh | 12 ++---------- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/maxctrl/test/cluster.js b/maxctrl/test/cluster.js index 94fe67045..5a1658012 100644 --- a/maxctrl/test/cluster.js +++ b/maxctrl/test/cluster.js @@ -224,14 +224,12 @@ describe('Cluster Sync', function() { .then(() => doCommand('create listener RW-Split-Router my-listener-2 5998 --hosts ' + primary_host)) // Sync after creation should succeed .then(() => doCommand('cluster sync ' + secondary_host + ' --hosts ' + primary_host)) - // Destroy the created server, should succeed - .then(() => doCommand('destroy listener RW-Split-Router my-listener-2')) - .then(() => doCommand('cluster sync ' + secondary_host + ' --hosts ' + primary_host)) + // Destroy the created listener, should succeed + .then(() => doCommand('destroy listener RW-Split-Router my-listener-2 --hosts ' + primary_host)) + .then(() => doCommand('cluster sync ' + primary_host + ' --hosts ' + secondary_host)) } else { // MaxScales are on different machines - 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('destroy listener RW-Split-Router my-listener-2')) .then(() => doCommand('cluster sync ' + secondary_host + ' --hosts ' + primary_host)) diff --git a/test/maxscale_test_secondary.cnf b/test/maxscale_test_secondary.cnf index a99a62c2d..e5af32ffa 100644 --- a/test/maxscale_test_secondary.cnf +++ b/test/maxscale_test_secondary.cnf @@ -7,7 +7,7 @@ datadir=@CMAKE_INSTALL_PREFIX@/secondary/lib/maxscale cachedir=@CMAKE_INSTALL_PREFIX@/secondary/cache/maxscale language=@CMAKE_INSTALL_PREFIX@/secondary/lib/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_port=8990 diff --git a/test/start_double_maxscale.sh b/test/start_double_maxscale.sh index a82631131..889ec969f 100755 --- a/test/start_double_maxscale.sh +++ b/test/start_double_maxscale.sh @@ -9,13 +9,22 @@ maxscaledir=$MAXSCALE_DIR 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/cache/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 -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/run/maxscale mkdir -m 0755 -p $maxscaledir/secondary/log/maxscale diff --git a/test/start_maxscale.sh b/test/start_maxscale.sh index 53ff3bee1..9504506e3 100755 --- a/test/start_maxscale.sh +++ b/test/start_maxscale.sh @@ -9,6 +9,16 @@ maxscaledir=$MAXSCALE_DIR 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 $maxscaledir/bin/maxscale -df $maxscaledir/maxscale.cnf &>> $maxscaledir/maxscale.output & pid=$! diff --git a/test/stop_double_maxscale.sh b/test/stop_double_maxscale.sh index 8d588011f..b4eca7494 100755 --- a/test/stop_double_maxscale.sh +++ b/test/stop_double_maxscale.sh @@ -1,8 +1,7 @@ #!/bin/bash # -# This script is run after each test block. It kills the two MaxScale processes -# and cleans up the directories that contain generated files. +# This script is run after each test block. It kills the two MaxScale processes. # maxscaledir=$MAXSCALE_DIR @@ -18,12 +17,4 @@ done # If it wasn't dead before, now it is pkill -9 '^maxscale$' -rm -r $maxscaledir/lib/maxscale -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 +exit 0 diff --git a/test/stop_maxscale.sh b/test/stop_maxscale.sh index b948c5b57..af9cb41d6 100755 --- a/test/stop_maxscale.sh +++ b/test/stop_maxscale.sh @@ -1,8 +1,7 @@ #!/bin/bash # -# This script is run after each test block. It kills the MaxScale process -# and cleans up the directories that contain generated files. +# This script is run after each test block. It kills the MaxScale process. # maxscaledir=$MAXSCALE_DIR @@ -18,11 +17,4 @@ done # If it wasn't dead before, now it is pkill -9 '^maxscale$' -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 -mkdir -m 0755 -p $maxscaledir/cache/maxscale -mkdir -m 0755 -p $maxscaledir/run/maxscale +exit 0