From 728fc3b2cfd7b55c62760c55a997231632fa1e73 Mon Sep 17 00:00:00 2001 From: "Petr \"Stone\" Hracek" Date: Wed, 29 Nov 2023 14:04:44 +0100 Subject: [PATCH] Add testing use case for rails-postgresql template Signed-off-by: Petr "Stone" Hracek --- test/run-openshift-remote-cluster | 2 ++ test/test-lib-ruby.sh | 23 +++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/test/run-openshift-remote-cluster b/test/run-openshift-remote-cluster index 6fcf2527..f14f3e1f 100755 --- a/test/run-openshift-remote-cluster +++ b/test/run-openshift-remote-cluster @@ -30,6 +30,8 @@ ct_os_check_login || exit $OC_ERR ct_os_tag_image_for_cvp "ruby" +ct_pull_or_import_postgresql || exit $OC_ERR + set -u # For testing on OpenShift 4 we use internal registry diff --git a/test/test-lib-ruby.sh b/test/test-lib-ruby.sh index 4d01449b..3e8d5b6c 100644 --- a/test/test-lib-ruby.sh +++ b/test/test-lib-ruby.sh @@ -11,6 +11,24 @@ THISDIR=$(dirname ${BASH_SOURCE[0]}) source "${THISDIR}/test-lib.sh" source "${THISDIR}/test-lib-openshift.sh" +function ct_pull_or_import_postgresql() { + postgresql_image="quay.io/sclorg/postgresql-12-c8s" + image_short="postgresql:12" + image_tag="${image_short}" + # Variable CVP is set by CVP pipeline + if [ "${CVP:-0}" -eq "0" ]; then + # In case of container or OpenShift 4 tests + # Pull image before going through tests + # Exit in case of failure, because postgresql container is mandatory + ct_pull_image "${postgresql_image}" "true" + else + # Import postgresql-10-centos7 image before running tests on CVP + oc import-image "${image_short}:latest" --from="${postgresql_image}:latest" --insecure=true --confirm + # Tag postgresql image to "postgresql:10" which is expected by test suite + oc tag "${image_short}:latest" "${image_tag}" + fi +} + function test_ruby_integration() { ct_os_test_s2i_app "${IMAGE_NAME}" \ "https://github.com/sclorg/s2i-ruby-container.git" \ @@ -38,11 +56,12 @@ function test_ruby_imagestream() { function test_ruby_s2i_templates() { # TODO: this was not working because the referenced example dir was added as part of this commit ct_os_test_template_app "${IMAGE_NAME}" \ - "${THISDIR}/rails-postgresql.json" \ + "https://raw.githubusercontent.com/phracek/rails-ex/migrate_deployment/openshift/templates/rails-postgresql.json" \ ruby \ "Everything is OK" \ 8080 http 200 \ - "-p SOURCE_REPOSITORY_REF=master -p VERSION=${VERSION} -p NAME=rails-postgresql-example" + "-p SOURCE_REPOSITORY_REF=master -p RUBY_VERSION=${VERSION} -p NAME=rails-postgresql-example" \ + "quay.io/sclorg/postgresql-12-c8s|postgresql:12-el8" } function test_latest_imagestreams() {