From 064ad8fa4f27eaaaecea82785b6b440d654a73cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 10 Aug 2018 21:00:07 +0300 Subject: [PATCH] Improve MaxScale startup and shutdown in NPM tests The tests are now less violent in how they stop MaxScale. Also the logs are now removed before a new test run is executed. --- test/maxscale_test.cnf | 1 - test/maxscale_test_secondary.cnf | 1 - test/run_npm_test.sh | 2 ++ test/stop_double_maxscale.sh | 19 +------------------ test/stop_maxscale.sh | 8 +++++--- 5 files changed, 8 insertions(+), 23 deletions(-) diff --git a/test/maxscale_test.cnf b/test/maxscale_test.cnf index 70b985648..d2a9ff810 100644 --- a/test/maxscale_test.cnf +++ b/test/maxscale_test.cnf @@ -1,6 +1,5 @@ [maxscale] threads=4 -log_info=1 libdir=@CMAKE_INSTALL_PREFIX@/@MAXSCALE_LIBDIR@ logdir=@CMAKE_INSTALL_PREFIX@/log/maxscale/ datadir=@CMAKE_INSTALL_PREFIX@/lib/maxscale diff --git a/test/maxscale_test_secondary.cnf b/test/maxscale_test_secondary.cnf index e5af32ffa..d0eb78095 100644 --- a/test/maxscale_test_secondary.cnf +++ b/test/maxscale_test_secondary.cnf @@ -1,6 +1,5 @@ [maxscale] threads=4 -log_info=1 libdir=@CMAKE_INSTALL_PREFIX@/@MAXSCALE_LIBDIR@ logdir=@CMAKE_INSTALL_PREFIX@/secondary/log/maxscale/ datadir=@CMAKE_INSTALL_PREFIX@/secondary/lib/maxscale diff --git a/test/run_npm_test.sh b/test/run_npm_test.sh index 1361124c2..9070e0b0f 100755 --- a/test/run_npm_test.sh +++ b/test/run_npm_test.sh @@ -18,6 +18,8 @@ testdir=$3 maxscaledir=$PWD/maxscale_test/ +rm -f $maxscaledir/maxscale{,1,2}.output $maxscaledir/{,secondary/}log/maxscale/maxscale.log + # Create the test directories mkdir -p $maxscaledir $testdir diff --git a/test/stop_double_maxscale.sh b/test/stop_double_maxscale.sh index d0cd55ef6..300125d6e 100755 --- a/test/stop_double_maxscale.sh +++ b/test/stop_double_maxscale.sh @@ -1,20 +1,3 @@ #!/bin/bash -# -# This script is run after each test block. It kills the two MaxScale processes. -# - -maxscaledir=$MAXSCALE_DIR - -test -z "$MAXSCALE_DIR" && exit 1 - -for ((i=0;i<200;i++)) -do - pkill '^maxscale$' || break - sleep 0.1 -done - -# If it wasn't dead before, now it is -pkill -9 '^maxscale$' - -exit 0 +./stop_maxscale.sh diff --git a/test/stop_maxscale.sh b/test/stop_maxscale.sh index a086f86d1..4d3da6c7c 100755 --- a/test/stop_maxscale.sh +++ b/test/stop_maxscale.sh @@ -8,13 +8,15 @@ maxscaledir=$MAXSCALE_DIR test -z "$MAXSCALE_DIR" && exit 1 -for ((i=0;i<200;i++)) +pkill '^maxscale$' + +for ((i=0;i<100;i++)) do - pkill '^maxscale$' || break + pgrep '^maxscale$' &> /dev/null || break sleep 0.1 done # If it wasn't dead before, now it is -pkill -9 '^maxscale$' +pgrep '^maxscale$' &> /dev/null && pkill -11 '^maxscale$' exit 0