Merge "Fix image format set for rally test cases"
[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 export PYTHONUNBUFFERED=1
43
44 function odl_tests(){
45     keystone_ip=$(openstack catalog show identity |grep publicURL| cut -f3 -d"/" | cut -f1 -d":")
46     neutron_ip=$(openstack catalog show network | grep publicURL | cut -f3 -d"/" | cut -f1 -d":")
47     odl_ip=${neutron_ip}
48     odl_port=8080
49     if [ "$INSTALLER_TYPE" == "fuel" ]; then
50         odl_port=8282
51     elif [ "$INSTALLER_TYPE" == "apex" ]; then
52         odl_ip=$SDN_CONTROLLER_IP
53         odl_port=8181
54     elif [ "$INSTALLER_TYPE" == "joid" ]; then
55         odl_ip=$SDN_CONTROLLER
56     elif [ "$INSTALLER_TYPE" == "compass" ]; then
57         odl_port=8181
58     else
59         odl_ip=$SDN_CONTROLLER_IP
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.py -m ssh $report
76         ;;
77         "vping_userdata")
78             python ${FUNCTEST_REPO_DIR}/testcases/OpenStack/vPing/vping.py -m userdata $report
79         ;;
80         "odl")
81             odl_tests
82             [[ "$report" == "-r" ]] && args=-p
83             ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/OpenDaylightTesting.py \
84                 --keystoneip $keystone_ip --neutronip $neutron_ip \
85                 --osusername ${OS_USERNAME} --ostenantname ${OS_TENANT_NAME} \
86                 --ospassword ${OS_PASSWORD} \
87                 --odlip $odl_ip --odlwebport $odl_port ${args}
88         ;;
89         "tempest_smoke_serial")
90             python ${FUNCTEST_REPO_DIR}/testcases/OpenStack/tempest/run_tempest.py \
91                 $clean_flag -s -m smoke $report
92         ;;
93         "tempest_full_parallel")
94             python ${FUNCTEST_REPO_DIR}/testcases/OpenStack/tempest/run_tempest.py \
95                 $serial_flag $clean_flag -m full $report
96         ;;
97         "vims")
98             python ${FUNCTEST_REPO_DIR}/testcases/vnf/vIMS/vIMS.py $clean_flag $report
99         ;;
100         "rally_full")
101             python ${FUNCTEST_REPO_DIR}/testcases/OpenStack/rally/run_rally-cert.py $clean_flag all $report
102         ;;
103         "rally_sanity")
104             python ${FUNCTEST_REPO_DIR}/testcases/OpenStack/rally/run_rally-cert.py \
105                 $clean_flag --sanity all $report
106         ;;
107         "bgpvpn")
108             sdnvpn_repo_dir=${repos_dir}/sdnvpn/test/functest/
109             python ${sdnvpn_repo_dir}/run_tests.py $report
110         ;;
111         "onos")
112             python ${FUNCTEST_REPO_DIR}/testcases/Controllers/ONOS/Teston/onosfunctest.py
113         ;;
114         "onos_sfc")
115             python ${FUNCTEST_REPO_DIR}/testcases/Controllers/ONOS/Teston/onosfunctest.py -t sfc
116         ;;
117         "promise")
118             python ${FUNCTEST_REPO_DIR}/testcases/features/promise.py $report
119             sleep 10 # to let the instances terminate
120         ;;
121         "doctor")
122             python ${FUNCTEST_REPO_DIR}/testcases/features/doctor.py $report
123         ;;
124         "ovno")
125             # suite under rewritting for colorado
126             # no need to run anything until refactoring done
127             # ${repos_dir}/ovno/Testcases/RunTests.sh
128         ;;
129         "security_scan")
130             echo "Sourcing Credentials ${FUNCTEST_CONF_DIR}/stackrc for undercloud .."
131             source ${FUNCTEST_CONF_DIR}/stackrc
132             python ${repos_dir}/securityscanning/security_scan.py --config ${repos_dir}/securityscanning/config.ini
133         ;;
134         "copper")
135             python ${FUNCTEST_REPO_DIR}/testcases/features/copper.py $report
136         ;;
137         "moon")
138             python ${repos_dir}/moon/tests/run_tests.py $report
139         ;;
140         "multisite")
141             python ${FUNCTEST_REPO_DIR}/testcases/OpenStack/tempest/gen_tempest_conf.py
142             python ${FUNCTEST_REPO_DIR}/testcases/OpenStack/tempest/run_tempest.py \
143                 $clean_flag -s -m feature_multisite $report \
144                 -c ${FUNCTEST_REPO_DIR}/testcases/OpenStack/tempest/tempest_multisite.conf
145         ;;
146         "domino")
147             python ${FUNCTEST_REPO_DIR}/testcases/features/domino.py $report
148         ;;
149         "odl-sfc")
150             ODL_SFC_DIR=${FUNCTEST_REPO_DIR}/testcases/features/sfc
151             # pass FUNCTEST_REPO_DIR inside prepare_odl_sfc.bash
152             FUNCTEST_REPO_DIR=${FUNCTEST_REPO_DIR} bash ${ODL_SFC_DIR}/prepare_odl_sfc.bash || exit $?
153             source ${ODL_SFC_DIR}/tackerc
154             python ${ODL_SFC_DIR}/sfc.py $report
155         ;;
156         "parser")
157             python ${FUNCTEST_REPO_DIR}/testcases/vnf/vRNC/parser.py $report
158         ;;
159         *)
160             echo "The test case '${test_name}' does not exist."
161             exit 1
162     esac
163
164     if [[ $? != 0 ]]; then exit 1
165     else exit 0
166     fi
167 }
168
169
170 # Parse parameters
171 while [[ $# > 0 ]]
172     do
173     key="$1"
174     case $key in
175         -h|--help)
176             echo "$usage"
177             exit 0
178             shift
179         ;;
180         -r|--report)
181             report="-r"
182         ;;
183         -s|--serial)
184             serial=true
185         ;;
186         -t|--test|--tests)
187             TEST="$2"
188             shift
189         ;;
190         *)
191             echo "unknown option $1 $2"
192             exit 1
193         ;;
194     esac
195     shift # past argument or value
196 done
197
198
199 # Source credentials
200 echo "Sourcing Credentials ${FUNCTEST_CONF_DIR}/openstack.creds to run the test.."
201 source ${FUNCTEST_CONF_DIR}/openstack.creds
202
203
204 # Run test
205 run_test $TEST