-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathdaily_scl_tests.sh
executable file
·120 lines (103 loc) · 3.8 KB
/
daily_scl_tests.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
#!/bin/bash
set -x
SCL_CONTAINERS_UPSTREAM="\
s2i-nodejs-container
"
SCL_S2I_CONTAINERS="\
s2i-base-container
s2i-nodejs-container
s2i-php-container
s2i-perl-container
s2i-ruby-container
s2i-python-container
"
SCL_NOS2I_CONTAINTERS="\
varnish-container
nginx-container
httpd-container
redis-container
mariadb-container
postgresql-container
valkey-container
"
[[ -z "$1" ]] && { echo "You have to specify target to build SCL images. rhel9, rhel8, or fedora" && exit 1 ; }
TARGET="$1"
shift
[[ -z "$1" ]] && { echo "You have to specify type of the test to run. test, test-openshift, test-openshift-pytest, test-openshift-4" && exit 1 ; }
TESTS="$1"
shift
if [[ -z "$SET_TEST" ]]; then
SET_TEST="S2I"
fi
CUR_WD=$(pwd)
echo "Current working directory is: ${CUR_WD}"
TMP_DIR="${TMT_PLAN_DATA}"
RESULT_DIR="${TMP_DIR}/results/"
KUBECONFIG=/root/.kube/config
KUBEPASSWD=/root/.kube/ocp-kube
PBINCLI=/usr/local/bin/pbincli
PBINCLI_OPTS="--server https://privatebin.corp.redhat.com --expire 1week --no-insecure-warning --no-check-certificate --format plaintext"
mkdir -p "${RESULT_DIR}"
function clone_repo() {
local repo_name=$1; shift
# Sometimes cloning failed with an error
# The requested URL returned error: 500. Save it into log for info
git clone "https://github.com/sclorg/${repo_name}.git" || \
{ echo "Repository ${repo_name} was not cloned." > ${RESULT_DIR}/${repo_name}.log; return 1 ; }
cd "${repo_name}" || { echo "Repository ${repo_name} does not exist. Skipping." && return 1 ; }
git submodule update --init
git submodule update --remote
}
function clean_ocp4() {
if [[ "${TESTS}" == "test-openshift-4" ]] || [[ "${TESTS}" == "test-openshift-pytest" ]]; then
echo "Cleaning OpenShift 4 environment"
oc project default
PASS=$(cat "${KUBEPASSWD}")
oc login --username=kubeadmin --insecure-skip-tls-verify=true --password="${PASS}" --server=https://api.core-serv-ocp.hosted.psi.rdu2.redhat.com:6443
export PATH="/usr/local/oc-v4/bin:$PATH"
oc project default
oc projects | grep sclorg
# oc projects | grep sclorg | xargs oc delete project
# oc delete all --all
# Sleep couple seconds till OpenShift is not back again.
sleep 10
fi
}
function iterate_over_all_containers() {
CONTAINTERS_TO_TEST=$SCL_S2I_CONTAINERS
if [[ "${TESTS}" == "test-upstream" ]]; then
CONTAINTERS_TO_TEST=$SCL_CONTAINERS_UPSTREAM
elif [[ "${SET_TEST}" == "NOS2I" ]]; then
CONTAINTERS_TO_TEST=$SCL_NOS2I_CONTAINTERS
fi
for repo in ${CONTAINTERS_TO_TEST}; do
# Do not shutting down OpenShift 3 cluster
export OS_CLUSTER_STARTED_BY_TEST=0
cd ${TMP_DIR} || exit
local log_name="${TMP_DIR}/${repo}.log"
clone_repo "${repo}"
if [[ -d "/root/sclorg-tmt-plans" ]]; then
pushd /root/sclorg-tmt-plans && ./set_devel_repo.sh "sclorg/${repo}" "$TARGET" "${TMP_DIR}/${repo}"
# Switch back to tmp container-repo name
popd
fi
make "${TESTS}" TARGET="${TARGET}" > "${log_name}" 2>&1
if [[ $? -ne 0 ]]; then
echo "Tests for container $repo has failed."
cp "${log_name}" "${RESULT_DIR}/"
echo "Show the last 100 lines from file: ${RESULT_DIR}/${repo}.log"
tail -100 "${RESULT_DIR}/${repo}.log"
fi
clean_ocp4
done
}
git clone https://gitlab.cee.redhat.com/platform-eng-core-services/sclorg-tmt-plans /root/sclorg-tmt-plans
git clone https://github.com/sclorg/container-common-scripts.git /root/container-common-scripts
if [[ "${TESTS}" == "test-openshift-4" ]] || [[ "${TESTS}" == "test-openshift-pytest" ]]; then
echo "Testing OpenShift 4 is enabled"
curl -L --insecure https://url.corp.redhat.com/sclorg-data-kubeconfig >$KUBECONFIG
# Download kubepasswd
curl -L --insecure https://url.corp.redhat.com/sclorg-data-kubepasswd >$KUBEPASSWD
fi
iterate_over_all_containers
cd "${CUR_WD}"