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
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
17 changed files with 88 additions and 74 deletions

View File

@ -8,6 +8,7 @@
rp=`realpath $0`
export src_dir=`dirname $rp`
export test_dir=`pwd`
export test_name=`basename $rp`
@ -17,7 +18,7 @@ if [ $? -ne 0 ] ; then
echo "configuring maxscale failed"
exit 1
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"
#sleep 15
@ -69,5 +70,5 @@ else
echo "Messages are same"
fi
$test_dir/copy_logs.sh bug561
$src_dir/copy_logs.sh bug561
exit $res

View File

@ -6,6 +6,7 @@
## - compare error messages
rp=`realpath $0`
export src_dir=`dirname $rp`
export test_dir=`pwd`
export test_name=`basename $rp`
@ -15,7 +16,7 @@ if [ $? -ne 0 ] ; then
echo "configuring maxscale failed"
exit 1
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`
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
fi
$test_dir/copy_logs.sh bug562
$src_dir/copy_logs.sh bug562
exit $res

View File

@ -6,6 +6,7 @@
## - check output of SHOW VARIABLES LIKE 'char%'
rp=`realpath $0`
export src_dir=`dirname $rp`
export test_dir=`pwd`
export test_name=`basename $rp`
$test_dir/non_native_setup $test_name
@ -14,7 +15,7 @@ if [ $? -ne 0 ] ; then
echo "configuring maxscale failed"
exit 1
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"
do
@ -34,11 +35,9 @@ do
if [[ $res1 != 0 ]] || [[ $res2 != 0 ]] || [[ $res3 != 0 ]] ; then
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%'"
$test_dir/copy_logs.sh bug564
$src_dir/copy_logs.sh bug564
exit 1
fi
done
$test_dir/copy_logs.sh bug564
$src_dir/copy_logs.sh bug564
exit 0

View File

@ -6,6 +6,7 @@
## check if Maxscale is alive
rp=`realpath $0`
export src_dir=`dirname $rp`
export test_dir=`pwd`
export test_name=`basename $rp`
$test_dir/non_native_setup $test_name
@ -14,7 +15,7 @@ if [ $? -ne 0 ] ; then
echo "configuring maxscale failed"
exit 1
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"`
#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
res=$?
$test_dir/copy_logs.sh bug567
$src_dir/copy_logs.sh bug567
exit $res

View File

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

View File

@ -1,4 +1,8 @@
#!/bin/bash
rp=`realpath $0`
export src_dir=`dirname $rp`
./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
rp=`realpath $0`
export src_dir=`dirname $rp`
export test_dir=`pwd`
export test_name=`basename $rp`
$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
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:"
for ((i=0 ; i<1000 ; i++)) ; do
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
echo "ReadConn router (master):"
for ((i=0 ; i<1000 ; i++)) ; do
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
res=$?
$test_dir/copy_logs.sh long_insert
$src_dir/copy_logs.sh long_insert
exit $res

View File

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

View File

@ -4,15 +4,20 @@
#
# 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`
echo "--disable_query_log" > 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
./mysqltest_driver.sh $1 Hartmut_tests/maxscale-mysqltest 4006
$src_dir/mysqltest_driver.sh $1 $PWD/Hartmut_tests/maxscale-mysqltest 4006
ret=$?
./copy_logs.sh $1
$src_dir/copy_logs.sh $1
exit $ret

View File

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

View File

@ -68,8 +68,10 @@ int main(int argc, char* argv[])
TestConnections::skip_maxscale_start(true);
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)
{

View File

@ -1,12 +1,14 @@
#!/bin/bash
rp=`realpath $0`
export src_dir=`dirname $rp`
$PWD/non_native_setup $test_name
if [ $? -ne 0 ] ; then
echo "configuring maxscale failed"
exit 1
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
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],
test->maxscales->user_name,
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);
test->check_maxscale_processes(0, 1);

View File

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

View File

@ -5,6 +5,7 @@
## check that Maxscale is reacting correctly on ctrc+c signal and termination does not take ages
rp=`realpath $0`
export src_dir=`dirname $rp`
export test_dir=`pwd`
export test_name=`basename $rp`
@ -20,12 +21,12 @@ if [ $? -ne 0 ] ; then
exit 1
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"
res=$?
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

View File

@ -5,6 +5,7 @@
## run a set of queries in the loop (see setmix.sql) using Perl client
rp=`realpath $0`
export src_dir=`dirname $rp`
export test_dir=`pwd`
export test_name=`basename $rp`
@ -15,7 +16,7 @@ then
echo "configuring maxscale failed"
exit 1
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
@ -27,8 +28,8 @@ fi
res=0
$test_dir/session_hang/run_setmix.sh &
perl $test_dir/session_hang/simpletest.pl
$src_dir/session_hang/run_setmix.sh &
perl $src_dir/session_hang/simpletest.pl
if [ $? -ne 0 ]
then
res=1
@ -52,6 +53,6 @@ else
echo "Test PASSED"
fi
$test_dir/copy_logs.sh run_session_hang
$src_dir/copy_logs.sh run_session_hang
exit $res