Merge "Added 60 sec delay before launching instances in healthcheck"
[functest.git] / ci / exec_test.sh
1 #!/bin/bash
2
3 #
4 # Author: Jose Lausuch (jose.lausuch@ericsson.com)
5 #         Morgan Richomme (morgan.richomme@orange.com)
6 # Installs the Functest framework within the Docker container
7 # and run the tests automatically
8 #
9 #
10 # All rights reserved. This program and the accompanying materials
11 # are made available under the terms of the Apache License, Version 2.0
12 # which accompanies this distribution, and is available at
13 # http://www.apache.org/licenses/LICENSE-2.0
14 #
15
16 usage="Script to trigger the tests automatically.
17
18 usage:
19     bash $(basename "$0") [-h|--help] [-t <test_name>]
20
21 where:
22     -h|--help         show this help text
23     -r|--report       push results to database (false by default)
24     -s|--serial       run Tempest tests in one thread
25     -t|--test         run specific test case
26       <test_name>"
27
28
29 report=""
30 serial=false
31
32 # Get the list of runnable tests
33 # Check if we are in CI mode
34 debug=""
35 if [[ "${CI_DEBUG,,}" == "true" ]];then
36     debug="--debug"
37 fi
38
39 FUNCTEST_REPO_DIR=${repos_dir}/functest/
40 FUNCTEST_CONF_DIR=/home/opnfv/functest/conf/
41
42
43 function odl_tests(){
44     keystone_ip=$(openstack catalog show identity |grep publicURL| cut -f3 -d"/" | cut -f1 -d":")
45     neutron_ip=$(openstack catalog show network | grep publicURL | cut -f3 -d"/" | cut -f1 -d":")
46     odl_ip=${neutron_ip}
47     odl_port=8181
48     if [ "$INSTALLER_TYPE" == "fuel" ]; then
49         odl_port=8282
50     elif [ "$INSTALLER_TYPE" == "apex" ]; then
51         :
52     elif [ "$INSTALLER_TYPE" == "joid" ]; then
53         odl_ip=$SDN_CONTROLLER
54         odl_port=8080
55         :
56     elif [ "$INSTALLER_TYPE" == "compass" ]; then
57         :
58     else
59         odl_ip=$SDN_CONTROLLER
60     fi
61 }
62
63 function run_test(){
64     test_name=$1
65     serial_flag=""
66     if [ $serial == "true" ]; then
67         serial_flag="-s"
68     fi
69
70     case $test_name in
71         "healthcheck")
72             ${FUNCTEST_REPO_DIR}/testcases/OpenStack/healthcheck/healthcheck.sh
73         ;;
74         "vping_ssh")
75             python ${FUNCTEST_REPO_DIR}/testcases/OpenStack/vPing/vPing_ssh.py $report
76         ;;
77         "vping_userdata")
78             python ${FUNCTEST_REPO_DIR}/testcases/OpenStack/vPing/vPing_userdata.py $report
79         ;;
80         "odl")
81             odl_tests
82             ODL_PORT=$odl_port ODL_IP=$odl_ip KEYSTONE_IP=$keystone_ip NEUTRON_IP=$neutron_ip USR_NAME=${OS_USERNAME} PASS=${OS_PASSWORD} \
83                 ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/start_tests.sh
84
85             # push results to the DB in case of CI
86             if [[ -n "$DEPLOY_SCENARIO" && "$DEPLOY_SCENARIO" != "none" &&
87                   -n "$INSTALLER_TYPE" && "$INSTALLER_TYPE" != "none" ]] &&
88                env | grep NODE_NAME > /dev/null; then
89                 odl_logs="/home/opnfv/functest/results/odl/logs/2"
90                 odl_path="${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/"
91                 node_name=$(env | grep NODE_NAME | cut -f2 -d'=')
92                 python ${odl_path}/odlreport2db.py -x ${odl_logs}/output.xml -i ${INSTALLER_TYPE} -p ${node_name} -s ${DEPLOY_SCENARIO}
93             fi
94         ;;
95         "tempest_smoke_serial")
96             python ${FUNCTEST_REPO_DIR}/testcases/OpenStack/tempest/run_tempest.py \
97                 $clean_flag -s -m smoke $report
98         ;;
99         "tempest_full_parallel")
100             python ${FUNCTEST_REPO_DIR}/testcases/OpenStack/tempest/run_tempest.py \
101                 $serial_flag $clean_flag -m full $report
102         ;;
103         "vims")
104             python ${FUNCTEST_REPO_DIR}/testcases/vIMS/vIMS.py $clean_flag $report
105         ;;
106         "rally_full")
107             python ${FUNCTEST_REPO_DIR}/testcases/OpenStack/rally/run_rally-cert.py $clean_flag all $report
108         ;;
109         "rally_sanity")
110             python ${FUNCTEST_REPO_DIR}/testcases/OpenStack/rally/run_rally-cert.py \
111                 $clean_flag --sanity all $report
112         ;;
113         "bgpvpn")
114             python ${FUNCTEST_REPO_DIR}/testcases/features/bgpvpn.py
115         ;;
116         "onos")
117             if [ "$INSTALLER_TYPE" == "joid" ]; then
118                 python ${FUNCTEST_REPO_DIR}/testcases/Controllers/ONOS/Teston/onosfunctest.py -i joid
119             else
120                 python ${FUNCTEST_REPO_DIR}/testcases/Controllers/ONOS/Teston/onosfunctest.py
121             fi
122       ;;
123         "promise")
124             python ${FUNCTEST_REPO_DIR}/testcases/features/promise.py $report
125             sleep 10 # to let the instances terminate
126         ;;
127         "doctor")
128             python ${FUNCTEST_REPO_DIR}/testcases/features/doctor.py
129         ;;
130         "ovno")
131             ${repos_dir}/ovno/Testcases/RunTests.sh
132         ;;
133         *)
134             echo "The test case '${test_name}' does not exist."
135             exit 1
136     esac
137 }
138
139
140 # Parse parameters
141 while [[ $# > 0 ]]
142     do
143     key="$1"
144     case $key in
145         -h|--help)
146             echo "$usage"
147             exit 0
148             shift
149         ;;
150         -r|--report)
151             report="-r"
152         ;;
153         -s|--serial)
154             serial=true
155         ;;
156         -t|--test|--tests)
157             TEST="$2"
158             shift
159         ;;
160         *)
161             echo "unknown option $1 $2"
162             exit 1
163         ;;
164     esac
165     shift # past argument or value
166 done
167
168
169 # Source credentials
170 echo "Sourcing Credentials ${FUNCTEST_CONF_DIR}/openstack.creds to run the test.."
171 source ${FUNCTEST_CONF_DIR}/openstack.creds
172
173
174 # Run test
175 run_test $TEST