#!/bin/bash
#
# Test the MySQL image in OpenShift (local cluster)
#
# IMAGE_NAME specifies a name of the candidate image used for testing.
# The image has to be available before this script is executed.
# VERSION specifies the major version of the MySQL in format of X.Y
# OS specifies RHEL version (e.g. OS=rhel7)
#
THISDIR=$(dirname ${BASH_SOURCE[0]})
source ${THISDIR}/test-lib-mysql.sh
set -eo nounset
trap ct_os_cleanup EXIT SIGINT
ct_os_check_compulsory_vars
ct_os_cluster_up
test_mysql_pure_image "${IMAGE_NAME}"
test_mysql_template "${IMAGE_NAME}"
# TODO: Can we make the build against examples inside the same PR?
test_mysql_s2i "${IMAGE_NAME}" "https://github.com/sclorg/mysql-container.git" test/test-app
# test with the just built image and an integrated template
test_mysql_integration "${IMAGE_NAME}" "${VERSION}" mysql
# test with a released image and an integrated template
if [ "${OS}" == "rhel7" ] ; then
PUBLIC_IMAGE_NAME=${PUBLIC_IMAGE_NAME:-${REGISTRY:-registry.access.redhat.com/}rhscl/${BASE_IMAGE_NAME}-${VERSION//./}-rhel7}
else
PUBLIC_IMAGE_NAME=${PUBLIC_IMAGE_NAME:-${REGISTRY:-}centos/${BASE_IMAGE_NAME}-${VERSION//./}-centos7}
fi
export CT_SKIP_UPLOAD_IMAGE=true
test_mysql_integration mysql "${VERSION}" "${PUBLIC_IMAGE_NAME}"
OS_TESTSUITE_RESULT=0
ct_os_cluster_down