aboutsummaryrefslogtreecommitdiffstats
path: root/runTags.sh
blob: 03f75dab9f855dcc8e2db14df7c108437c7ce9ad (plain)
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

# Set the defaults
DEFAULT_LOG_LEVEL="TRACE" # Available levels: TRACE, DEBUG, INFO (default), WARN, NONE (no logging)
DEFAULT_RES="1280x1024x24"
DEFAULT_DISPLAY=":99"
DEFAULT_ROBOT_TEST="-i health"
INSTALL_NAME="ONAP"
DEFAULT_OUTPUT_FOLDER=./

# To mitigate the chromedriver hanging issue
export DBUS_SESSION_BUS_ADDRESS=/dev/null

# Use default if none specified as env var
LOG_LEVEL=${LOG_LEVEL:-$DEFAULT_LOG_LEVEL}
RES=${RES:-$DEFAULT_RES}
DISPLAY=${DISPLAY:-$DEFAULT_DISPLAY}

# OUTPUT_FOLDER env variable will be overridden by -d command line argument.
OUTPUT_FOLDER=${OUTPUT_FOLDER:-$DEFAULT_OUTPUT_FOLDER}

VARIABLEFILES=
LISTENERS=
VARIABLES="--removekeywords name:keystone_interface.*"

## Single argument, it is an include tag
if [ $# -eq 1 ]; then
    ROBOT_TAGS="-i $1"
fi

##
## if more than 1 tag is supplied, the must be provided with -i or -e
##
while [ $# -gt 1 ]
do
	key="$1"

	case $key in
    	-i|--include)
    	ROBOT_TAGS="${ROBOT_TAGS} -i $2"
    	shift
    	;;
    	-e|--exclude)
    	ROBOT_TAGS="${ROBOT_TAGS} -e $2"
    	shift
    	;;
    	-d|--outputdir)
    	OUTPUT_FOLDER=$2
    	shift
    	;;
  		--display)
    	DISPLAY=:$2
    	shift
    	;;
  		--listener)
    	LISTENERS="${LISTENER} --listener $2 "
    	shift
    	;;
   		-V)
    	VARIABLEFILES="${VARIABLEFILES} -V $2 "
    	shift
    	;;
   		-v)
    	VARIABLES="${VARIABLES} -v $2 "
    	shift
    	;;
	esac
	shift
done

if [ "${ROBOT_TAGS}" = "" ];then
    ROBOT_TAGS=$DEFAULT_ROBOT_TEST
fi

# Start Xvfb
echo -e "Starting Xvfb on display ${DISPLAY} with res ${RES}"
Xvfb ${DISPLAY} -ac -screen 0 ${RES} +extension RANDR &
XVFBPID=$!
# Get pid of this spawned process to make sure we kill the correct process later

export DISPLAY=${DISPLAY}

# Execute tests
echo -e "Executing robot tests at log level ${LOG_LEVEL}"

ROBOT_LIBS=./robot/library:./robot/library/eteutils:./robot/library/heatbridge

cd /var/opt/${INSTALL_NAME}
python -m robot.run -L ${LOG_LEVEL} -d ${OUTPUT_FOLDER} ${VARIABLEFILES} ${VARIABLES} ${LISTENERS} -P ${ROBOT_LIBS} ${ROBOT_TAGS} /var/opt/${INSTALL_NAME}/robot/testsuites/
RET_CODE=$?

# Stop Xvfb we started earlier
# select it from list of possible Xvfb pids running because
# a) there may be multiple Xvfbs running and
# b) the XVFBPID may not be the correct if the start did not actually work (unlikely and that may be)
PIDS=$(pgrep Xvfb)
for P in $PIDS
do
	if [ $P == $XVFBPID ];then
		kill -9 $P
	fi
done

exit $RET_CODE