diff --git a/maxscale-system-test/maxtest/src/nodes.cc b/maxscale-system-test/maxtest/src/nodes.cc index 33dead0b8..70511a185 100644 --- a/maxscale-system-test/maxtest/src/nodes.cc +++ b/maxscale-system-test/maxtest/src/nodes.cc @@ -332,7 +332,7 @@ int Nodes::read_basic_env() // reading private IPs sprintf(env_name, "%s_%03d_private_ip", prefix, i); IP_private[i] = strdup(get_nc_item(env_name).c_str()); - if (IP_private[i] == NULL) + if ((IP_private[i] == NULL) || (strlen(IP_private[i]) == 0)) { IP_private[i] = IP[i]; } diff --git a/maxscale-system-test/mdbci/mdbci_wrapper b/maxscale-system-test/mdbci/mdbci_wrapper new file mode 100644 index 000000000..05006df2d --- /dev/null +++ b/maxscale-system-test/mdbci/mdbci_wrapper @@ -0,0 +1,8 @@ +export user=${host_user} 2>&1 >/dev/null +export ip=${host_ip} 2>&1 >/dev/null +export host=$user@$ip 2>&1 >/dev/null +sshopt="-q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ConnectTimeout=120 " + +rsync -avz --progress -e "ssh $sshopt" ${MDBCI_VM_PATH}/ $host:${MDBCI_VM_PATH}/ 2>&1 >/dev/null +ssh $sshopt $host "MDBCI_VM_PATH=$MDBCI_VM_PATH /home/$user/mdbci/mdbci $*" 2>/dev/null +rsync -avz --progress -e "ssh $sshopt" $host:${MDBCI_VM_PATH}/ ${MDBCI_VM_PATH}/ 2>&1 >/dev/null diff --git a/maxscale-system-test/mdbci/run_test.sh b/maxscale-system-test/mdbci/run_test.sh index 15becd0ab..487e4a7d4 100755 --- a/maxscale-system-test/mdbci/run_test.sh +++ b/maxscale-system-test/mdbci/run_test.sh @@ -41,8 +41,6 @@ export vm_memory=${vm_memory:-"2048"} export dir=`pwd` -ulimit -n - # read the name of build scripts directory export script_dir="$(dirname $(readlink -f $0))" diff --git a/maxscale-system-test/mdbci/run_test_vm.sh b/maxscale-system-test/mdbci/run_test_vm.sh new file mode 100755 index 000000000..8a63f73c1 --- /dev/null +++ b/maxscale-system-test/mdbci/run_test_vm.sh @@ -0,0 +1,110 @@ +#!/bin/bash + +# read the name of build scripts directory +export script_dir="$(dirname $(readlink -f $0))" + +rm -rf LOGS + +export curr_date=`date '+%Y-%m-%d_%H-%M'` +export mdbci_config_name=${name:-$box-${curr_date}} +export mdbci_config_name=`echo ${mdbci_config_name} | sed "s/?//g"` +export MDBCI_VM_PATH=$HOME/${mdbci_config_name}_vms +export PATH=$PATH:$HOME/mdbci + +. ${script_dir}/set_run_test_variables.sh + +export name=$mdbci_config_name + +# prepare separate dir for MDBCI vms +rm -rf $HOME/${mdbci_config_name}_vms +mkdir -p $HOME/${mdbci_config_name}_vms + +export provider=`mdbci show provider $box --silent 2> /dev/null` +export backend_box=${backend_box:-"centos_7_"$provider} + +mdbci destroy test_vm + +cp ${script_dir}/test_vm.json $HOME/${mdbci_config_name}_vms/ +test_vm_box="ubuntu_bionic_"$provider +me=`whoami` +sed -i "s/###test_vm_box###/${test_vm_box}/" $HOME/${mdbci_config_name}_vms/test_vm.json +sed -i "s/###test_vm_user###/${me}/" $HOME/${mdbci_config_name}_vms/test_vm.json + +mdbci generate test_vm --template test_vm.json --override +mdbci up test_vm + +ip=`mdbci show network --silent test_vm` +key=`mdbci show keyfile --silent test_vm` +sshopt="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ConnectTimeout=120 " + + +ssh -i $key $sshopt $me@$ip "mkdir -p .ssh; mkdir -p ${MDBCI_VM_PATH}; mkdir -p mdbci; mkdir -p MaxScale" +scp -i $key $sshopt -r ${script_dir}/../../* $me@$ip:~/MaxScale/ + +scp -i $key $sshopt $HOME/.config/mdbci/max-tst.key $me@$ip:~/.ssh/id_rsa +ssh -i $key $sshopt $me@$ip "chmod 400 .ssh/id_rsa" +scp -i $key $sshopt ${script_dir}/mdbci_wrapper $me@$ip:~/mdbci/mdbci +ssh -i $key $sshopt $me@$ip "chmod +x mdbci/mdbci" + +echo export MDBCI_VM_PATH=${MDBCI_VM_PATH} > test_env +echo export PATH=\$PATH:\$HOME/mdbci >> test_env +echo export host_user=$me >> test_env +my_ip=`ip route get $ip | egrep -o '([0-9]{1,3}\.){3}[0-9]{1,3}' | tail -1` +echo export host_ip=${my_ip} >> test_env + +test_env_list=( + "WORKSPACE" + "JOB_NAME" + "BUILD_NUMBER" + "BUILD_TIMESTAMP" + "name" + "target" + "box" + "product" + "version" + "do_not_destroy_vm" + "test_set" + "ci_url" + "smoke" + "big" + "backend_ssl" + "use_snapshots" + "no_vm_revert" + "template" + "config_to_clone" + "test_branch" + "use_valgrind" + "use_callgrind" +) + +for s in ${test_env_list[@]} ; do + eval "v=\$$s" + if [ -n "$v" ] ; then + echo "export $s=\"$v\"" >> test_env + fi +done + +cat test_env + +scp -i $key $sshopt test_env $me@$ip:~/ + +ssh -i $key $sshopt $me@$ip "sudo usermod --shell /bin/bash $me" +ssh -i $key $sshopt $me@$ip "./MaxScale/BUILD/install_test_build_deps.sh" +ssh -i $key $sshopt $me@$ip ". ./test_env; env; ./MaxScale/maxscale-system-test/mdbci/run_test.sh" + + +. ${script_dir}/configure_log_dir.sh +mkdir -p LOGS +mkdir -p ${logs_publish_dir} +scp -i $key $sshopt -r $me@$ip:./MaxScale/build/maxscale-system-test/LOGS/* LOGS/ + + +cp core.* ${logs_publish_dir} +${script_dir}/copy_logs.sh + +if [ "${do_not_destroy_vm}" != "yes" ] ; then + mdbci destroy ${mdbci_config_name} + mdbci destroy test_vm + rm -rf $HOME/${mdbci_config_name}_vms + echo "clean up done!" +fi diff --git a/maxscale-system-test/mdbci/test_vm.json b/maxscale-system-test/mdbci/test_vm.json new file mode 100644 index 000000000..2359f9a00 --- /dev/null +++ b/maxscale-system-test/mdbci/test_vm.json @@ -0,0 +1,10 @@ +{ + "ubuntu_bionic": { + "hostname": "default", + "box" : "###test_vm_box###", + "user" : "###test_vm_user###", + "memory_size": "8192", + "cpu_count": "8" + } +} +