Skip to content
This repository was archived by the owner on May 7, 2025. It is now read-only.

Commit 3de8994

Browse files
committed
Add tests for image streams and refactor tests to work with remote OCP4 cluster
1 parent a0c2b09 commit 3de8994

File tree

4 files changed

+44
-13
lines changed

4 files changed

+44
-13
lines changed

test/run-openshift-local-cluster

+22-7
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ TEMPLATES="$THISDIR/examples/petset"
1212
source "$THISDIR"/test-lib-openshift.sh
1313
source ${THISDIR}/test-lib-mongodb.sh
1414

15-
set -exo nounset
15+
set -eo nounset
1616

17-
test -n "${IMAGE_NAME-}" || false 'make sure $IMAGE_NAME is defined'
18-
test -n "${VERSION-}" || false 'make sure $VERSION is defined'
19-
test -n "${OS-}" || false 'make sure $OS is defined'
17+
trap ct_os_cleanup EXIT SIGINT
18+
19+
ct_os_check_compulsory_vars
2020

2121
ct_os_enable_print_logs
2222

@@ -103,19 +103,34 @@ test_mongodb_pure_image "${IMAGE_NAME}"
103103
test_mongodb_replication "${IMAGE_NAME}"
104104

105105
# test with the just built image and an integrated template
106+
echo "Running test_mongodb_integration with ${IMAGE_NAME}"
106107
test_mongodb_integration "${IMAGE_NAME}" "${VERSION}" mongodb
107108

108109
# test with a released image and an integrated template
110+
# ignore possible failure of this test for centos images
111+
fail_not_released=true
109112
if [ "${OS}" == "rhel7" ] ; then
110-
PUBLIC_IMAGE_NAME=${PUBLIC_IMAGE_NAME:-${REGISTRY:-registry.access.redhat.com/}rhscl/${BASE_IMAGE_NAME}-${VERSION//./}-rhel7}
113+
PUBLIC_IMAGE_NAME=${PUBLIC_IMAGE_NAME:-${REGISTRY:-registry.redhat.io/}rhscl/${BASE_IMAGE_NAME}-${VERSION//./}-rhel7}
111114
else
112115
PUBLIC_IMAGE_NAME=${PUBLIC_IMAGE_NAME:-${REGISTRY:-}centos/${BASE_IMAGE_NAME}-${VERSION//./}-centos7}
116+
fail_not_released=false
113117
fi
114118

115-
export CT_SKIP_UPLOAD_IMAGE=true
116-
test_mongodb_integration mongodb "${VERSION}" "${PUBLIC_IMAGE_NAME}"
119+
# Try pulling the image first to see if it is accessible
120+
if docker pull "${PUBLIC_IMAGE_NAME}"; then
121+
echo "Running test_mongodb_integration with ${PUBLIC_IMAGE_NAME}"
122+
test_mongodb_integration "${PUBLIC_IMAGE_NAME}" "${VERSION}" mongodb
123+
else
124+
echo "Warning: ${PUBLIC_IMAGE_NAME} could not be downloaded via 'docker'"
125+
! $fail_not_released || false "ERROR: Failed to pull image"
126+
fi
127+
128+
# Check the imagestream
129+
test_mongodb_imagestream
117130

118131
OS_TESTSUITE_RESULT=0
119132

120133
ct_os_cluster_down
121134

135+
# vim: set tabstop=2:shiftwidth=2:expandtab:
136+

test/run-openshift-remote-cluster

+7-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ export CT_SKIP_NEW_PROJECT=true
2424
export CT_SKIP_UPLOAD_IMAGE=true
2525
export CT_NAMESPACE=openshift
2626

27-
test_mongodb_integration mongodb ${VERSION} "${IMAGE_NAME}"
27+
# Check the template
28+
test_mongodb_integration "${IMAGE_NAME}" ${VERSION} mongodb
29+
30+
# Check the imagestream
31+
test_mongodb_imagestream
2832

2933
OS_TESTSUITE_RESULT=0
3034

35+
# vim: set tabstop=2:shiftwidth=2:expandtab:
36+

test/test-lib-mongodb.sh

+14-4
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,28 @@ source ${THISDIR}/test-lib-openshift.sh
1414
function test_mongodb_integration() {
1515
local image_name=$1
1616
local VERSION=$2
17-
local import_image=$3
18-
local service_name=${import_image##*/}
17+
local service_name=$3
18+
local image_tagged="${service_name}:${VERSION}"
1919
ct_os_template_exists mongodb-ephemeral && t=mongodb-ephemeral || t=mongodb-persistent
2020
ct_os_test_template_app_func "${image_name}" \
2121
"${t}" \
2222
"${service_name}" \
23-
"ct_os_check_cmd_internal '${import_image}' '${service_name}' \"mongo <IP>/testdb -u testu -ptestp --eval 'quit()'\" '.*' 120" \
23+
"ct_os_check_cmd_internal '<SAME_IMAGE>' '${service_name}-testing' \"mongo <IP>/testdb -u testu -ptestp --eval 'quit()'\" '.*' 120" \
2424
"-p MONGODB_VERSION=${VERSION} \
2525
-p DATABASE_SERVICE_NAME="${service_name}-testing" \
2626
-p MONGODB_USER=testu \
2727
-p MONGODB_PASSWORD=testp \
28-
-p MONGODB_DATABASE=testdb" "" "${import_image}"
28+
-p MONGODB_DATABASE=testdb"
29+
}
30+
31+
# Check the imagestream
32+
function test_mongodb_imagestream() {
33+
case ${OS} in
34+
rhel7|centos7) ;;
35+
*) echo "Imagestream testing not supported for $OS environment." ; return 0 ;;
36+
esac
37+
38+
ct_os_test_image_stream_template "${THISDIR}/../imagestreams/mongodb-${OS}.json" "${THISDIR}/../examples/mongodb-ephemeral-template.json" mongodb "-p MONGODB_VERSION=${VERSION}"
2939
}
3040

3141
# vim: set tabstop=2:shiftwidth=2:expandtab:

0 commit comments

Comments
 (0)