1 Star 0 Fork 0

iothers / test_db

加入 Gitee
与超过 600 万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未指定开源许可证,未经作者的许可,此代码仅用于学习,不能用于其他用途。
克隆/下载
test_versions.sh 1.97 KB
一键复制 编辑 Web IDE 原始数据 按行查看 历史
Giuseppe Maxia 提交于 2020-09-04 14:40 . Add compatibility test
#!/usr/bin/env bash
# Tests that the employees database can work with all versions of MySQL
#
# Requires dbdeployer to be installed and configured (https://www.dbdeployer.com)
function found_in_path {
name=$1
for dir in $(echo $PATH | tr ':' ' ')
do
if [ -x $dir/$name ]
then
echo $dir/$name
return
fi
done
}
function check_exit_code {
exit_code=$?
if [ "$exit_code" != "0" ]
then
echo "Execution error"
exit $exit_code
fi
}
dbdeployer=$(found_in_path dbdeployer)
if [ -z "$dbdeployer" ]
then
echo "dbdeployer not found in \$PATH"
exit 1
fi
[ -z "$SANDBOX_HOME" ] && SANDBOX_HOME=$HOME/sandboxes
for short_version in 5.0 5.1 5.5 5.6 5.7 8.0
do
version=$($dbdeployer info version $short_version)
if [ -z "$version" ]
then
continue
fi
echo "### -------------------"
echo "### $version"
echo "### -------------------"
ver_name=$(echo $version | tr '.' '_')
$dbdeployer deploy single $version
check_exit_code
msb=$SANDBOX_HOME/msb_$ver_name
if [ ! -d $msb ]
then
echo "'$msb' not found or not a directory - Halting test"
exit 1
fi
$msb/use < employees.sql
check_exit_code
echo "Testing MD5"
$msb/use -t < test_employees_md5.sql > /tmp/test_md5.txt
md5_ok=$(grep -iw ok /tmp/test_md5.txt | wc -l | tr -d ' \t')
if [ "$md5_ok" == "8" ]
then
echo "MD5 OK - $md5_ok"
else
echo "MD5 FAIL - expected 8 - found $md5_ok"
cat /tmp/test_md5.txt
exit 1
fi
echo "Testing SHA"
$msb/use -t < test_employees_sha.sql > /tmp/test_sha.txt
sha_ok=$(grep -iw ok /tmp/test_sha.txt | wc -l | tr -d ' \t')
if [ "$sha_ok" == "8" ]
then
echo "SHA OK - $sha_ok"
else
echo "SHA FAIL - expected 8 - found $sha_ok"
cat /tmp/test_sha.txt
exit 1
fi
$dbdeployer delete msb_$ver_name
check_exit_code
done

评论 ( 0 )

你可以在登录后,发表评论

1
https://gitee.com/4ningjian/test_db.git
git@gitee.com:4ningjian/test_db.git
4ningjian
test_db
test_db
master

搜索帮助