3800b63075cd560f7b0876e550b19677fc284e73
[functest.git] / testcases / Controllers / ODL / CI / start_tests.sh
1 #!/bin/bash
2 # it includes python2.7 virtual env with robot packages and git
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9
10 BASEDIR=`dirname $0`
11 RESULTS_DIR='/home/opnfv/functest/results/odl/'
12 REPO_DIR='/home/opnfv/repos/odl_integration'
13 #TODO: read this form config_functest.yaml
14
15 # Colors
16 green='\033[0;32m'
17 light_green='\033[1;32m'
18 red='\033[1;31m'
19 nc='\033[0m' # No Color
20
21 usage="Script for starting ODL tests. Tests to be executed are specified in test_list.txt file.
22
23 usage:
24 [var=value] bash $(basename "$0") [-h]
25
26 where:
27     -h     show this help text
28     var    one of the following: ODL_IP, ODL_PORT, USR_NAME, PASS, NEUTRON_IP
29     value  new value for var
30
31 example:
32     ODL_IP=oscontro1 ODL_PORT=8080 bash $(basename "$0")"
33
34 while getopts ':h' option; do
35   case "$option" in
36     h) echo "$usage"
37        exit
38        ;;
39    \?) printf "illegal option: -%s\n" "$OPTARG" >&2
40        echo "$usage" >&2
41        exit 1
42        ;;
43   esac
44 done
45
46 echo -e "${green}Current environment parameters for ODL suite.${nc}"
47 # Following vars might be also specified as CLI params
48 set -x
49 ODL_IP=${ODL_IP:-'192.168.1.5'}
50 ODL_PORT=${ODL_PORT:-8081}
51 USR_NAME=${USR_NAME:-'neutron'}
52 PASS=${PASS:-'octopus'}
53 NEUTRON_IP=${NEUTRON_IP:-192.168.0.68}
54 KEYSTONE_IP=${KEYSTONE_IP:-192.168.0.69}
55 set +x
56
57 init_file=${REPO_DIR}/test/csit/suites/openstack/neutron/__init__.robot
58 # Change openstack password for admin tenant in neutron suite
59 sed -i "s/\"password\": \".*\"/\"password\": \"${PASS}\"/" $init_file
60
61 # Add Start Suite and Teardown Suite
62 if [[ ! `grep 'Suite Teardown' ${init_file}` ]]; then
63     sed -i "/^Documentation.*/a Suite Teardown     Stop Suite" $init_file
64     sed -i "/^Documentation.*/a Suite Setup        Start Suite" $init_file
65 fi
66
67 # add custom tests to suite, if there are more custom tests needed this will be reworked
68 echo -e "${green}Copy custom tests to suite.${nc}"
69 cp -vf ${BASEDIR}/custom_tests/neutron/* ${REPO_DIR}/test/csit/suites/openstack/neutron/
70
71 # List of tests are specified in test_list.txt
72 # those are relative paths to test directories from integartion suite
73 echo -e "${green}Executing chosen tests.${nc}"
74 test_num=0
75 while read line
76 do
77     # skip comments
78     [[ ${line:0:1} == "#" ]] && continue
79     # skip empty lines
80     [[ -z "${line}" ]] && continue
81
82     ((test_num++))
83     echo -e "${light_green}Starting test: $line ${nc}"
84     pybot -v OPENSTACK:${KEYSTONE_IP} -v NEUTRON:${NEUTRON_IP} -v PORT:${ODL_PORT} -v CONTROLLER:${ODL_IP} ${REPO_DIR}/$line
85     mkdir -p $RESULTS_DIR/logs/${test_num}
86     mv log.html $RESULTS_DIR/logs/${test_num}/
87     mv report.html $RESULTS_DIR/logs/${test_num}/
88     mv output.xml $RESULTS_DIR/logs/${test_num}/
89 done < ${BASEDIR}/test_list.txt
90
91 # create final report which includes all partial test reports
92 for i in $(seq $test_num); do
93   rebot_params="$rebot_params $RESULTS_DIR/logs/$i/output.xml"
94 done
95
96 echo -e "${green}Final report is located:${nc}"
97 rebot $rebot_params