Merge "[Promise test case] Use proper way to get parameters from yaml"
[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             bash ${FUNCTEST_REPO_DIR}/testcases/features/sfc/server_presetup_CI.bash
151             ret_val=$?
152             if [ $ret_val != 0 ]; then
153                 exit $ret_val
154             fi
155             bash ${FUNCTEST_REPO_DIR}/testcases/features/sfc/compute_presetup_CI.bash
156             ret_val=$?
157             if [ $ret_val != 0 ]; then
158                 exit $ret_val
159             fi
160             source ${FUNCTEST_REPO_DIR}/testcases/features/sfc/tackerc
161             python ${FUNCTEST_REPO_DIR}/testcases/features/sfc/sfc.py $report
162         ;;
163         "parser")
164             python ${FUNCTEST_REPO_DIR}/testcases/vnf/vRNC/parser.py $report
165         ;;
166         *)
167             echo "The test case '${test_name}' does not exist."
168             exit 1
169     esac
170
171     if [[ $? != 0 ]]; then exit 1
172     else exit 0
173     fi
174 }
175
176
177 # Parse parameters
178 while [[ $# > 0 ]]
179     do
180     key="$1"
181     case $key in
182         -h|--help)
183             echo "$usage"
184             exit 0
185             shift
186         ;;
187         -r|--report)
188             report="-r"
189         ;;
190         -s|--serial)
191             serial=true
192         ;;
193         -t|--test|--tests)
194             TEST="$2"
195             shift
196         ;;
197         *)
198             echo "unknown option $1 $2"
199             exit 1
200         ;;
201     esac
202     shift # past argument or value
203 done
204
205
206 # Source credentials
207 echo "Sourcing Credentials ${FUNCTEST_CONF_DIR}/openstack.creds to run the test.."
208 source ${FUNCTEST_CONF_DIR}/openstack.creds
209
210
211 # Run test
212 run_test $TEST