-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathrun_containerqa.sh
More file actions
105 lines (92 loc) · 3.33 KB
/
run_containerqa.sh
File metadata and controls
105 lines (92 loc) · 3.33 KB
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
#!/bin/bash
###############################################################################
## run_containerqa.sh
## This script sets up the host under test for running the
## container testing against the Red Hat OpenJDK containers
##
###############################################################################
set -ex
set -o pipefail
## resolve folder of this script, following all symlinks,
## http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
SCRIPT_SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SCRIPT_SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
SCRIPT_DIR="$( cd -P "$( dirname "$SCRIPT_SOURCE" )" && pwd )"
SCRIPT_SOURCE="$(readlink "$SCRIPT_SOURCE")"
# if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
[[ $SCRIPT_SOURCE != /* ]] && SCRIPT_SOURCE="$SCRIPT_DIR/$SCRIPT_SOURCE"
done
readonly SCRIPT_DIR="$( cd -P "$( dirname "$SCRIPT_SOURCE" )" && pwd )"
# Help function
function print_help() {
echo "Name: run_containerqa.sh
Description: Red Hat OpenJDK testsuite for Red Hat OpenShift Container Platform.
Command-line arguements:
--container-image
Container image under test.
--report-dir
Directory to store the execution logs.
Example: run_containerqa.sh \
--container-image=registry.access.redhat.com/ubi8/openjdk-8:1.17-1.1693366248 \
--report-dir=/mnt/log_dir/
"
exit 1
}
# The commandline should be `run_containerqa.sh --container-image=registry.access.redhat.com/ubi8/openjdk-8:1.17-1.1693366248`
for a in "$@"
do
case $a in
--container-image=*)
CONTAINER_VERSION="${a#*=}"
;;
--report-dir=*)
ARG_REPORT_DIR="${a#*=}"
;;
*)
echo "Unrecognized argument: '$a'" >&2
print_help >&2
;;
esac
done
if [ -z "$CONTAINER_VERSION" ] ; then
print_help >&2
fi
if [ -n "$ARG_REPORT_DIR" ] ; then
if [ ! -e "$ARG_REPORT_DIR" ] ; then
echo "$ARG_REPORT_DIR do not exists"
exit 2
fi
fi
echo "Ensure that the run-folder-as-tests sub-repo is properly pulled down."
echo "Ensure Podman is installed on the host under tests."
echo "See test.yaml file if in doubts"
TIME=$(date +%s)
jtWork="test.${TIME}/jdk/work"
jtReport="test.${TIME}/jdk/report"
mkdir -p $jtWork
mkdir -p $jtReport
export SCRATCH_DISK="`pwd`/$jtWork"
export WORKSPACE="`pwd`/$jtReport"
SUITE_FOLDER="containersQa"
REMOTE_NORMAL_CONTAINER=true bash ${SCRIPT_DIR}/run-folder-as-tests/run-folder-as-tests.sh ${SCRIPT_DIR}/${SUITE_FOLDER} ${CONTAINER_VERSION} | tee test.${TIME}/tests.log
toPack="${jtReport} test.${TIME}/tests.log"
if [ "x$JNI_PACK_WORK" == "xtrue" ] ; then
toPack="$toPack ${jtWork}";
fi
tar -czf test.${TIME}.tar.gz $toPack || echo "Packing of results tarball failed"
if ! [ -f test.${TIME}/tests.log ] ; then
echo "Missing tests.log!" 1>&2
exit 1
fi
if [ -n "$ARG_REPORT_DIR" ] ; then
if [ -e "$ARG_REPORT_DIR" ] ; then
mv -v test.${TIME}.* "$ARG_REPORT_DIR"
fi
fi
# results should be in log, if not, it means suite was not run
grep -Eqi -e '^passed' -e '^(failed|error)' -e '^Ignored' test.${TIME}/tests.log || exit 2
if [ "x$CQA_FAIL" == "xtrue" ] ; then
if grep -Eq -e '^Failed: [1-9]' test.${TIME}/tests.log ; then
exit 1
fi
fi