Files
MaxScale/test/start_double_maxscale.sh
Markus Mäkelä 47bcb6ad02 MXS-3345: Defer path permission checks
Doing the directory permission checks after all the values have been set
helps avoid problems with intermediate values that aren't valid. This
happens when --basedir generates invalid derived paths and the correct path
is provided as an argument right after it.

The path parameter is read from the configuration file only if it hasn't
been modified by a command line option. The case where an invalid command
line option is given but a valid configuration parameter would override it
is still treated as an error.

Also added a clarifying comment into set_dirs to make sure the handling
for the two path parameters is not moved inside set_runtime_dirs.

Fixed the testing scripts for the REST API and MaxCtrl now that the
directory permission checks are done correctly. Previously some paths seem
to have been ignored.
2021-02-09 17:36:41 +02:00

57 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
#
# This script is run before each test block. It starts two MaxScales and waits
# for them to become responsive.
#
maxscaledir=$MAXSCALE_DIR
test -z "$MAXSCALE_DIR" && exit 1
# 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/etc/maxscale.modules.d/
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/etc/maxscale.modules.d/
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
if [ "`whoami`" == "root" ]
then
user_opt="-U root"
fi
# Start MaxScale
$maxscaledir/bin/maxscale $user_opt -f $maxscaledir/maxscale.cnf &>> $maxscaledir/maxscale1.output || exit 1
# Start a second maxscale
$maxscaledir/bin/maxscale $user_opt -f $maxscaledir/maxscale_secondary.cnf &>> $maxscaledir/maxscale2.output || exit 1
# Wait for the MaxScales to start
for ((i=0;i<150;i++))
do
$maxscaledir/bin/maxctrl list servers >& /dev/null && \
$maxscaledir/bin/maxctrl --hosts 127.0.0.1:8990 list servers >& /dev/null && \
exit 0
sleep 0.1
done
# MaxScales failed to start, exit with an error
exit 1