MXS-1220: Simplify test creation

The tests now automatically start MaxScale before each test block and stop
it and perform cleanup after the test. This is done by simply calling the
`before.sh` and `after.sh` scripts before each test block.
This commit is contained in:
Markus Mäkelä
2017-05-04 16:21:37 +03:00
parent 6b0fabf834
commit a3c683ab87
5 changed files with 78 additions and 15 deletions

View File

@ -0,0 +1,38 @@
#!/bin/bash
#
# This script is run after each test block. It kills the MaxScale process
# and cleans up the directories that contain generated files.
#
test -z "$MAXSCALE_DIR" && exit 1
maxscaledir=$MAXSCALE_DIR
pid=`cat $maxscaledir/maxscale.pid`
echo $pid
for ((i=0;i<60;i++))
do
kill -0 $pid
if [ $? -eq 0 ]
then
# Process is still up
kill $pid
if [ $i -gt 3 ]
then
sleep 0.1
fi
else
break
fi
done
rm -r $maxscaledir/lib/maxscale
rm -r $maxscaledir/cache/maxscale
rm -r $maxscaledir/run/maxscale
mkdir -m 0755 -p $maxscaledir/lib/maxscale
mkdir -m 0755 -p $maxscaledir/cache/maxscale
mkdir -m 0755 -p $maxscaledir/run/maxscale