This repository has been archived by the owner on Aug 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
run-cnf-suites.sh
executable file
·112 lines (103 loc) · 3.28 KB
/
run-cnf-suites.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
#!/usr/bin/env bash
set -x
# defaults
export OUTPUT_LOC="$PWD/test-network-function"
usage() {
echo "$0 [-o OUTPUT_LOC] [-f SUITE...] -s [SUITE...] [-l LABEL...]"
echo "Call the script and list the test suites to run"
echo " e.g."
echo " $0 [ARGS] -f access-control lifecycle"
echo " will run the access-control and lifecycle suites"
echo ""
echo "Allowed suites are listed in the README."
}
usage_error() {
usage
exit 1
}
FOCUS=""
SKIP=""
LABEL=""
BASEDIR=$(dirname $(realpath $0))
# Parge args beginning with "-"
while [[ $1 == -* ]]; do
case "$1" in
-h|--help|-\?) usage; exit 0;;
-o) if (($# > 1)); then
OUTPUT_LOC=$2; shift
else
echo "-o requires an argument" 1>&2
exit 1
fi ;;
-s|--skip)
while (( "$#" >= 2 )) && ! [[ $2 = --* ]] && ! [[ $2 = -* ]] ; do
SKIP="$2|$SKIP"
shift
done;;
-f|--focus)
while (( "$#" >= 2 )) && ! [[ $2 = --* ]] && ! [[ $2 = -* ]] ; do
FOCUS="$2|$FOCUS"
shift
done;;
-l|--label)
while (( "$#" >= 2 )) && ! [[ $2 = --* ]] && ! [[ $2 = -* ]] ; do
LABEL="$2|$LABEL"
shift
done;;
-*) echo "invalid option: $1" 1>&2; usage_error;;
esac
shift
done
# specify Junit report file name.
GINKGO_ARGS="-junit $OUTPUT_LOC -claimloc $OUTPUT_LOC --ginkgo.junit-report $OUTPUT_LOC/cnf-certification-tests_junit.xml -ginkgo.v -test.v"
# Make sure the HTML output is copied to the output directory,
# even in case of a test failure
function html_output() {
if [ -f ${OUTPUT_LOC}/claim.json ]; then
echo -n "var initialjson=" > ${OUTPUT_LOC}/claimjson.js
cat ${OUTPUT_LOC}/claim.json >> ${OUTPUT_LOC}/claimjson.js
fi
cp ${BASEDIR}/script/results.html ${OUTPUT_LOC}
}
trap html_output EXIT
FOCUS=${FOCUS%?} # strip the trailing "|" from the concatenation
SKIP=${SKIP%?} # strip the trailing "|" from the concatenation
LABEL=${LABEL%?} # strip the trailing "|" from the concatenation
res=`oc version | grep Server`
if [ -z "$res" ]
then
echo "Minikube or similar detected"
export TNF_NON_OCP_CLUSTER=true
fi
# Run cnf-feature-deploy test container if not running inside a container
# cgroup file doesn't exist on MacOS. Consider that as not running in container as well
if [[ ! -f "/proc/1/cgroup" ]] || grep -q init\.scope /proc/1/cgroup; then
cd script
./run-cfd-container.sh
cd ..
fi
if [[ -z "${TNF_PARTNER_SRC_DIR}" ]]; then
echo "env var \"TNF_PARTNER_SRC_DIR\" not set, running the script without updating infra"
else
make -C $TNF_PARTNER_SRC_DIR install-partner-pods
fi
echo "Running with focus '$FOCUS'"
echo "Running with skip '$SKIP'"
echo "Running with label filter '$LABEL'"
echo "Report will be output to '$OUTPUT_LOC'"
echo "ginkgo arguments '${GINKGO_ARGS}'"
FOCUS_STRING=""
SKIP_STRING=""
LABEL_STRING=""
if [ -n "$FOCUS" ]; then
FOCUS_STRING=-ginkgo.focus="$FOCUS"
if [ -n "$SKIP" ]; then
SKIP_STRING=-ginkgo.skip="$SKIP"
fi
if [ -n "$LABEL" ]; then
LABEL_STRING=-ginkgo.label-filter="$LABEL"
fi
else
echo "No test suite (-f) was set, so only diagnostic functions will run. Skip patterns (-s) and labels (-l) will be ignored".
fi
cd ./test-network-function && ./test-network-function.test $FOCUS_STRING $SKIP_STRING $LABEL_STRING ${GINKGO_ARGS}