Use VM to run tests

In order to avoid host overloading, execution of tests moved also to VM.
VM uses MDBCI wrapper which sends all commands to the host
This commit is contained in:
Timofey Turenko 2020-07-24 14:39:35 +03:00
parent 39aa129fc5
commit fa40845e0c
5 changed files with 129 additions and 3 deletions

View File

@ -327,7 +327,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];
}

View File

@ -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

View File

@ -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))"

View File

@ -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

View File

@ -0,0 +1,10 @@
{
"ubuntu_bionic": {
"hostname": "default",
"box" : "###test_vm_box###",
"user" : "###test_vm_user###",
"memory_size": "8192",
"cpu_count": "8"
}
}