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