fix absolute/relative issue in start_test.sh
[functest.git] / testcases / Controllers / ODL / CI / start_tests.sh
1 #!/bin/bash
2 # Script requires that test environment is created already
3 # it includes python2.7 virtual env with robot packages and git
4 # use create_env.sh script for creating python virtualenv
5
6 BASEDIR=`dirname $0`
7 # Colors
8 green='\033[0;32m'
9 light_green='\033[1;32m'
10 red='\033[1;31m'
11 nc='\033[0m' # No Color
12
13 usage="Script for starting ODL tests. Tests to be executed are specified in test_list.txt file.
14
15 usage:
16 [var=value] bash $(basename "$0") [-h]
17
18 where:
19     -h     show this help text
20     var    one of the following: ODL_IP, ODL_PORT, USR_NAME, PASS, NEUTRON_IP
21     value  new value for var
22
23 example:
24     ODL_IP=oscontro1 ODL_PORT=8080 bash $(basename "$0")"
25
26 while getopts ':h' option; do
27   case "$option" in
28     h) echo "$usage"
29        exit
30        ;;
31    \?) printf "illegal option: -%s\n" "$OPTARG" >&2
32        echo "$usage" >&2
33        exit 1
34        ;;
35   esac
36 done
37
38 echo -e "${green}Current environment parameters for ODL suite.${nc}"
39 # Following vars might be also specified as CLI params
40 set -x
41 ODL_IP=${ODL_IP:-'192.168.1.5'}
42 ODL_PORT=${ODL_PORT:-8081}
43 USR_NAME=${USR_NAME:-'neutron'}
44 PASS=${PASS:-'octopus'}
45 NEUTRON_IP=${NEUTRON_IP:-192.168.0.68}
46 set +x
47
48 echo -e "${green}Cloning ODL integration git repo.${nc}"
49 if [ -d ${BASEDIR}/integration ]; then
50     cd ${BASEDIR}/integration
51     git checkout -- .
52     git pull
53     cd -
54 else
55     git clone https://github.com/opendaylight/integration.git ${BASEDIR}/integration
56 fi
57
58 # Change openstack password for admin tenant in neutron suite
59 sed -i "s/\"password\": \"admin\"/\"password\": \"${PASS}\"/" ${BASEDIR}/integration/test/csit/suites/openstack/neutron/__init__.robot
60
61 if source $BASEDIR/venv/bin/activate; then
62     echo -e "${green}Python virtualenv activated.${nc}"
63 else
64     echo -e "${red}ERROR${nc}"
65     exit 1
66 fi
67
68 # add custom tests to suite, if there are more custom tests needed this will be reworked
69 echo -e "${green}Copy custom tests to suite.${nc}"
70 cp -vf $BASEDIR/custom_tests/neutron/* $BASEDIR/integration/test/csit/suites/openstack/neutron/
71
72 # List of tests are specified in test_list.txt
73 # those are relative paths to test directories from integartion suite
74 echo -e "${green}Executing chosen tests.${nc}"
75 test_num=1
76 while read line
77 do
78     # skip comments
79     [[ ${line:0:1} == "#" ]] && continue
80     # skip empty lines
81     [[ -z "${line}" ]] && continue
82
83     echo -e "${light_green}Starting test: $line ${nc}"
84     pybot -v OPENSTACK:${NEUTRON_IP} -v PORT:${ODL_PORT} -v CONTROLLER:${ODL_IP} ${BASEDIR}/$line
85     mkdir -p $BASEDIR/logs/${test_num}
86     mv log.html $BASEDIR/logs/${test_num}/
87     mv report.html $BASEDIR/logs/${test_num}/
88     mv output.xml $BASEDIR/logs/${test_num}/
89     ((test_num++))
90 done < ${BASEDIR}/test_list.txt
91
92 echo -e "${green}Deactivate venv.${nc}"
93 deactivate
94
95 # Now we can copy output.xml, log.html and report.xml files generated by robot.