Remove logger as input parameter of functions in openstack_utils
[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             ${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
88
89             # push results to the DB in case of CI
90             # if [[ "$report" == "-r" &&
91             #       -n "$DEPLOY_SCENARIO" && "$DEPLOY_SCENARIO" != "none" &&
92             #       -n "$INSTALLER_TYPE" && "$INSTALLER_TYPE" != "none" ]] &&
93             #    env | grep NODE_NAME > /dev/null; then
94             #     odl_logs="/home/opnfv/functest/results/odl/"
95             #     odl_path="${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/"
96             #     node_name=$(env | grep NODE_NAME | cut -f2 -d'=')
97             #     python ${odl_path}/odlreport2db.py -x ${odl_logs}/output.xml -i ${INSTALLER_TYPE} -p ${node_name} -s ${DEPLOY_SCENARIO}
98             # fi
99         ;;
100         "tempest_smoke_serial")
101             python ${FUNCTEST_REPO_DIR}/testcases/OpenStack/tempest/run_tempest.py \
102                 $clean_flag -s -m smoke $report
103         ;;
104         "tempest_full_parallel")
105             python ${FUNCTEST_REPO_DIR}/testcases/OpenStack/tempest/run_tempest.py \
106                 $serial_flag $clean_flag -m full $report
107         ;;
108         "vims")
109             python ${FUNCTEST_REPO_DIR}/testcases/vnf/vIMS/vIMS.py $clean_flag $report
110         ;;
111         "rally_full")
112             python ${FUNCTEST_REPO_DIR}/testcases/OpenStack/rally/run_rally-cert.py $clean_flag all $report
113         ;;
114         "rally_sanity")
115             python ${FUNCTEST_REPO_DIR}/testcases/OpenStack/rally/run_rally-cert.py \
116                 $clean_flag --sanity all $report
117         ;;
118         "bgpvpn")
119             sdnvpn_repo_dir=${repos_dir}/sdnvpn/test/functest/
120             # Copy blacklist from sdnvpn repo to the proper place to execute functest
121             src=${sdnvpn_repo_dir}/tempest_blacklist.txt
122             dst=${FUNCTEST_REPO_DIR}/testcases/OpenStack/tempest/custom_tests/blacklist.txt
123             cp $src $dst
124             # Execute tempest smoke with blacklist
125             python ${FUNCTEST_REPO_DIR}/testcases/OpenStack/tempest/run_tempest.py \
126                 $clean_flag -s -m smoke $report
127             # Remove blacklist file
128             rm $dst
129
130             # Execute SDNVPN test cases
131             python ${sdnvpn_repo_dir}/run_tests.py $report
132
133         ;;
134         "onos")
135             python ${FUNCTEST_REPO_DIR}/testcases/Controllers/ONOS/Teston/onosfunctest.py
136       ;;
137         "promise")
138             python ${FUNCTEST_REPO_DIR}/testcases/features/promise.py $report
139             sleep 10 # to let the instances terminate
140         ;;
141         "doctor")
142             python ${FUNCTEST_REPO_DIR}/testcases/features/doctor.py
143         ;;
144         "ovno")
145             # suite under rewritting for colorado
146             # no need to run anything until refactoring done
147             # ${repos_dir}/ovno/Testcases/RunTests.sh
148         ;;
149         "security_scan")
150             echo "Sourcing Credentials ${FUNCTEST_CONF_DIR}/stackrc for undercloud .."
151             source ${FUNCTEST_CONF_DIR}/stackrc
152             python ${FUNCTEST_REPO_DIR}/testcases/security_scan/security_scan.py --config ${FUNCTEST_REPO_DIR}/testcases/security_scan/config.ini
153         ;;
154         "copper")
155             python ${FUNCTEST_REPO_DIR}/testcases/features/copper.py
156         ;;
157         "moon")
158             # TODO put the link to Moon script to be run (if test runnable) here
159             ${repos_dir}/moon/tests/run_tests.sh
160         ;;
161         "multisite")
162             python ${FUNCTEST_REPO_DIR}/testcases/features/multisite.py
163             python ${FUNCTEST_REPO_DIR}/testcases/OpenStack/tempest/run_tempest.py \
164                 $clean_flag -s -m feature_multisite $report
165         ;;
166         "domino")
167             python ${FUNCTEST_REPO_DIR}/testcases/features/domino.py
168         ;;
169         *)
170             echo "The test case '${test_name}' does not exist."
171             exit 1
172     esac
173
174     if [[ $? != 0 ]]; then exit 1
175     else exit 0
176     fi
177 }
178
179
180 # Parse parameters
181 while [[ $# > 0 ]]
182     do
183     key="$1"
184     case $key in
185         -h|--help)
186             echo "$usage"
187             exit 0
188             shift
189         ;;
190         -r|--report)
191             report="-r"
192         ;;
193         -s|--serial)
194             serial=true
195         ;;
196         -t|--test|--tests)
197             TEST="$2"
198             shift
199         ;;
200         *)
201             echo "unknown option $1 $2"
202             exit 1
203         ;;
204     esac
205     shift # past argument or value
206 done
207
208
209 # Source credentials
210 echo "Sourcing Credentials ${FUNCTEST_CONF_DIR}/openstack.creds to run the test.."
211 source ${FUNCTEST_CONF_DIR}/openstack.creds
212
213
214 # Run test
215 run_test $TEST