Skip to content

Commit 00623f3

Browse files
committed
Add compatibility test
1 parent f5748c4 commit 00623f3

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

test_versions.sh

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/usr/bin/env bash
2+
3+
# Tests that the employees database can work with all versions of MySQL
4+
#
5+
# Requires dbdeployer to be installed and configured (https://www.dbdeployer.com)
6+
7+
function found_in_path {
8+
name=$1
9+
for dir in $(echo $PATH | tr ':' ' ')
10+
do
11+
if [ -x $dir/$name ]
12+
then
13+
echo $dir/$name
14+
return
15+
fi
16+
done
17+
}
18+
19+
20+
function check_exit_code {
21+
exit_code=$?
22+
if [ "$exit_code" != "0" ]
23+
then
24+
echo "Execution error"
25+
exit $exit_code
26+
fi
27+
}
28+
29+
dbdeployer=$(found_in_path dbdeployer)
30+
31+
if [ -z "$dbdeployer" ]
32+
then
33+
echo "dbdeployer not found in \$PATH"
34+
exit 1
35+
fi
36+
37+
[ -z "$SANDBOX_HOME" ] && SANDBOX_HOME=$HOME/sandboxes
38+
39+
for short_version in 5.0 5.1 5.5 5.6 5.7 8.0
40+
do
41+
version=$($dbdeployer info version $short_version)
42+
if [ -z "$version" ]
43+
then
44+
continue
45+
fi
46+
echo "### -------------------"
47+
echo "### $version"
48+
echo "### -------------------"
49+
ver_name=$(echo $version | tr '.' '_')
50+
51+
$dbdeployer deploy single $version
52+
check_exit_code
53+
54+
msb=$SANDBOX_HOME/msb_$ver_name
55+
56+
if [ ! -d $msb ]
57+
then
58+
echo "'$msb' not found or not a directory - Halting test"
59+
exit 1
60+
fi
61+
62+
$msb/use < employees.sql
63+
check_exit_code
64+
echo "Testing MD5"
65+
$msb/use -t < test_employees_md5.sql > /tmp/test_md5.txt
66+
md5_ok=$(grep -iw ok /tmp/test_md5.txt | wc -l | tr -d ' \t')
67+
68+
if [ "$md5_ok" == "8" ]
69+
then
70+
echo "MD5 OK - $md5_ok"
71+
else
72+
echo "MD5 FAIL - expected 8 - found $md5_ok"
73+
cat /tmp/test_md5.txt
74+
exit 1
75+
fi
76+
77+
echo "Testing SHA"
78+
$msb/use -t < test_employees_sha.sql > /tmp/test_sha.txt
79+
sha_ok=$(grep -iw ok /tmp/test_sha.txt | wc -l | tr -d ' \t')
80+
if [ "$sha_ok" == "8" ]
81+
then
82+
echo "SHA OK - $sha_ok"
83+
else
84+
echo "SHA FAIL - expected 8 - found $sha_ok"
85+
cat /tmp/test_sha.txt
86+
exit 1
87+
fi
88+
89+
$dbdeployer delete msb_$ver_name
90+
check_exit_code
91+
92+
done
93+

0 commit comments

Comments
 (0)