-
Notifications
You must be signed in to change notification settings - Fork 324
/
Copy pathtest-lib-python.sh
137 lines (124 loc) · 4.88 KB
/
test-lib-python.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
#
# Functions for tests for the Python image in OpenShift.
#
# IMAGE_NAME specifies a name of the candidate image used for testing.
# The image has to be available before this script is executed.
#
THISDIR=$(dirname ${BASH_SOURCE[0]})
source "${THISDIR}/test-lib.sh"
source "${THISDIR}/test-lib-openshift.sh"
function ct_pull_or_import_postgresql() {
if [[ "${VERSION}" == *"minimal"* ]]; then
VERSION=$(echo "${VERSION}" | cut -d "-" -f 1)
fi
if [[ "${VERSION}" == "3.11" ]] || [[ "${VERSION}" == "3.12" ]]; then
postgresql_image="quay.io/sclorg/postgresql-12-c8s"
image_short="postgresql:12"
image_tag="${image_short}"
else
postgresql_image="quay.io/centos7/postgresql-10-centos7:centos7"
image_short="postgresql:10-centos7"
image_tag="postgresql:10"
fi
# 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
}
# Check the imagestream
function test_python_imagestream() {
local tag="-ubi7"
if [ "${OS}" == "rhel8" ]; then
tag="-ubi8"
elif [ "${OS}" == "rhel9" ]; then
tag="-ubi9"
fi
if [[ "${VERSION}" == *"minimal"* ]]; then
VERSION=$(echo "${VERSION}" | cut -d "-" -f 1)
fi
if [[ "${VERSION}" == "3.11" ]] || [[ "${VERSION}" == "3.12" ]]; then
branch="4.2.x"
postgresql_image="quay.io/sclorg/postgresql-12-c8s|postgresql:12"
postgresql_version="12"
else
branch="master"
postgresql_image="quay.io/centos7/postgresql-10-centos7:centos7|postgresql:10"
postgresql_version="10"
fi
TEMPLATES="
django-postgresql.json \
django-postgresql-persistent.json"
for template in $TEMPLATES; do
ct_os_test_image_stream_quickstart "${THISDIR}/imagestreams/python-${OS%[0-9]*}.json" \
"https://raw.githubusercontent.com/sclorg/django-ex/${branch}/openshift/templates/${template}" \
"${IMAGE_NAME}" \
'python' \
'Welcome to your Django application on OpenShift' \
8080 http 200 "-p SOURCE_REPOSITORY_REF=$branch -p PYTHON_VERSION=${VERSION}${tag} -p POSTGRESQL_VERSION=${postgresql_version} -p NAME=python-testing" \
"$postgresql_image"
done
}
function test_python_s2i_app_ex_standalone() {
ct_os_test_s2i_app "${IMAGE_NAME}" \
"https://github.com/sclorg/s2i-python-container.git" \
"examples/standalone-test-app" \
"Hello World from standalone WSGI application!"
}
function test_python_s2i_app_ex() {
if [[ "${VERSION}" == *"minimal"* ]]; then
VERSION=$(echo "${VERSION}" | cut -d "-" -f 1)
fi
if [[ "${VERSION}" == "3.11" ]] || [[ "${VERSION}" == "3.12" ]]; then
branch="4.2.x"
else
branch="2.2.x"
fi
django_example_repo_url="https://github.com/sclorg/django-ex.git#${branch}"
ct_os_test_s2i_app "${IMAGE_NAME}" \
"${django_example_repo_url}" \
. \
'Welcome to your Django application on OpenShift'
}
function test_python_s2i_templates() {
if [ -z "${EPHEMERAL_TEMPLATES:-}" ]; then
EPHEMERAL_TEMPLATES="
django-postgresql.json \
django-postgresql-persistent.json"
fi
if [[ "${VERSION}" == *"minimal"* ]]; then
VERSION=$(echo "${VERSION}" | cut -d "-" -f 1)
fi
if [[ "${VERSION}" == "3.11" ]] || [[ "${VERSION}" == "3.12" ]]; then
postgresql_image="quay.io/sclorg/postgresql-12-c8s|postgresql:12"
postgresql_version="12"
else
postgresql_image="quay.io/centos7/postgresql-10-centos7:centos7|postgresql:10"
postgresql_version="10"
fi
for template in $EPHEMERAL_TEMPLATES; do
branch="2.2.x"
ct_os_test_template_app "$IMAGE_NAME" \
"https://raw.githubusercontent.com/sclorg/django-ex/${branch}/openshift/templates/${template}" \
python \
'Welcome to your Django application on OpenShift' \
8080 http 200 "-p SOURCE_REPOSITORY_REF=$branch -p PYTHON_VERSION=${VERSION} -p POSTGRESQL_VERSION=${postgresql_version} -p NAME=python-testing" \
"${postgresql_image}"
done
}
function test_latest_imagestreams() {
info "Testing the latest version in imagestreams"
# Switch to root directory of a container
pushd "${THISDIR}/../.." >/dev/null
ct_check_latest_imagestreams
popd >/dev/null
}
# vim: set tabstop=2:shiftwidth=2:expandtab: