Skip to content

Commit

Permalink
Fix tests for changes did in mysql_upgrade calls
Browse files Browse the repository at this point in the history
  • Loading branch information
hhorak committed Feb 4, 2018
1 parent b191e78 commit fb7a543
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions test/run
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ function cleanup() {
ct_cleanup

if [ $TESTSUITE_RESULT -eq 0 ] ; then
echo "Tests succeeded."
echo "Tests for ${IMAGE_NAME} succeeded."
else
echo "Tests failed."
echo "Tests for ${IMAGE_NAME} failed."
fi
}
trap cleanup EXIT SIGINT
Expand Down Expand Up @@ -472,7 +472,13 @@ ssl-cert=\${APP_DATA}/mysql-certs/server-cert-selfsigned.pem

# At least MySQL 5.6 requires ssl-ca option on client side, otherwise the ssl is not used
CONTAINER_EXTRA_ARGS="-v ${test_app_dir}:/opt/app-root/src/:z"
if mysql_cmd "$ip" "ssl_test_user" "ssl_test" --ssl-mode=REQUIRED --ssl-ca=${ca_cert_path} -e 'show status like "Ssl_cipher" \G' | grep 'Value: [A-Z][A-Z0-9-]*' ; then

# MySQL requires --ssl-mode to be set in order to require SSL
case ${VERSION} in
5*) ssl_mode_opt='--ssl-mode=REQUIRED'
esac

if mysql_cmd "$ip" "ssl_test_user" "ssl_test" ${ssl_mode_opt:-} --ssl-ca=${ca_cert_path} -e 'show status like "Ssl_cipher" \G' | grep 'Value: [A-Z][A-Z0-9-]*' ; then
echo " Success!"
rm -rf ${test_app_dir}
else
Expand Down Expand Up @@ -514,7 +520,7 @@ function run_upgrade_test() {
mkdir "${tmpdir}/data" && chmod -R a+rwx "${tmpdir}"

# Create MySQL container with persistent volume and set the version from too old version
local datadir=${tmpdir}
local datadir=${tmpdir}/data
create_container "testupg1" -e MYSQL_USER=user -e MYSQL_PASSWORD=foo \
-e MYSQL_DATABASE=db -v ${datadir}:/var/lib/mysql/data:Z
test_connection testupg1 user foo
Expand All @@ -534,7 +540,7 @@ function run_upgrade_test() {
return 1
fi
# Check whether upgrade did not happen
if docker logs $(ct_get_cid testupg2) 2>&1 | grep -e 'Running mysql_upgrade --socket=/tmp/mysql.sock' &>/dev/null ; then
if docker logs $(ct_get_cid testupg2) 2>&1 | grep -e 'Running mysql_upgrade' &>/dev/null ; then
echo "Upgrade should not be run when information about version is missing"
return 1
fi
Expand All @@ -555,7 +561,7 @@ function run_upgrade_test() {
test_connection testupg3 user foo
docker stop $(ct_get_cid testupg3) >/dev/null
# Check whether some upgrade happened
if ! docker logs $(ct_get_cid testupg3) 2>&1 | grep -e 'Running mysql_upgrade --socket=/tmp/mysql.sock' &>/dev/null ; then
if ! docker logs $(ct_get_cid testupg3) 2>&1 | grep -qe 'Running mysql_upgrade' ; then
echo "Upgrade did not happen but it should when upgrading from previous version"
docker logs $(ct_get_cid testupg3)
return 1
Expand All @@ -570,7 +576,7 @@ function run_upgrade_test() {
test_connection testupg4 user foo
docker stop $(ct_get_cid testupg4) >/dev/null
# Check whether some upgrade happened
if docker logs $(ct_get_cid testupg4) 2>&1 | grep -e 'Running mysql_upgrade --socket=/tmp/mysql.sock' &>/dev/null ; then
if docker logs $(ct_get_cid testupg4) 2>&1 | grep -e 'Running mysql_upgrade' &>/dev/null ; then
echo "Upgrade happened but it should not when upgrading from current version"
return 1
fi
Expand Down Expand Up @@ -612,7 +618,7 @@ function run_upgrade_test() {

function run_all_tests() {
for test_case in $TEST_LIST; do
: "Running test $test_case"
echo "Running test $test_case for ${IMAGE_NAME}"
$test_case
done;
}
Expand Down

0 comments on commit fb7a543

Please sign in to comment.