-
Notifications
You must be signed in to change notification settings - Fork 218
/
Copy pathtest-lib-postgresql.sh
91 lines (84 loc) · 3.38 KB
/
test-lib-postgresql.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
#!/bin/bash
#
# Functions for tests for the PostgreSQL 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
source "${THISDIR}"/test-lib-remote-openshift.sh
function test_postgresql_integration() {
local service_name=postgresql
if [ "${OS}" == "rhel7" ]; then
namespace_image="rhscl/postgresql-${VERSION}-rhel7"
else
namespace_image="${OS}/postgresql-${VERSION}"
# Check if the current version is already GA
# This directory is cloned from TMT plan repo 'sclorg-tmt-plans'
local devel_file="/root/sclorg-tmt-plans/devel_images"
if [ -f "${devel_file}" ]; then
if grep -q "${OS}=postgresql-container=${VERSION}" "$devel_file" ; then
echo "This version is currently developed, so skipping this test."
return
fi
fi
fi
TEMPLATES="postgresql-ephemeral-template.json
postgresql-persistent-template.json"
for template in $TEMPLATES; do
ct_os_test_template_app_func "${IMAGE_NAME}" \
"${THISDIR}/examples/${template}" \
"${service_name}" \
"ct_os_check_cmd_internal 'registry.redhat.io/${namespace_image}' '${service_name}-testing' 'PGPASSWORD=testp pg_isready -t 15 -h <IP> -U testu -d testdb' 'accepting connections' 120" \
"-p POSTGRESQL_VERSION=${VERSION} \
-p DATABASE_SERVICE_NAME="${service_name}-testing" \
-p POSTGRESQL_USER=testu \
-p POSTGRESQL_PASSWORD=testp \
-p POSTGRESQL_DATABASE=testdb"
done
}
# Check the imagestream
function test_postgresql_imagestream() {
local tag="-el7"
if [ "${OS}" == "rhel8" ]; then
tag="-el8"
elif [ "${OS}" == "rhel9" ]; then
tag="-el9"
fi
# Check if the current version is already GA
# This directory is cloned from TMT plan repo 'sclorg-tmt-plans'
local devel_file="/root/sclorg-tmt-plans/devel_images"
if [ -f "${devel_file}" ]; then
if grep -q "${OS}=postgresql-container=${VERSION}" "$devel_file" ; then
echo "This version is currently developed, so skipping this test."
return
fi
fi
TEMPLATES="postgresql-ephemeral-template.json
postgresql-persistent-template.json"
for template in $TEMPLATES; do
ct_os_test_image_stream_template "${THISDIR}/imagestreams/postgresql-${OS%[0-9]*}.json" "${THISDIR}/examples/${template}" postgresql "-p POSTGRESQL_VERSION=${VERSION}${tag}"
done
}
function run_latest_imagestreams_test() {
# Check if the current version is already GA
# This directory is cloned from TMT plan repo 'sclorg-tmt-plans'
local devel_file="/root/sclorg-tmt-plans/devel_images"
if [ -f "${devel_file}" ]; then
if grep -q "${OS}=postgresql-container=${VERSION}" "$devel_file" ; then
echo "This version is currently developed, so skipping this test."
return
fi
fi
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
}
# vim: set tabstop=2:shiftwidth=2:expandtab: