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