Add reporting to DB in OpenDaylightTesting
[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         odl_ip=$SDN_CONTROLLER_IP
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_IP
60         odl_port=8080
61     fi
62 }
63
64 function run_test(){
65     test_name=$1
66     serial_flag=""
67     if [ $serial == "true" ]; then
68         serial_flag="-s"
69     fi
70
71     case $test_name in
72         "healthcheck")
73             ${FUNCTEST_REPO_DIR}/testcases/OpenStack/healthcheck/healthcheck.sh
74         ;;
75         "vping_ssh")
76             python ${FUNCTEST_REPO_DIR}/testcases/OpenStack/vPing/vPing_ssh.py $report
77         ;;
78         "vping_userdata")
79             python ${FUNCTEST_REPO_DIR}/testcases/OpenStack/vPing/vPing_userdata.py $report
80         ;;
81         "odl")
82             odl_tests
83             if [[ "$report" == "-r" &&
84                   -n "$DEPLOY_SCENARIO" && "$DEPLOY_SCENARIO" != "none" &&
85                   -n "$INSTALLER_TYPE" && "$INSTALLER_TYPE" != "none" ]] &&
86                env | grep NODE_NAME > /dev/null; then
87                 args=-p
88             fi
89             ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/OpenDaylightTesting.py \
90                 --keystoneip $keystone_ip --neutronip $neutron_ip \
91                 --osusername ${OS_USERNAME} --ostenantname ${OS_TENANT_NAME} \
92                 --ospassword ${OS_PASSWORD} \
93                 --odlip $odl_ip --odlwebport $odl_port ${args}
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/vnf/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             sdnvpn_repo_dir=${repos_dir}/sdnvpn/test/functest/
115             python ${sdnvpn_repo_dir}/run_tests.py $report
116         ;;
117         "onos")
118             python ${FUNCTEST_REPO_DIR}/testcases/Controllers/ONOS/Teston/onosfunctest.py
119         ;;
120         "onos_sfc")
121             python ${FUNCTEST_REPO_DIR}/testcases/Controllers/ONOS/Teston/onosfunctest.py -t sfc
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 $report
129         ;;
130         "ovno")
131             # suite under rewritting for colorado
132             # no need to run anything until refactoring done
133             # ${repos_dir}/ovno/Testcases/RunTests.sh
134         ;;
135         "security_scan")
136             echo "Sourcing Credentials ${FUNCTEST_CONF_DIR}/stackrc for undercloud .."
137             source ${FUNCTEST_CONF_DIR}/stackrc
138             python ${repos_dir}/securityscanning/security_scan.py --config ${repos_dir}/securityscanning/config.ini
139         ;;
140         "copper")
141             python ${FUNCTEST_REPO_DIR}/testcases/features/copper.py $report
142         ;;
143         "moon")
144             python ${repos_dir}/moon/tests/run_tests.py $report
145         ;;
146         "multisite")
147             python ${FUNCTEST_REPO_DIR}/testcases/OpenStack/tempest/gen_tempest_conf.py
148             python ${FUNCTEST_REPO_DIR}/testcases/OpenStack/tempest/run_tempest.py \
149                 $clean_flag -s -m feature_multisite $report \
150                 -c ${FUNCTEST_REPO_DIR}/testcases/OpenStack/tempest/tempest_multisite.conf
151         ;;
152         "domino")
153             python ${FUNCTEST_REPO_DIR}/testcases/features/domino.py $report
154         ;;
155         "odl-sfc")
156             bash ${FUNCTEST_REPO_DIR}/testcases/features/sfc/server_presetup_CI.bash
157             ret_val=$?
158             if [ $ret_val != 0 ]; then
159                 exit $ret_val
160             fi
161             bash ${FUNCTEST_REPO_DIR}/testcases/features/sfc/compute_presetup_CI.bash
162             ret_val=$?
163             if [ $ret_val != 0 ]; then
164                 exit $ret_val
165             fi
166             source ${FUNCTEST_REPO_DIR}/testcases/features/sfc/tackerc
167             python ${FUNCTEST_REPO_DIR}/testcases/features/sfc/sfc.py $report
168         ;;
169         "parser")
170             python ${FUNCTEST_REPO_DIR}/testcases/vnf/vRNC/parser.py $report
171         ;;
172         *)
173             echo "The test case '${test_name}' does not exist."
174             exit 1
175     esac
176
177     if [[ $? != 0 ]]; then exit 1
178     else exit 0
179     fi
180 }
181
182
183 # Parse parameters
184 while [[ $# > 0 ]]
185     do
186     key="$1"
187     case $key in
188         -h|--help)
189             echo "$usage"
190             exit 0
191             shift
192         ;;
193         -r|--report)
194             report="-r"
195         ;;
196         -s|--serial)
197             serial=true
198         ;;
199         -t|--test|--tests)
200             TEST="$2"
201             shift
202         ;;
203         *)
204             echo "unknown option $1 $2"
205             exit 1
206         ;;
207     esac
208     shift # past argument or value
209 done
210
211
212 # Source credentials
213 echo "Sourcing Credentials ${FUNCTEST_CONF_DIR}/openstack.creds to run the test.."
214 source ${FUNCTEST_CONF_DIR}/openstack.creds
215
216
217 # Run test
218 run_test $TEST