add upgrade test

This commit is contained in:
Timofey Turenko
2017-11-23 11:26:18 +02:00
committed by Markus Mäkelä
parent 0c1b0648b6
commit e1711889b9
8 changed files with 204 additions and 0 deletions

View File

@ -136,3 +136,7 @@ if [ $build_result -ne 0 ] ; then
exit $build_result
fi
if [ ${run_upgrade_test} == "yes" ] ; then
${script_dir}/upgrade_test.sh
fi

View File

@ -0,0 +1,15 @@
[maxscale]
threads=4
log_warning=1
[CLI]
type=service
router=cli
[CLI Listener]
type=listener
service=CLI
protocol=maxscaled
#address=localhost
socket=default

View File

@ -0,0 +1,16 @@
[maxscale]
threads=4
log_warning=1
[CLI]
type=service
router=cli
[CLI Listener]
type=listener
service=CLI
protocol=maxscaled
#address=localhost
port=6603

View File

@ -0,0 +1,15 @@
set -x
LOGS_DIR=${logs_dir:-$HOME/LOGS}
echo $JOB_NAME | grep "/"
if [ $? == 0 ] ; then
export job_name_buildID=`echo $JOB_NAME | sed "s|/|-$BUILD_NUMBER/|"`
export logs_publish_dir="${LOGS_DIR}/${job_name_buildID}/"
else
export logs_publish_dir="${LOGS_DIR}/${JOB_NAME}-${BUILD_NUMBER}"
fi
export job_name_buildID=`echo ${JOB_NAME} | sed "s|/|-${BUILD_NUMBER}/|"`
export logs_publish_dir="${LOGS_DIR}/${job_name_buildID}-${BUILD_NUMBER}"
echo "Logs go to ${logs_publish_dir}"
mkdir -p ${logs_publish_dir}

1
BUILD/mdbci/local_rep.sh Normal file
View File

@ -0,0 +1 @@
export ci_url="http://192.168.122.1/repository"

View File

@ -76,3 +76,7 @@ export ci_url=${ci_url:-"http://max-tst-01.mariadb.com/ci-repository/"}
export deb_repo_key=${deb_repo_key:-"135659e928c12247"}
export rpm_repo_key=${rpm_repo_key:-"$ci_url/MariaDBMaxscale-GPG-KEY.public"}
export run_upgrade_test=${run_upgrade_test:-"no"}
export production_url=${production_url:-"https://downloads.mariadb.com/MaxScale/"}

View File

@ -0,0 +1,11 @@
{
"maxscale" :
{
"hostname" : "maxscale",
"box" : "$box",
"product" : {
"name": "maxscale"
}
}
}

138
BUILD/mdbci/upgrade_test.sh Executable file
View File

@ -0,0 +1,138 @@
#!/bin/bash
set -x
# read the name of build scripts directory
export script_dir="$(dirname $(readlink -f $0))"
# load all needed variables
. ${script_dir}/set_build_variables.sh
export maxadmin_command=${maxadmin_command:-"sudo maxadmin show services"}
export old_target=${old_target:-"2.1.9"}
export old_target=`echo $old_target | sed "s/?//g"`
provider=`${mdbci_dir}/mdbci show provider $box --silent 2> /dev/null`
name=$box-${JOB_NAME}-${BUILD_NUMBER}_upgradetest
name=`echo $name | sed "s|/|-|g"`
cp ${script_dir}/install.json.template ${MDBCI_VM_PATH}/$name.json
eval "cat <<EOF
$(<${script_dir}/templates/install.json.template)
" 2> /dev/null > $MDBCI_VM_PATH/${name}.json
while [ -f ~/vagrant_lock ]
do
sleep 5
done
touch ~/vagrant_lock
echo $JOB_NAME-$BUILD_NUMBER >> ~/vagrant_lock
# destroying existing box
if [ -d "install_$box" ]; then
cd $MDBCI_VM_PATH/$name
vagrant destroy -f
cd $dir
fi
${mdbci_dir}/repository-config/generate_all.sh repo.d
${mdbci_dir}/repository-config/maxscale-release.sh $old_target repo.d
# starting VM for build
${mdbci_dir}/mdbci --override --template $MDBCI_VM_PATH/$name.json --repo-dir $dir/repo.d generate $name
${mdbci_dir}/mdbci up $name --attempts=1
if [ $? != 0 ] ; then
if [ $? != 0 ] ; then
echo "Error starting VM"
cd ${MDBCI_VM_PATH}/$name
if [ "x$do_not_destroy_vm" != "xyes" ] ; then
vagrant destroy -f
fi
cd $dir
rm ~/vagrant_lock
exit 1
fi
fi
rm ~/vagrant_lock
# get VM info
export sshuser=`${mdbci_dir}/mdbci ssh --command 'whoami' --silent $name/maxscale 2> /dev/null | tr -d '\r'`
export IP=`${mdbci_dir}/mdbci show network $name/maxscale --silent 2> /dev/null`
export sshkey=`${mdbci_dir}/mdbci show keyfile $name/maxscale --silent 2> /dev/null | sed 's/"//g'`
export scpopt="-i $sshkey -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ConnectTimeout=120 "
export sshopt="$scpopt $sshuser@$IP"
old_version=`ssh $sshopt "maxscale --version" `
rm -rf repo.d
${mdbci_dir}/repository-config/generate_all.sh repo.d
${mdbci_dir}/repository-config/maxscale-ci.sh $target repo.d
${mdbci_dir}/mdbci setup_repo --product maxscale --repo-dir $dir/repo.d $name/maxscale
${mdbci_dir}/mdbci install_product --product maxscale $name/maxscale
res=$?
new_version=`ssh $sshopt "maxscale --version" `
echo "old version: '${old_version}', new version: '${new_version}'"
if [ "${old_version}" == "${new_version}" ]; then
echo "Upgrde was not done!"
res=1
fi
export cnf_file=${cnf_file:-"maxscale.cnf.minimum"}
scp $scpopt ${script_dir}/cnf/$cnf_file $sshuser@$IP:~/
. ${script_dir}/configure_log_dir.sh
${mdbci_dir}/mdbci ssh --command 'service --help' $name/maxscale
if [ $? == 0 ] ; then
maxscale_start_cmd="sudo service maxscale start"
else
${mdbci_dir}/mdbci ssh --command 'echo \"/usr/bin/maxscale 2> /dev/null &\" > maxscale_start.sh; echo \"disown\" >> maxscale_start.sh; chmod a+x maxscale_start.sh' $name/maxscale --silent
maxscale_start_cmd="sudo ./maxscale_start.sh 2> /dev/null &"
fi
ssh $sshopt "sudo cp $cnf_file /etc/maxscale.cnf"
ssh $sshopt "$maxscale_start_cmd" &
pid_to_kill=$!
sleep 10
ssh $sshopt $maxadmin_command
if [ $? != 0 ] ; then
echo "Maxadmin executing error"
res=1
fi
maxadmin_out=`ssh $sshopt $maxadmin_command`
echo $maxadmin_out | grep "CLI"
if [ $? != 0 ] ; then
echo "CLI service is not found in maxadmin output"
res=1
fi
echo $maxadmin_out | grep "Started"
if [ $? != 0 ] ; then
echo "'Started' is not found in the CLI service description"
res=1
fi
mkdir -p $logs_publish_dir
scp $scpopt $sshuser@$IP:/var/log/maxscale/* $logs_publish_dir
chmod a+r $logs_publish_dir/*
if [ "x$do_not_destroy_vm" != "xyes" ] ; then
cd $MDBCI_VM_PATH/$name
vagrant destroy -f
cd $dir
fi
kill $pid_to_kill
exit $res