Remove fragile process test from vFW validation.
[testsuite.git] / runTags.sh
1 #!/bin/bash
2
3 # Set the defaults
4 DEFAULT_LOG_LEVEL="TRACE" # Available levels: TRACE, DEBUG, INFO (default), WARN, NONE (no logging)
5 DEFAULT_RES="1280x1024x24"
6 DEFAULT_DISPLAY=":99"
7 DEFAULT_ROBOT_TEST="-i health"
8 INSTALL_NAME="OpenECOMP_ETE"
9 DEFAULT_OUTPUT_FOLDER=./
10
11 # Use default if none specified as env var
12 LOG_LEVEL=${LOG_LEVEL:-$DEFAULT_LOG_LEVEL}
13 RES=${RES:-$DEFAULT_RES}
14 DISPLAY=${DISPLAY:-$DEFAULT_DISPLAY}
15
16 # OUTPUT_FOLDER env variable will be overridden by -d command line argument.
17 OUTPUT_FOLDER=${OUTPUT_FOLDER:-$DEFAULT_OUTPUT_FOLDER}
18
19 VARIABLEFILES=
20
21 ## Single argument, it is an include tag
22 if [ $# -eq 1 ]; then
23     ROBOT_TAGS="-i $1"
24 fi
25
26 ## 
27 ## if more than 1 tag is supplied, the must be provided with -i or -e 
28 ##
29 while [ $# -gt 1 ]
30 do
31         key="$1"
32         
33         case $key in
34         -i|--include)
35         ROBOT_TAGS="${ROBOT_TAGS} -i $2"
36         shift 
37         ;;
38         -e|--exclude)
39         ROBOT_TAGS="${ROBOT_TAGS} -e $2"
40         shift 
41         ;;
42         -d|--outputdir)
43         OUTPUT_FOLDER=$2
44         shift
45         ;; 
46         --display)
47         DISPLAY=:$2
48         shift 
49         ;;
50         -V)
51         VARIABLEFILES="${VARIABLEFILES} -V $2 "
52         shift 
53         ;;
54         -v)
55         VARIABLES="${VARIABLES} -v $2 "
56         shift 
57         ;;
58         esac
59         shift
60 done    
61
62 if [ "${ROBOT_TAGS}" = "" ];then
63     ROBOT_TAGS=$DEFAULT_ROBOT_TEST
64 fi 
65
66 # Start Xvfb
67 echo -e "Starting Xvfb on display ${DISPLAY} with res ${RES}"
68 Xvfb ${DISPLAY} -ac -screen 0 ${RES} +extension RANDR &
69 XVFBPID=$!
70 # Get pid of this spawned process to make sure we kill the correct process later
71
72 export DISPLAY=${DISPLAY}
73
74 # Execute tests
75 echo -e "Executing robot tests at log level ${LOG_LEVEL}"
76
77 ROBOT_LIBS=./robot/library:./robot/library/eteutils:./robot/library/heatbridge
78
79 cd /var/opt/${INSTALL_NAME}
80 python -m robot.run -L ${LOG_LEVEL} -d ${OUTPUT_FOLDER} ${VARIABLEFILES} ${VARIABLES} -P ${ROBOT_LIBS} ${ROBOT_TAGS} $(pwd)
81
82 # Stop Xvfb we started earlier
83 # select it from list of possible Xvfb pids running because
84 # a) there may be multiple Xvfbs running and 
85 # b) the XVFBPID may not be the correct if the start did not actually work (unlikely and that may be) 
86 PIDS=$(pgrep Xvfb)
87 for P in $PIDS
88 do
89         if [ $P == $XVFBPID ];then
90                 kill -9 $P
91         fi
92 done