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