Make NPM tests runnable by root
The tests can now be run as root. This is most likely required in some cases and it should not break things if they are run as root (e.g. inside a VM with no other users). NPM prevents the use of the root user (due to modules getting root access) and uses an unprivileged user to install the modules. As maxctrl has to generate the version information at install time, running `npm install` as root will fail due to missing privileges to the current working directory. To work around this, an explicit step was added. Also changed the maxadmin checks to maxctrl to remove the dependency on the socket file location being writable by non-root users (/var/run/maxscale/ might not be accessible to all users).
This commit is contained in:
parent
c495abcca7
commit
a399c58df3
@ -30,6 +30,9 @@ cp -t $testdir -r $testsrc/*
|
||||
# Required by MaxCtrl (not super pretty)
|
||||
cp -t $testdir/.. $srcdir/VERSION*.cmake
|
||||
|
||||
# This avoids running npm as root if we're executing the tests as root (MaxCtrl specific)
|
||||
(cd $testdir && test -f configure_version.cmake && cmake -P configure_version.cmake)
|
||||
|
||||
# Copy required docker-compose files to the MaxScale directory and bring MariaDB
|
||||
# servers up. This is an asynchronous process.
|
||||
cd $maxscaledir
|
||||
|
@ -29,25 +29,27 @@ 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 -df $maxscaledir/maxscale.cnf &>> $maxscaledir/maxscale1.output &
|
||||
$maxscaledir/bin/maxscale $user_opt -f $maxscaledir/maxscale.cnf &>> $maxscaledir/maxscale1.output
|
||||
|
||||
# Wait for the first MaxScale to start
|
||||
for ((i=0;i<60;i++))
|
||||
for ((i=0;i<150;i++))
|
||||
do
|
||||
$maxscaledir/bin/maxadmin help >& /dev/null && break
|
||||
$maxscaledir/bin/maxctrl list servers >& /dev/null && break
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
# Start a second maxscale
|
||||
$maxscaledir/bin/maxscale -df $maxscaledir/maxscale_secondary.cnf &>> $maxscaledir/maxscale2.output &
|
||||
$maxscaledir/bin/maxscale $user_opt -f $maxscaledir/maxscale_secondary.cnf &>> $maxscaledir/maxscale2.output
|
||||
|
||||
# Wait for the second MaxScale to start
|
||||
for ((i=0;i<60;i++))
|
||||
for ((i=0;i<150;i++))
|
||||
do
|
||||
$maxscaledir/bin/maxadmin -S /tmp/maxadmin2.sock help >& /dev/null && break
|
||||
$maxscaledir/bin/maxctrl --hosts 127.0.0.1:8990 list servers >& /dev/null && break
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
# Give MaxScale some time to settle
|
||||
sleep 1
|
||||
|
@ -19,16 +19,17 @@ mkdir -m 0755 -p $maxscaledir/cache/maxscale
|
||||
mkdir -m 0755 -p $maxscaledir/run/maxscale
|
||||
mkdir -m 0755 -p $maxscaledir/log/maxscale
|
||||
|
||||
if [ "`whoami`" == "root" ]
|
||||
then
|
||||
user_opt="-U root"
|
||||
fi
|
||||
|
||||
# Start MaxScale
|
||||
$maxscaledir/bin/maxscale -df $maxscaledir/maxscale.cnf &>> $maxscaledir/maxscale.output &
|
||||
pid=$!
|
||||
$maxscaledir/bin/maxscale $user_opt -f $maxscaledir/maxscale.cnf &>> $maxscaledir/maxscale.output
|
||||
|
||||
# Wait for MaxScale to start
|
||||
for ((i=0;i<60;i++))
|
||||
for ((i=0;i<150;i++))
|
||||
do
|
||||
$maxscaledir/bin/maxadmin help >& /dev/null && break
|
||||
$maxscaledir/bin/maxctrl list servers >& /dev/null && break
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
# Give MaxScale some time to settle
|
||||
sleep 1
|
||||
|
@ -8,10 +8,10 @@ maxscaledir=$MAXSCALE_DIR
|
||||
|
||||
test -z "$MAXSCALE_DIR" && exit 1
|
||||
|
||||
for ((i=0;i<20;i++))
|
||||
for ((i=0;i<200;i++))
|
||||
do
|
||||
pkill '^maxscale$' || break
|
||||
sleep 0.5
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
# If it wasn't dead before, now it is
|
||||
|
@ -8,10 +8,10 @@ maxscaledir=$MAXSCALE_DIR
|
||||
|
||||
test -z "$MAXSCALE_DIR" && exit 1
|
||||
|
||||
for ((i=0;i<20;i++))
|
||||
for ((i=0;i<200;i++))
|
||||
do
|
||||
pkill '^maxscale$' || break
|
||||
sleep 0.5
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
# If it wasn't dead before, now it is
|
||||
|
Loading…
x
Reference in New Issue
Block a user