-
Notifications
You must be signed in to change notification settings - Fork 35
/
quickstarter-test.sh
executable file
·64 lines (54 loc) · 2.21 KB
/
quickstarter-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
#!/usr/bin/env bash
set -eu
set -o pipefail
export CGO_ENABLED=0
THIS_SCRIPT="$(basename $0)"
# By default we run all quickstarter tests, otherwise just the quickstarter
# passed as the first argument to this script.
QUICKSTARTER=${1-"ods-quickstarters/..."}
PARALLEL=${2-"1"}
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ODS_CORE_DIR=${SCRIPT_DIR%/*}
if ! oc whoami &> /dev/null; then
echo "${THIS_SCRIPT}: You need to login to OpenShift to run the tests"
echo "${THIS_SCRIPT}: Returning with exit code 1"
exit 1
fi
if [ -f test-quickstarter-results.txt ]; then
rm test-quickstarter-results.txt
fi
BITBUCKET_TEST_PROJECT="unitt"
echo "Setup Bitbucket test project ${BITBUCKET_TEST_PROJECT} ..."
BITBUCKET_URL=$(${ODS_CORE_DIR}/scripts/get-config-param.sh BITBUCKET_URL)
CD_USER_ID=$(${ODS_CORE_DIR}/scripts/get-config-param.sh CD_USER_ID)
CD_USER_PWD_B64=$(${ODS_CORE_DIR}/scripts/get-config-param.sh CD_USER_PWD_B64)
./scripts/setup-bitbucket-test-project.sh \
--bitbucket=${BITBUCKET_URL} \
--user=${CD_USER_ID} \
--password=$(base64 -d - <<< ${CD_USER_PWD_B64}) \
--project=${BITBUCKET_TEST_PROJECT}
echo " "
echo "${THIS_SCRIPT}: Cleaning a little bit the host machine to not suffer from limitated resources... "
echo " "
if [ -f ./scripts/free-unused-resources.sh ]; then
chmod +x ./scripts/free-unused-resources.sh
./scripts/free-unused-resources.sh || true
else
echo "Not found script ./scripts/free-unused-resources.sh "
fi
echo " "
echo "${THIS_SCRIPT}: Running tests (${QUICKSTARTER}). Output will take a while to arrive ..."
echo " "
# Should fix error " panic: test timed out after "
echo "${THIS_SCRIPT}: go test -v -count=1 -timeout 30h -parallel ${PARALLEL} github.com/opendevstack/ods-core/tests/quickstarter -args ${QUICKSTARTER}"
go test -v -count=1 -timeout 30h -parallel ${PARALLEL} github.com/opendevstack/ods-core/tests/quickstarter -args ${QUICKSTARTER} | tee test-quickstarter-results.txt 2>&1
exitcode="${PIPESTATUS[0]}"
if [ -f test-quickstarter-results.txt ]; then
go-junit-report < test-quickstarter-results.txt > test-quickstarter-report.xml
fi
echo " "
echo " "
echo "${THIS_SCRIPT}: Returning with exit code ${exitcode}"
echo " "
echo " "
exit $exitcode