forked from sclorg/container-common-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·68 lines (59 loc) · 2.38 KB
/
test.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
#!/bin/bash
# This script is used to test the OpenShift Docker images.
#
# TEST_MODE - If set, run regular test suite
# TEST_OPENSHIFT_MODE - If set, run OpenShift tests (if present)
# VERSIONS - Must be set to a list with possible versions (subdirectories)
set -e
[ -n "${DEBUG:-}" ] && set -x
# This adds backwards compatibility if only single version needs to be testing
# In CI we would like to test single version but VERSIONS= means, that nothing is tested
# make test TARGET=<OS> VERSIONS=<something> ... checks single version for CLI
# make test TARGET=<OS> SINGLE_VERSION=<something> ... checks single version from Testing Farm
VERSIONS=${SINGLE_VERSION:-$VERSIONS}
echo "Tested versions are: $VERSIONS"
for dir in ${VERSIONS}; do
[ ! -e "${dir}/.image-id" ] && echo "-> Image for version $dir not built, skipping tests." && continue
pushd "${dir}" > /dev/null
IMAGE_ID=$(cat .image-id)
export IMAGE_ID
IMAGE_VERSION=$(docker inspect -f "{{.Config.Labels.version}}" "$IMAGE_ID")
# Kept also IMAGE_NAME as some tests might still use that.
IMAGE_NAME="$(docker inspect -f "{{.Config.Labels.name}}" "$IMAGE_ID"):$IMAGE_VERSION"
# shellcheck disable=SC2268
if [ "${OS}" == "centos7" ] || [ "${OS}" == "c9s" ] || [ "${OS}" == "fedora" ] || [ "${OS}" == "c8s" ]; then
export IMAGE_NAME="$REGISTRY$IMAGE_NAME"
else
export IMAGE_NAME
fi
if [ -n "${TEST_MODE}" ]; then
VERSION=$dir test/run
fi
if [ -n "${TEST_OPENSHIFT_4}" ]; then
# In case only imagestream is deprecated
# and the other tests should be working
if [ -e ".exclude-openshift" ]; then
echo "-> .exclude-openshift file exists for version $dir, skipping OpenShift-4 tests."
else
if [[ -x test/run-openshift-remote-cluster ]]; then
VERSION=$dir test/run-openshift-remote-cluster
else
echo "-> Tests for OpenShift 4 are not present. Add run-openshift-remote-cluster script, skipping"
fi
fi
fi
if [ -n "${TEST_OPENSHIFT_MODE}" ]; then
# In case only imagestream is deprecated
# and the other tests should be working
if [ -e ".exclude-openshift" ]; then
echo "-> .exclude-openshift file exists for version $dir, skipping OpenShift tests."
else
if [[ -x test/run-openshift ]]; then
VERSION=$dir test/run-openshift
else
echo "-> OpenShift 3 tests are not present, skipping"
fi
fi
fi
popd > /dev/null
done