Release 1.12.0 version
[testsuite.git] / runEteTag.sh
1 #!/bin/bash
2 INSTALL_DIR=/var/opt/ONAP
3
4 #####################################################################
5 # Start display on 256 if it has not already been started...
6 # This will stay up and be used for all soak tests
7 # Tried this once and got an unexpected error so restored the start/kill
8 # pattern for each test for now.
9 # Perhaps the error was unrelated to the using the same display for 
10 # all tests. Preserve this just in case....
11 function start_display_if
12 {
13         export DISPLAY=:256
14     xdpyinfo -display $DISPLAY >/dev/null 2>&1
15     while [ $? = 1 ]
16     do
17                 # Start Xvfb
18                 echo -e "Starting Xvfb on display ${DISPLAY} with res ${RES}"
19                 Xvfb ${DISPLAY} -ac -screen 0 ${RES} +extension RANDR &
20                 disown
21     done
22 }
23
24 #####################################################################
25 function start_display
26 {
27         export DISPLAY=:$(( $TEST_NUMBER % 256 ))
28     xdpyinfo -display $DISPLAY >/dev/null 2>&1
29     while [ $? = 0 ]
30     do
31            DISPLAY=$(( $RANDOM % 1000 ))
32        xdpyinfo -display $DISPLAY >/dev/null 2>&1
33     done
34         # Start Xvfb
35         echo -e "Starting Xvfb on display ${DISPLAY} with res ${RES}"
36         Xvfb ${DISPLAY} -ac -screen 0 ${RES} +extension RANDR &
37         XVFBPID=$!
38         disown
39         echo ${DISPLAY} > /tmp/robotDisplay.$TEST_NUMBER
40         # Get and save pid of this spawned process to make sure we kill the correct process later
41 }
42
43 #####################################################################
44 function kill_display
45 {
46     xdpyinfo -display $DISPLAY >/dev/null 2>&1
47     if [ $? = 0 ]; then
48        kill -9 $XVFBPID >/dev/null 2>&1
49     fi
50     rm -rf   /tmp/robotDisplay.$TEST_NUMBER
51 }
52
53 #####################################################################
54 # main
55 #####################################################################
56 export ROBOT_TAG=$1
57 export TEST_NUMBER=$2
58
59 if [ "$TEST_NUMBER" = "" ];then
60     TEST_NUMBER=$$
61 fi
62
63 # Use default if none specified as env var
64 DEFAULT_LOG_LEVEL="INFO" # Available levels: TRACE, DEBUG, INFO (default), WARN, NONE (no logging)
65 LOG_LEVEL=${LOG_LEVEL:-$DEFAULT_LOG_LEVEL}
66
67 # To mitigate the chromedriver hanging issue
68 export DBUS_SESSION_BUS_ADDRESS=/dev/null
69
70 RES="1280x1024x24"
71 OUTPUT_FOLDER=/share/logs/${SOAKSUBFOLDER}runEteTag_$TEST_NUMBER
72 mkdir -p $OUTPUT_FOLDER
73 INSTALL_DIR="/var/opt/ONAP"
74
75 ROBOT_LIBS=./robot/library:./robot/library/ONAPLibrary:./robot/library/heatbridge
76 VARIABLEFILES="-V /share/config/vm_properties.py -V /share/config/integration_robot_properties.py -V /share/config/integration_preload_parameters.py"
77 VARIABLES="-v GLOBAL_BUILD_NUMBER:$TEST_NUMBER"
78 LISTENERS=
79
80 start_display
81
82 # Execute tests
83 echo -e "Executing robot test ${ROBOT_TAG} at log level ${LOG_LEVEL}"
84
85 cd ${INSTALL_DIR}
86 python -m robot.run -L ${LOG_LEVEL} -d ${OUTPUT_FOLDER} ${VARIABLEFILES} ${VARIABLES} ${LISTENERS} -P ${ROBOT_LIBS} -i ${ROBOT_TAG} $(pwd) > ${OUTPUT_FOLDER}/robot.out 2>&1
87
88 ####################################################################
89 # Stop Xvfb we started earlier
90 kill_display