Don't assume source and binary directories are the same

Some of the scripts assumed that other scripts would be located in the
same directory where the current script was executed.

Also fixed the SSL connection creation which depended on an obsolete
environment variable causing all out-of-source SSL tests to fail.
This commit is contained in:
Markus Mäkelä
2018-05-11 00:10:24 +03:00
parent 16b777ad17
commit b776ed7821
17 changed files with 88 additions and 74 deletions

View File

@ -8,6 +8,7 @@
rp=`realpath $0` rp=`realpath $0`
export src_dir=`dirname $rp`
export test_dir=`pwd` export test_dir=`pwd`
export test_name=`basename $rp` export test_name=`basename $rp`
@ -17,7 +18,7 @@ if [ $? -ne 0 ] ; then
echo "configuring maxscale failed" echo "configuring maxscale failed"
exit 1 exit 1
fi fi
export ssl_options="--ssl-cert=$test_dir/ssl-cert/client-cert.pem --ssl-key=$test_dir/ssl-cert/client-key.pem" export ssl_options="--ssl-cert=$src_dir/ssl-cert/client-cert.pem --ssl-key=$src_dir/ssl-cert/client-key.pem"
#echo "Waiting for 15 seconds" #echo "Waiting for 15 seconds"
#sleep 15 #sleep 15
@ -69,5 +70,5 @@ else
echo "Messages are same" echo "Messages are same"
fi fi
$test_dir/copy_logs.sh bug561 $src_dir/copy_logs.sh bug561
exit $res exit $res

View File

@ -6,6 +6,7 @@
## - compare error messages ## - compare error messages
rp=`realpath $0` rp=`realpath $0`
export src_dir=`dirname $rp`
export test_dir=`pwd` export test_dir=`pwd`
export test_name=`basename $rp` export test_name=`basename $rp`
@ -15,7 +16,7 @@ if [ $? -ne 0 ] ; then
echo "configuring maxscale failed" echo "configuring maxscale failed"
exit 1 exit 1
fi fi
export ssl_options="--ssl-cert=$test_dir/ssl-cert/client-cert.pem --ssl-key=$test_dir/ssl-cert/client-key.pem" export ssl_options="--ssl-cert=$src_dir/ssl-cert/client-cert.pem --ssl-key=$src_dir/ssl-cert/client-key.pem"
mariadb_err=`mysql -u no_such_user -psome_pwd -h $node_001_network $ssl_option --socket=$node_000_socket test 2>&1` mariadb_err=`mysql -u no_such_user -psome_pwd -h $node_001_network $ssl_option --socket=$node_000_socket test 2>&1`
maxscale_err=`mysql -u no_such_user -psome_pwd -h $maxscale_IP -P 4006 $ssl_options test 2>&1` maxscale_err=`mysql -u no_such_user -psome_pwd -h $maxscale_IP -P 4006 $ssl_options test 2>&1`
@ -38,5 +39,5 @@ else
res=0 res=0
fi fi
$test_dir/copy_logs.sh bug562 $src_dir/copy_logs.sh bug562
exit $res exit $res

View File

@ -6,6 +6,7 @@
## - check output of SHOW VARIABLES LIKE 'char%' ## - check output of SHOW VARIABLES LIKE 'char%'
rp=`realpath $0` rp=`realpath $0`
export src_dir=`dirname $rp`
export test_dir=`pwd` export test_dir=`pwd`
export test_name=`basename $rp` export test_name=`basename $rp`
$test_dir/non_native_setup $test_name $test_dir/non_native_setup $test_name
@ -14,7 +15,7 @@ if [ $? -ne 0 ] ; then
echo "configuring maxscale failed" echo "configuring maxscale failed"
exit 1 exit 1
fi fi
export ssl_options="--ssl-cert=$test_dir/ssl-cert/client-cert.pem --ssl-key=$test_dir/ssl-cert/client-key.pem" export ssl_options="--ssl-cert=$src_dir/ssl-cert/client-cert.pem --ssl-key=$src_dir/ssl-cert/client-key.pem"
for char_set in "latin1" "latin2" for char_set in "latin1" "latin2"
do do
@ -34,11 +35,9 @@ do
if [[ $res1 != 0 ]] || [[ $res2 != 0 ]] || [[ $res3 != 0 ]] ; then if [[ $res1 != 0 ]] || [[ $res2 != 0 ]] || [[ $res3 != 0 ]] ; then
echo "charset is ignored" echo "charset is ignored"
mysql -u$node_user -p$node_password -h $maxscale_IP -P 4006 $ssl_options --default-character-set="latin2" -e "SHOW VARIABLES LIKE 'char%'" mysql -u$node_user -p$node_password -h $maxscale_IP -P 4006 $ssl_options --default-character-set="latin2" -e "SHOW VARIABLES LIKE 'char%'"
$test_dir/copy_logs.sh bug564 $src_dir/copy_logs.sh bug564
exit 1 exit 1
fi fi
done done
$test_dir/copy_logs.sh bug564 $src_dir/copy_logs.sh bug564
exit 0 exit 0

View File

@ -6,6 +6,7 @@
## check if Maxscale is alive ## check if Maxscale is alive
rp=`realpath $0` rp=`realpath $0`
export src_dir=`dirname $rp`
export test_dir=`pwd` export test_dir=`pwd`
export test_name=`basename $rp` export test_name=`basename $rp`
$test_dir/non_native_setup $test_name $test_dir/non_native_setup $test_name
@ -14,7 +15,7 @@ if [ $? -ne 0 ] ; then
echo "configuring maxscale failed" echo "configuring maxscale failed"
exit 1 exit 1
fi fi
export ssl_options="--ssl-cert=$test_dir/ssl-cert/client-cert.pem --ssl-key=$test_dir/ssl-cert/client-key.pem" export ssl_options="--ssl-cert=$src_dir/ssl-cert/client-cert.pem --ssl-key=$src_dir/ssl-cert/client-key.pem"
#pid=`ssh -i $maxscale_sshkey -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $maxscale_access_user@$maxscale_IP "pgrep maxscale"` #pid=`ssh -i $maxscale_sshkey -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null $maxscale_access_user@$maxscale_IP "pgrep maxscale"`
#echo "Maxscale pid is $pid" #echo "Maxscale pid is $pid"
@ -29,6 +30,6 @@ echo "checking if Maxscale is alive"
echo "show databases;" | mysql -u$node_user -p$node_password -h $maxscale_IP -P 4006 $ssl_options echo "show databases;" | mysql -u$node_user -p$node_password -h $maxscale_IP -P 4006 $ssl_options
res=$? res=$?
$test_dir/copy_logs.sh bug567 $src_dir/copy_logs.sh bug567
exit $res exit $res

View File

@ -1,5 +1,8 @@
#!/bin/bash #!/bin/bash
rp=`realpath $0`
export src_dir=`dirname $rp`
user=skysql user=skysql
password=skysql password=skysql
@ -15,18 +18,20 @@ function run_test
local test_name=$1 local test_name=$1
echo $test_name echo $test_name
logdir=log_$test_name
mkdir -p $logdir
mysqltest --host=$maxscale_IP --port=$port \ mysqltest --host=$maxscale_IP --port=$port \
--user=$user --password=$password \ --user=$user --password=$password \
--logdir=log \ --logdir=$logdir \
--test-file=t/$test_name.test \ --test-file=$dir/t/$test_name.test \
--result-file=r/$test_name.result \ --result-file=$dir/r/$test_name.result \
--silent --silent
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
echo " OK" echo " OK"
rc=0 rc=0
else else
echo " FAILED" echo " FAILED"
rc=1 rc=1
@ -57,7 +62,9 @@ then
echo "warning: Expected test name to be $expected_name_basic, was $1." echo "warning: Expected test name to be $expected_name_basic, was $1."
fi fi
source=cache/$1/cache_rules.json export dir="$src_dir/cache/$expected_name"
source=$src_dir/cache/$1/cache_rules.json
target=vagrant@$maxscale_IP:/home/$maxscale_access_user/cache_rules.json target=vagrant@$maxscale_IP:/home/$maxscale_access_user/cache_rules.json
if [ $maxscale_IP != "127.0.0.1" ] ; then if [ $maxscale_IP != "127.0.0.1" ] ; then
@ -78,11 +85,6 @@ test_dir=`pwd`
$test_dir/non_native_setup $1 $test_dir/non_native_setup $1
cd cache/$expected_name
[ -d log ] && rm -r log
mkdir log || exit 1
echo echo
# We sleep slightly longer than the TTL to ensure that the TTL mechanism # We sleep slightly longer than the TTL to ensure that the TTL mechanism

View File

@ -1,4 +1,8 @@
#!/bin/bash #!/bin/bash
rp=`realpath $0`
export src_dir=`dirname $rp`
./non_native_setup insertstream ./non_native_setup insertstream
./mysqltest_driver.sh insertstream insertstream 4006
$src_dir/mysqltest_driver.sh insertstream $src_dir/insertstream 4006

View File

@ -1,29 +1,30 @@
#!/bin/bash #!/bin/bash
rp=`realpath $0` rp=`realpath $0`
export src_dir=`dirname $rp`
export test_dir=`pwd` export test_dir=`pwd`
export test_name=`basename $rp` export test_name=`basename $rp`
$test_dir/non_native_setup $test_name $test_dir/non_native_setup $test_name
export ssl_options="--ssl-cert=$test_dir/ssl-cert/client-cert.pem --ssl-key=$test_dir/ssl-cert/client-key.pem" export ssl_options="--ssl-cert=$src_dir/ssl-cert/client-cert.pem --ssl-key=$src_dir/ssl-cert/client-key.pem"
IP=$Maxscale_IP IP=$Maxscale_IP
mysql -h $IP -P 4006 -u $node_user -p$node_password $ssl_options < $test_dir/long_insert_sql/test_init.sql mysql -h $IP -P 4006 -u $node_user -p$node_password $ssl_options < $src_dir/long_insert_sql/test_init.sql
echo "RWSplit router:" echo "RWSplit router:"
for ((i=0 ; i<1000 ; i++)) ; do for ((i=0 ; i<1000 ; i++)) ; do
echo "iteration: $i" echo "iteration: $i"
mysql -h $IP -P 4006 -u $node_user -p$node_password $ssl_options < $test_dir/long_insert_sql/test_query.sql mysql -h $IP -P 4006 -u $node_user -p$node_password $ssl_options < $src_dir/long_insert_sql/test_query.sql
done done
echo "ReadConn router (master):" echo "ReadConn router (master):"
for ((i=0 ; i<1000 ; i++)) ; do for ((i=0 ; i<1000 ; i++)) ; do
echo "iteration: $i" echo "iteration: $i"
mysql -h $IP -P 4008 -u $node_user -p$node_uassword $ssl_options < $test_dir/long_insert_sql/test_query.sql mysql -h $IP -P 4008 -u $node_user -p$node_uassword $ssl_options < $src_dir/long_insert_sql/test_query.sql
done done
res=$? res=$?
$test_dir/copy_logs.sh long_insert $src_dir/copy_logs.sh long_insert
exit $res exit $res

View File

@ -12,6 +12,7 @@
#include "mariadb_func.h" #include "mariadb_func.h"
#include "templates.h"
#include <ctype.h> #include <ctype.h>
#include <sstream> #include <sstream>
@ -20,20 +21,11 @@ int set_ssl(MYSQL* conn)
char client_key[1024]; char client_key[1024];
char client_cert[1024]; char client_cert[1024];
char ca[1024]; char ca[1024];
char* test_dir = getenv("test_dir");
if (test_dir == NULL) sprintf(client_key, "%s/ssl-cert/client-key.pem", test_dir);
{ sprintf(client_cert, "%s/ssl-cert/client-cert.pem", test_dir);
sprintf(client_key, "./ssl-cert/client-key.pem"); sprintf(ca, "%s/ssl-cert/ca.pem", test_dir);
sprintf(client_cert, "./ssl-cert/client-cert.pem");
sprintf(ca, "./ssl-cert/ca.pem");
}
else
{
sprintf(client_key, "%s/ssl-cert/client-key.pem", test_dir);
sprintf(client_cert, "%s/ssl-cert/client-cert.pem", test_dir);
sprintf(ca, "%s/ssl-cert/ca.pem", test_dir);
}
return mysql_ssl_set(conn, client_key, client_cert, ca, NULL, NULL); return mysql_ssl_set(conn, client_key, client_cert, ca, NULL, NULL);
} }

View File

@ -4,15 +4,20 @@
# #
# TODO: Don't test correctness of routing with mysqltest # TODO: Don't test correctness of routing with mysqltest
# #
rp=`realpath $0`
export src_dir=`dirname $rp`
# TODO: Don't copy this and "unmangle" the test instead
cp -r $src_dir/Hartmut_tests/maxscale-mysqltest ./Hartmut_tests/maxscale-mysqltest/
master_id=`echo "SELECT @@server_id" | mysql -u$node_user -p$node_password -h $node_000_network $ssl_options -P $node_000_port | tail -n1` master_id=`echo "SELECT @@server_id" | mysql -u$node_user -p$node_password -h $node_000_network $ssl_options -P $node_000_port | tail -n1`
echo "--disable_query_log" > Hartmut_tests/maxscale-mysqltest/testconf.inc echo "--disable_query_log" > Hartmut_tests/maxscale-mysqltest/testconf.inc
echo "SET @TMASTER_ID=$master_id;" >> Hartmut_tests/maxscale-mysqltest/testconf.inc echo "SET @TMASTER_ID=$master_id;" >> Hartmut_tests/maxscale-mysqltest/testconf.inc
echo "--enable_query_log" >> Hartmut_tests/maxscale-mysqltest/testconf.inc echo "--enable_query_log" >> Hartmut_tests/maxscale-mysqltest/testconf.inc
./mysqltest_driver.sh $1 Hartmut_tests/maxscale-mysqltest 4006 $src_dir/mysqltest_driver.sh $1 $PWD/Hartmut_tests/maxscale-mysqltest 4006
ret=$? ret=$?
./copy_logs.sh $1 $src_dir/copy_logs.sh $1
exit $ret exit $ret

View File

@ -19,7 +19,8 @@ then
exit 1 exit 1
fi fi
source=masking/$1/masking_rules.json src_dir=$(dirname $(realpath $0))
source=$src_dir/masking/$1/masking_rules.json
target=$maxscale_access_user@$maxscale_IP:/home/$maxscale_access_user/masking_rules.json target=$maxscale_access_user@$maxscale_IP:/home/$maxscale_access_user/masking_rules.json
if [ $maxscale_IP != "127.0.0.1" ] ; then if [ $maxscale_IP != "127.0.0.1" ] ; then
@ -55,4 +56,4 @@ fi
# [Read Connection Listener Master] in cnf/maxscale.maxscale.cnf.template.$1 # [Read Connection Listener Master] in cnf/maxscale.maxscale.cnf.template.$1
port=4008 port=4008
./mysqltest_driver.sh $1 ./masking/$1 $port $user $password $src_dir/mysqltest_driver.sh $1 $src_dir/masking/$1 $port $user $password

View File

@ -17,7 +17,9 @@ then
exit 1 exit 1
fi fi
source=masking/$1/masking_rules.json src_dir=$(dirname $(realpath $0))
echo "src_dir: $src_dir"
source=$src_dir/masking/$1/masking_rules.json
target=vagrant@$maxscale_IP:/home/$maxscale_access_user/masking_rules.json target=vagrant@$maxscale_IP:/home/$maxscale_access_user/masking_rules.json
if [ $maxscale_IP != "127.0.0.1" ] ; then if [ $maxscale_IP != "127.0.0.1" ] ; then
@ -37,22 +39,23 @@ echo $source copied to $target
test_dir=`pwd` test_dir=`pwd`
$test_dir/non_native_setup $1 $test_dir/non_native_setup $1
logdir=log_$1
cd masking/$1 [ -d $logdir ] && rm -r $logdir
[ -d log ] && rm -r log mkdir $logdir || exit 1
mkdir log || exit 1
# [Read Connection Listener Master] in cnf/maxscale.maxscale.cnf.template.$1 # [Read Connection Listener Master] in cnf/maxscale.maxscale.cnf.template.$1
port=4008 port=4008
password=skysql password=skysql
dir="$src_dir/masking/$1"
user=skysql user=skysql
test_name=masking_user test_name=masking_user
mysqltest --host=$maxscale_IP --port=$port \ mysqltest --host=$maxscale_IP --port=$port \
--user=$user --password=$password \ --user=$user --password=$password \
--logdir=log \ --logdir=$logdir \
--test-file=t/$test_name.test \ --test-file=$dir/t/$test_name.test \
--result-file=r/"$test_name"_"$user".result \ --result-file=$dir/r/"$test_name"_"$user".result \
--silent --silent
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
@ -66,9 +69,9 @@ user=maxskysql
test_name=masking_user test_name=masking_user
mysqltest --host=$maxscale_IP --port=$port \ mysqltest --host=$maxscale_IP --port=$port \
--user=$user --password=$password \ --user=$user --password=$password \
--logdir=log \ --logdir=$logdir \
--test-file=t/$test_name.test \ --test-file=$dir/t/$test_name.test \
--result-file=r/"$test_name"_"$user".result \ --result-file=$dir/r/"$test_name"_"$user".result \
--silent --silent
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
@ -81,6 +84,6 @@ fi
echo echo
# Copy logs from the VM # Copy logs from the VM
$test_dir/copy_logs.sh $1 $src_dir/copy_logs.sh $1
exit $res exit $res

View File

@ -68,8 +68,10 @@ int main(int argc, char* argv[])
TestConnections::skip_maxscale_start(true); TestConnections::skip_maxscale_start(true);
TestConnections test(argc, argv); TestConnections test(argc, argv);
std::string src = test_dir;
src += "/mxs1719.json";
if (test.maxscales->copy_to_node(0, "./mxs1719.json", "/home/vagrant/mxs1719.json") == 0) if (test.maxscales->copy_to_node(0, src.c_str(), "/home/vagrant/mxs1719.json") == 0)
{ {
if (test.maxscales->start() == 0) if (test.maxscales->start() == 0)
{ {

View File

@ -1,12 +1,14 @@
#!/bin/bash #!/bin/bash
rp=`realpath $0`
export src_dir=`dirname $rp`
$PWD/non_native_setup $test_name $PWD/non_native_setup $test_name
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
echo "configuring maxscale failed" echo "configuring maxscale failed"
exit 1 exit 1
fi fi
export ssl_options="--ssl-cert=$test_dir/ssl-cert/client-cert.pem --ssl-key=$test_dir/ssl-cert/client-key.pem" export ssl_options="--ssl-cert=$src_dir/ssl-cert/client-cert.pem --ssl-key=$src_dir/ssl-cert/client-key.pem"
res=0 res=0
echo "Trying RWSplit" echo "Trying RWSplit"

View File

@ -22,7 +22,7 @@ int main(int argc, char *argv[])
MYSQL *conn = open_conn(test->maxscales->readconn_master_port[0], test->maxscales->IP[0], MYSQL *conn = open_conn(test->maxscales->readconn_master_port[0], test->maxscales->IP[0],
test->maxscales->user_name, test->maxscales->user_name,
test->maxscales->password, true); test->maxscales->password, true);
test->add_result(execute_query(conn, "select @@server_id"), "SSL query failed"); test->add_result(execute_query(conn, "select @@server_id"), "SSL query to readconnroute failed");
mysql_close(conn); mysql_close(conn);
test->check_maxscale_processes(0, 1); test->check_maxscale_processes(0, 1);

View File

@ -36,26 +36,24 @@ fi
test_dir=`pwd` test_dir=`pwd`
port=$3 port=$3
cd $2 || exit 1
res=0 res=0
# Create a directory for the mysqltest logs # Create a directory for the mysqltest logs
[ -d log ] && rm -r log [ -d log_$1 ] && rm -r log_$1
mkdir log || exit 1 mkdir log_$1
echo echo
# Run the test # Run the test
for t in `cd t; ls *.test` for t in `$2/t/*.test|xargs -L 1 basename`
do do
printf "$t:" printf "$t:"
test_name=${t%%.test} test_name=${t%%.test}
mysqltest --host=$maxscale_IP --port=$port \ mysqltest --host=$maxscale_IP --port=$port \
--user=$user --password=$password \ --user=$user --password=$password \
--logdir=log \ --logdir=log_$1 \
--test-file=t/$test_name.test \ --test-file=$2/t/$test_name.test \
--result-file=r/$test_name.result \ --result-file=$2/r/$test_name.result \
--silent --silent
if [ $? -eq 0 ] if [ $? -eq 0 ]
@ -70,6 +68,6 @@ done
echo echo
# Copy logs from the VM # Copy logs from the VM
$test_dir/copy_logs.sh $1 $src_dir/copy_logs.sh $1
exit $res exit $res

View File

@ -5,6 +5,7 @@
## check that Maxscale is reacting correctly on ctrc+c signal and termination does not take ages ## check that Maxscale is reacting correctly on ctrc+c signal and termination does not take ages
rp=`realpath $0` rp=`realpath $0`
export src_dir=`dirname $rp`
export test_dir=`pwd` export test_dir=`pwd`
export test_name=`basename $rp` export test_name=`basename $rp`
@ -20,12 +21,12 @@ if [ $? -ne 0 ] ; then
exit 1 exit 1
fi fi
scp -i $maxscale_sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -r $test_dir/test_ctrl_c/* $maxscale_access_user@$maxscale_IP:./ scp -i $maxscale_sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -r $src_dir/test_ctrl_c/* $maxscale_access_user@$maxscale_IP:./
ssh -i $maxscale_sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $maxscale_access_user@$maxscale_IP "export maxscale_access_sudo=$maxscale_access_sudo; ./test_ctrl_c.sh" ssh -i $maxscale_sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $maxscale_access_user@$maxscale_IP "export maxscale_access_sudo=$maxscale_access_sudo; ./test_ctrl_c.sh"
res=$? res=$?
ssh -i $maxscale_sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $maxscale_access_user@$maxscale_IP "sudo rm -f /tmp/maxadmin.sock" ssh -i $maxscale_sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $maxscale_access_user@$maxscale_IP "sudo rm -f /tmp/maxadmin.sock"
$test_dir/copy_logs.sh run_ctrl_c $src_dir/copy_logs.sh run_ctrl_c
exit $res exit $res

View File

@ -5,6 +5,7 @@
## run a set of queries in the loop (see setmix.sql) using Perl client ## run a set of queries in the loop (see setmix.sql) using Perl client
rp=`realpath $0` rp=`realpath $0`
export src_dir=`dirname $rp`
export test_dir=`pwd` export test_dir=`pwd`
export test_name=`basename $rp` export test_name=`basename $rp`
@ -15,7 +16,7 @@ then
echo "configuring maxscale failed" echo "configuring maxscale failed"
exit 1 exit 1
fi fi
export ssl_options="--ssl-cert=$test_dir/ssl-cert/client-cert.pem --ssl-key=$test_dir/ssl-cert/client-key.pem" export ssl_options="--ssl-cert=$src_dir/ssl-cert/client-cert.pem --ssl-key=$src_dir/ssl-cert/client-key.pem"
echo "drop table if exists t1; create table t1(id integer primary key); " | mysql -u$node_user -p$node_password -h$maxscale_IP -P 4006 $ssl_options test echo "drop table if exists t1; create table t1(id integer primary key); " | mysql -u$node_user -p$node_password -h$maxscale_IP -P 4006 $ssl_options test
@ -27,8 +28,8 @@ fi
res=0 res=0
$test_dir/session_hang/run_setmix.sh & $src_dir/session_hang/run_setmix.sh &
perl $test_dir/session_hang/simpletest.pl perl $src_dir/session_hang/simpletest.pl
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
res=1 res=1
@ -52,6 +53,6 @@ else
echo "Test PASSED" echo "Test PASSED"
fi fi
$test_dir/copy_logs.sh run_session_hang $src_dir/copy_logs.sh run_session_hang
exit $res exit $res