Skip to content

Commit c104720

Browse files
Script to do the set up and run integration tests from Jenkins (#2373)
* Script to do the set up and run integration tests from Jenkins
1 parent b7cc361 commit c104720

File tree

1 file changed

+126
-0
lines changed

1 file changed

+126
-0
lines changed

jenkinsScript.sh

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
#!/bin/bash
2+
# Copyright (c) 2021, Oracle and/or its affiliates.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
#
5+
# This script checks for the below required environment variables on Jenkins and runs the integration tests
6+
# APACHE_MAVEN_HOME
7+
# HELM_VERSION
8+
# KUBECTL_VERSION
9+
# KIND_VERSION
10+
# IT_TEST
11+
# WDT_DOWNLOAD_URL
12+
# WIT_DOWNLOAD_URL
13+
# NUMBER_OF_THREADS
14+
# JAVA_HOME
15+
# OCR_PASSWORD
16+
# OCR_USERNAME
17+
# OCIR_USERNAME
18+
# OCIR_PASSWORD
19+
# OCIR_EMAIL
20+
21+
set -o errexit
22+
set -o pipefail
23+
24+
function checkEnvVars {
25+
local has_errors=false
26+
while [ ! -z "${1}" ]; do
27+
if [ -z "${!1}" ]; then
28+
echo "Error: '${1}' env variable is not set"
29+
has_errors=true
30+
else
31+
if [ "${1/PASSWORD//}" = "${1}" ]; then
32+
echo "Info: env var ${1}='${!1}'"
33+
else
34+
echo "Info: env var ${1}='***'"
35+
fi
36+
fi
37+
shift
38+
done
39+
if [ ! "$has_errors" = "false" ]; then
40+
echo "Error: Missing env vars, exiting."
41+
exit 1
42+
fi
43+
}
44+
function ver { printf %02d%02d%02d%02d%02d $(echo "$1" | tr '.' ' '); }
45+
function checkJavaVersion {
46+
java_version=`java -version 2>&1 >/dev/null | grep 'java version' | awk '{print $3}'`
47+
echo "Info: java version ${java_version}"
48+
if [ $(ver $java_version) -lt $(ver "11.0.10") ]; then
49+
echo "Error: Java version should be 11.0.10 or higher"
50+
exit 1
51+
fi
52+
}
53+
54+
echo "WORKSPACE ${WORKSPACE}"
55+
56+
checkEnvVars \
57+
APACHE_MAVEN_HOME \
58+
HELM_VERSION \
59+
KUBECTL_VERSION \
60+
KIND_VERSION \
61+
IT_TEST \
62+
WDT_DOWNLOAD_URL \
63+
WIT_DOWNLOAD_URL \
64+
NUMBER_OF_THREADS \
65+
JAVA_HOME \
66+
OCR_PASSWORD \
67+
OCR_USERNAME \
68+
OCIR_USERNAME \
69+
OCIR_PASSWORD \
70+
OCIR_EMAIL
71+
72+
73+
mkdir -p ${WORKSPACE}/bin
74+
75+
export PATH=${JAVA_HOME}/bin:${APACHE_MAVEN_HOME}/bin:${WORKSPACE}/bin:$PATH
76+
77+
which java
78+
java -version
79+
checkJavaVersion
80+
81+
which mvn
82+
mvn --version
83+
84+
echo 'Info: Set up helm...'
85+
curl -LO --retry 3 https://get.helm.sh/helm-v${HELM_VERSION}-linux-amd64.tar.gz
86+
tar -xf helm-v${HELM_VERSION}-linux-amd64.tar.gz
87+
cp linux-amd64/helm ${WORKSPACE}/bin/helm
88+
helm version
89+
90+
echo 'Info: Set up kubectl...'
91+
curl -LO --retry 3 https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl
92+
mv kubectl bin/kubectl
93+
chmod +x bin/kubectl
94+
kubectl version --client=true
95+
96+
echo 'Info: Set up kind...'
97+
curl -Lo ./kind --retry 3 https://kind.sigs.k8s.io/dl/v${KIND_VERSION}/kind-$(uname)-amd64
98+
chmod +x ./kind
99+
mv ./kind bin/kind
100+
kind version
101+
102+
export TWO_CLUSTERS=false
103+
export RESULT_ROOT=${WORKSPACE}/RESULT_ROOT
104+
export BRANCH_NAME=${BRANCH}
105+
106+
cd $WORKSPACE
107+
[ -d ${WORKSPACE}/logdir ] && rm -rf ${WORKSPACE}/logdir && mkdir -p ${WORKSPACE}/logdir
108+
pwd
109+
ls
110+
111+
echo "Info: soft limits"
112+
ulimit -a
113+
echo "Info: hard limits"
114+
ulimit -aH
115+
116+
echo 'Info: Run build...'
117+
mvn clean install
118+
119+
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
120+
helm repo add stable https://charts.helm.sh/stable --force-update
121+
helm repo update
122+
123+
echo "Info: Run tests.."
124+
sh -x ./kindtest.sh -t "${IT_TEST}" -v ${KUBE_VERSION} -p ${PARALLEL_RUN} -d ${WDT_DOWNLOAD_URL} -i ${WIT_DOWNLOAD_URL} -x ${NUMBER_OF_THREADS}
125+
126+

0 commit comments

Comments
 (0)