Merge pull request #425 from phracek/support_github_matrix
Support GitHub matrix
This commit is contained in:
parent
6a69db45eb
commit
f2fcbea918
11 changed files with 281 additions and 64 deletions
|
|
@ -29,11 +29,11 @@ get_image_id ()
|
|||
image=registry.redhat.io/$ns/postgresql-${version}-rhel7
|
||||
;;
|
||||
centos7)
|
||||
ns=centos
|
||||
ns=centos7
|
||||
if test "$version" -eq 92; then
|
||||
ns=openshift
|
||||
fi
|
||||
local image=docker.io/$ns/postgresql-${1//\./}-centos7
|
||||
local image=quay.io/$ns/postgresql-${1//\./}-centos7
|
||||
;;
|
||||
rhel8)
|
||||
ns=rhel8
|
||||
|
|
|
|||
|
|
@ -118,14 +118,13 @@ function check_postgresql_os_service_connection() {
|
|||
function test_postgresql_pure_image() {
|
||||
local image_name=$1
|
||||
local image_name_no_namespace=${image_name##*/}
|
||||
local service_name=${image_name_no_namespace}
|
||||
local service_name="${image_name_no_namespace%%:*}-testing"
|
||||
|
||||
ct_os_new_project
|
||||
ct_os_upload_image "${image_name}"
|
||||
# Create a specific imagestream tag for the image so that oc cannot use anything else
|
||||
ct_os_upload_image "${image_name}" "$image_name_no_namespace:testing"
|
||||
ct_os_upload_image "${image_name}" "$image_name_no_namespace"
|
||||
|
||||
ct_os_deploy_pure_image "$image_name_no_namespace:testing" \
|
||||
ct_os_deploy_pure_image "$image_name_no_namespace" \
|
||||
--name "${service_name}" \
|
||||
--env POSTGRESQL_ADMIN_PASSWORD=test
|
||||
|
||||
|
|
@ -139,7 +138,7 @@ function test_postgresql_template() {
|
|||
local image_name=$1; shift
|
||||
local template=$1
|
||||
local image_name_no_namespace=${image_name##*/}
|
||||
local service_name=${image_name_no_namespace}
|
||||
local service_name="${image_name_no_namespace%%:*}-testing"
|
||||
|
||||
ct_os_new_project
|
||||
ct_os_upload_image "${image_name}" "postgresql:$VERSION"
|
||||
|
|
@ -161,8 +160,8 @@ function test_postgresql_template() {
|
|||
function test_postgresql_update() {
|
||||
local image_name=$1; shift
|
||||
local template=$1
|
||||
local image_name_no_registry=${image_name#*/}
|
||||
local service_name=${image_name_no_registry#*/}
|
||||
local image_name_no_registry=${image_name##*/}
|
||||
local service_name="${image_name_no_registry%%:*}-testing"
|
||||
local user="testu" pass="testp" db="testdb"
|
||||
local registry="" old_image="" pod_ip=""
|
||||
local version released=:
|
||||
|
|
@ -219,8 +218,8 @@ function test_postgresql_update() {
|
|||
function test_postgresql_replication() {
|
||||
local image_name=$1
|
||||
local image_name_no_namespace=${image_name##*/}
|
||||
local master_service_name=${image_name_no_namespace}-master
|
||||
local slave_service_name=${image_name_no_namespace}-slave
|
||||
local master_service_name="${image_name_no_namespace%%:*}-master"
|
||||
local slave_service_name="${image_name_no_namespace%%:*}-slave"
|
||||
local istag="postgresql:$VERSION"
|
||||
local user="testu" pass="testp" db="testdb"
|
||||
local master_name="" master_ip="" slave_name="" slave_ip=""
|
||||
|
|
@ -289,7 +288,7 @@ function test_postgresql_persistent_redeploy() {
|
|||
local image_name=$1; shift
|
||||
local template=$1
|
||||
local image_name_no_namespace=${image_name##*/}
|
||||
local service_name=$image_name_no_namespace
|
||||
local service_name="${image_name_no_namespace%%:*}-testing"
|
||||
local user="testu" pass="testp" db="testdb"
|
||||
local registry="" old_image="" pod_ip=""
|
||||
|
||||
|
|
@ -327,7 +326,7 @@ function test_postgresql_ephemeral_redeploy() {
|
|||
local image_name=$1; shift
|
||||
local template=$1
|
||||
local image_name_no_namespace=${image_name##*/}
|
||||
local service_name=$image_name_no_namespace
|
||||
local service_name="${image_name_no_namespace%%:*}-testing"
|
||||
local user="testu" pass="testp" db="testdb"
|
||||
local registry="" old_image="" pod_ip=""
|
||||
|
||||
|
|
@ -365,7 +364,7 @@ function test_postgresql_configmap_start() {
|
|||
local image_name=$1; shift
|
||||
local template="$TEMPLATES/postgresql-ephemeral-template.json"
|
||||
local image_name_no_namespace=${image_name##*/}
|
||||
local service_name=$image_name_no_namespace
|
||||
local service_name="${image_name_no_namespace%%:*}-testing"
|
||||
local user="testu" pass="testp" db="testdb"
|
||||
local registry="" old_image="" pod_ip="" tmpdir=""
|
||||
local test_string=""
|
||||
|
|
@ -448,6 +447,19 @@ fi
|
|||
echo "Running test_mariadb_imagestream"
|
||||
test_postgresql_imagestream
|
||||
|
||||
function run_latest_imagestreams_test() {
|
||||
local result=1
|
||||
# Switch to root directory of a container
|
||||
echo "Testing the latest version in imagestreams"
|
||||
pushd "${THISDIR}/.." >/dev/null || return 1
|
||||
ct_check_latest_imagestreams
|
||||
result=$?
|
||||
popd >/dev/null || return 1
|
||||
return $result
|
||||
}
|
||||
|
||||
run_latest_imagestreams_test
|
||||
|
||||
OS_TESTSUITE_RESULT=0
|
||||
|
||||
ct_os_cluster_down
|
||||
|
|
|
|||
|
|
@ -16,13 +16,14 @@ set -eo nounset
|
|||
|
||||
trap ct_os_cleanup EXIT SIGINT
|
||||
|
||||
ct_os_set_ocp4
|
||||
|
||||
ct_os_check_compulsory_vars
|
||||
|
||||
oc status || false "It looks like oc is not properly logged in."
|
||||
|
||||
export CT_SKIP_NEW_PROJECT=true
|
||||
export CT_SKIP_UPLOAD_IMAGE=true
|
||||
export CT_NAMESPACE=openshift
|
||||
# For testing on OpenShift 4 we use external registry
|
||||
export CT_EXTERNAL_REGISTRY=true
|
||||
|
||||
# Check the template
|
||||
test_postgresql_integration "${IMAGE_NAME}"
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ run_s2i_enable_ssl_test
|
|||
run_upgrade_test
|
||||
run_migration_test
|
||||
run_pgaudit_test
|
||||
run_latest_imagestreams_test
|
||||
"
|
||||
|
||||
test $# -eq 1 -a "${1-}" == --list && echo "$TEST_LIST" && exit 0
|
||||
|
|
@ -655,7 +654,7 @@ run_upgrade_test ()
|
|||
# is fixed for non-SCL use cases
|
||||
{ [ "${OS}" == "fedora" ] || [ "${OS}" == "rhel8" ]; } && return 0
|
||||
|
||||
local upgrade_path="none 9.2 9.4 9.5 9.6 10 12 none" prev= act=
|
||||
local upgrade_path="none 9.2 9.4 9.5 9.6 10 12 13 none" prev= act=
|
||||
for act in $upgrade_path; do
|
||||
if test "$act" = $VERSION; then
|
||||
break
|
||||
|
|
@ -677,9 +676,9 @@ run_migration_test ()
|
|||
local from_version
|
||||
# Only test a subset of the migration path on non-intel hosts
|
||||
if [ "$(uname -i)" == "x86_64" ]; then
|
||||
local upgrade_path="9.2 9.4 9.5 9.6 10 12"
|
||||
local upgrade_path="9.2 9.4 9.5 9.6 10 12 13"
|
||||
else
|
||||
local upgrade_path="10 12"
|
||||
local upgrade_path="10 12 13"
|
||||
fi
|
||||
|
||||
for from_version in $upgrade_path; do
|
||||
|
|
@ -700,8 +699,8 @@ run_doc_test() {
|
|||
for f in help.1 ; do
|
||||
docker run --rm ${IMAGE_NAME} /bin/bash -c "cat /${f}" >${tmpdir}/$(basename ${f})
|
||||
# Check whether the files include some important information
|
||||
for term in "POSTGRESQL\_ADMIN\_PASSWORD" volume 5432 ; do
|
||||
if ! cat ${tmpdir}/$(basename ${f}) | grep -F -q -e "${term}" ; then
|
||||
for term in 'POSTGRESQL\\?_ADMIN\\?_PASSWORD' volume 5432 ; do
|
||||
if ! cat ${tmpdir}/$(basename ${f}) | grep -E -q -e "${term}" ; then
|
||||
echo "ERROR: File /${f} does not include '${term}'."
|
||||
return 1
|
||||
fi
|
||||
|
|
@ -899,17 +898,6 @@ EOSQL"
|
|||
grep -E 'AUDIT: SESSION,.*,.*,READ,SELECT,,,SELECT' "${data_dir}"/userdata/log/postgresql-*.log
|
||||
}
|
||||
|
||||
function run_latest_imagestreams_test() {
|
||||
local result=1
|
||||
# Switch to root directory of a container
|
||||
echo "Testing the latest version in imagestreams"
|
||||
pushd "${test_dir}/.." >/dev/null || return 1
|
||||
ct_check_latest_imagestreams
|
||||
result=$?
|
||||
popd >/dev/null || return 1
|
||||
return $result
|
||||
}
|
||||
|
||||
function run_all_tests() {
|
||||
for test_case in $TEST_LIST; do
|
||||
: "Running test $test_case"
|
||||
|
|
|
|||
|
|
@ -8,8 +8,9 @@
|
|||
|
||||
THISDIR=$(dirname ${BASH_SOURCE[0]})
|
||||
|
||||
source ${THISDIR}/test-lib.sh
|
||||
source ${THISDIR}/test-lib-openshift.sh
|
||||
source "${THISDIR}"/test-lib.sh
|
||||
source "${THISDIR}"/test-lib-openshift.sh
|
||||
source "${THISDIR}"/test-lib-remote-openshift.sh
|
||||
|
||||
function test_postgresql_integration() {
|
||||
local image_name=$1
|
||||
|
|
@ -32,8 +33,11 @@ function test_postgresql_imagestream() {
|
|||
rhel7|centos7) ;;
|
||||
*) echo "Imagestream testing not supported for $OS environment." ; return 0 ;;
|
||||
esac
|
||||
|
||||
ct_os_test_image_stream_template "${THISDIR}/../imagestreams/postgresql-${OS%[0-9]*}.json" "${THISDIR}/../examples/postgresql-ephemeral-template.json" postgresql "-p POSTGRESQL_VERSION=${VERSION}"
|
||||
local tag="-el7"
|
||||
if [ "${OS}" == "rhel8" ]; then
|
||||
tag="-el8"
|
||||
fi
|
||||
ct_os_test_image_stream_template "${THISDIR}/../imagestreams/postgresql-${OS%[0-9]*}.json" "${THISDIR}/../examples/postgresql-ephemeral-template.json" postgresql "-p POSTGRESQL_VERSION=${VERSION}${tag}"
|
||||
}
|
||||
|
||||
# vim: set tabstop=2:shiftwidth=2:expandtab:
|
||||
|
|
|
|||
112
test/test-lib-remote-openshift.sh
Normal file
112
test/test-lib-remote-openshift.sh
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
# shellcheck shell=bash
|
||||
# some functions are used from test-lib.sh, that is usually in the same dir
|
||||
# shellcheck source=/dev/null
|
||||
source "$(dirname "${BASH_SOURCE[0]}")"/test-lib.sh
|
||||
|
||||
# Set of functions for testing docker images in OpenShift using 'oc' command
|
||||
|
||||
# A variable containing the overall test result; must be changed to 0 in the end
|
||||
# of the testing script:
|
||||
# OS_TESTSUITE_RESULT=0
|
||||
# And the following trap must be set, in the beginning of the test script:
|
||||
# trap ct_os_cleanup EXIT SIGINT
|
||||
|
||||
# ct_os_set_path_oc_4 OC_VERSION
|
||||
# --------------------
|
||||
# This is a trick that helps using correct version 4 of the `oc`:
|
||||
# The input is version of the openshift in format 4.4 etc.
|
||||
# If the currently available version of oc is not of this version,
|
||||
# it first takes a look into /usr/local/oc-<ver>/bin directory,
|
||||
|
||||
# Arguments: oc_version - X.Y part of the version of OSE (e.g. 3.9)
|
||||
function ct_os_set_path_oc_4() {
|
||||
echo "Setting OCP4 client"
|
||||
local oc_version=$1
|
||||
local installed_oc_path="/usr/local/oc-v${oc_version}/bin"
|
||||
echo "PATH ${installed_oc_path}"
|
||||
if [ -x "${installed_oc_path}/oc" ] ; then
|
||||
oc_path="${installed_oc_path}"
|
||||
echo "Binary oc found in ${installed_oc_path}" >&2
|
||||
else
|
||||
echo "OCP4 not found"
|
||||
return 1
|
||||
fi
|
||||
export PATH="${oc_path}:${PATH}"
|
||||
oc version
|
||||
if ! oc version | grep -q "Client Version: ${oc_version}." ; then
|
||||
echo "ERROR: something went wrong, oc located at ${oc_path}, but oc of version ${oc_version} not found in PATH ($PATH)" >&1
|
||||
return 1
|
||||
else
|
||||
echo "PATH set correctly, binary oc found in version ${oc_version}: $(command -v oc)"
|
||||
fi
|
||||
}
|
||||
|
||||
# ct_os_prepare_ocp4
|
||||
# ------------------
|
||||
# Prepares environment for testing images in OpenShift 4 environment
|
||||
#
|
||||
#
|
||||
function ct_os_set_ocp4() {
|
||||
local login
|
||||
OS_OC_CLIENT_VERSION=${OS_OC_CLIENT_VERSION:-4.4}
|
||||
ct_os_set_path_oc_4 "${OS_OC_CLIENT_VERSION}"
|
||||
|
||||
oc version
|
||||
|
||||
login=$(cat "$KUBEPASSWORD")
|
||||
oc login -u kubeadmin -p "$login"
|
||||
echo "Login to OpenShift ${OS_OC_CLIENT_VERSION} is DONE"
|
||||
# let openshift cluster to sync to avoid some race condition errors
|
||||
sleep 3
|
||||
}
|
||||
|
||||
function ct_os_upload_image_external_registry() {
|
||||
local input_name="${1}" ; shift
|
||||
local image_name=${input_name##*/}
|
||||
local imagestream=${1:-$image_name:latest}
|
||||
local output_name
|
||||
|
||||
ct_os_login_external_registry
|
||||
|
||||
output_name="${INTERNAL_DOCKER_REGISTRY}/rhscl-ci-testing/$imagestream"
|
||||
|
||||
docker images
|
||||
docker tag "${input_name}" "${output_name}"
|
||||
docker push "${output_name}"
|
||||
}
|
||||
|
||||
|
||||
function ct_os_login_external_registry() {
|
||||
local docker_token
|
||||
# docker login fails with "404 page not found" error sometimes, just try it more times
|
||||
# shellcheck disable=SC2034
|
||||
echo "loging"
|
||||
[ -z "${INTERNAL_DOCKER_REGISTRY:-}" ] && "INTERNAL_DOCKER_REGISTRY has to be set for working with Internal registry" && return 1
|
||||
# shellcheck disable=SC2034
|
||||
for i in $(seq 12) ; do
|
||||
# shellcheck disable=SC2015
|
||||
docker_token=$(cat "$DOCKER_UPSHIFT_TOKEN")
|
||||
# shellcheck disable=SC2015
|
||||
docker login -u rhscl-ci-testing -p "$docker_token" "${INTERNAL_DOCKER_REGISTRY}" && return 0 || :
|
||||
sleep 5
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
function ct_os_import_image_ocp4() {
|
||||
local image_name="${1}"; shift
|
||||
local imagestream=${1:-$image_name:latest}
|
||||
local namespace
|
||||
|
||||
namespace=${CT_NAMESPACE:-"$(oc project -q)"}
|
||||
deploy_image_name="${INTERNAL_DOCKER_REGISTRY}/rhscl-ci-testing/${imagestream}"
|
||||
echo "Uploading image ${image_name} as ${deploy_image_name} , ${imagestream} into external registry."
|
||||
ct_os_upload_image_external_registry "${image_name}" "${imagestream}"
|
||||
if [ "${CT_TAG_IMAGE:-false}" == 'true' ]; then
|
||||
echo "Tag ${deploy_image_name} to ${namespace}/${imagestream}"
|
||||
oc tag --source=docker "${deploy_image_name}" "${namespace}/${imagestream}" --insecure=true --reference-policy=local
|
||||
else
|
||||
echo "Import image into OpenShift 4 environment ${namespace}/${imagestream} from ${deploy_image_name}"
|
||||
oc import-image "${namespace}/${imagestream}" --from="${deploy_image_name}" --confirm --reference-policy=local
|
||||
fi
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue