Use 8081 for apex's restconfport robot variable
[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     odl_restport=8181
51     if [ "$INSTALLER_TYPE" == "fuel" ]; then
52         odl_port=8282
53     elif [ "$INSTALLER_TYPE" == "apex" ]; then
54         odl_ip=$SDN_CONTROLLER_IP
55         odl_port=8081
56         odl_restport=8081
57     elif [ "$INSTALLER_TYPE" == "joid" ]; then
58         odl_ip=$SDN_CONTROLLER
59     elif [ "$INSTALLER_TYPE" == "compass" ]; then
60         odl_port=8181
61     else
62         odl_ip=$SDN_CONTROLLER_IP
63     fi
64 }
65
66
67
68 function run_test(){
69     test_name=$1
70     serial_flag=""
71     if [ $serial == "true" ]; then
72         serial_flag="-s"
73     fi
74
75     case $test_name in
76         "healthcheck")
77             ${FUNCTEST_TEST_DIR}/openstack/healthcheck/healthcheck.sh
78         ;;
79         "odl")
80             odl_tests
81             [[ "$report" == "-r" ]] && args=-p
82             ${FUNCTEST_TEST_DIR}/sdn/odl/odl.py \
83                 --keystoneip $keystone_ip \
84                 --neutronip $neutron_ip \
85                 --odlip $odl_ip \
86                 --odlrestconfport $odl_restport \
87                 --odlwebport $odl_port \
88                 --ospassword ${OS_PASSWORD} \
89                 --ostenantname ${OS_TENANT_NAME} \
90                 --osusername ${OS_USERNAME} \
91                 ${args}
92         ;;
93         "vims")
94             python ${FUNCTEST_TEST_DIR}/vnf/ims/vims.py $clean_flag $report
95         ;;
96         "rally_full")
97             python ${FUNCTEST_TEST_DIR}/openstack/rally/run_rally-cert.py $clean_flag all $report
98         ;;
99         "rally_sanity")
100             python ${FUNCTEST_TEST_DIR}/openstack/rally/run_rally-cert.py \
101                 $clean_flag --sanity all $report
102         ;;
103         "onos")
104             python ${FUNCTEST_TEST_DIR}/sdn/onos/teston/onos.py
105         ;;
106         "onos_sfc")
107             python ${FUNCTEST_TEST_DIR}/sdn/onos/teston/onos.py -t sfc
108         ;;
109         "promise")
110             python ${FUNCTEST_TEST_DIR}/features/promise.py $report
111             sleep 10 # to let the instances terminate
112         ;;
113         "doctor")
114             python ${FUNCTEST_TEST_DIR}/features/doctor.py $report
115         ;;
116         "ovno")
117             # suite under rewritting for colorado
118             # no need to run anything until refactoring done
119             # ${REPOS_DIR}/ovno/Testcases/RunTests.sh
120         ;;
121         "security_scan")
122             echo "Sourcing Credentials ${FUNCTEST_CONF_DIR}/stackrc for undercloud .."
123             source ${FUNCTEST_CONF_DIR}/stackrc
124             python ${FUNCTEST_TEST_DIR}/security_scan/security_scan.py --config ${FUNCTEST_TEST_DIR}/security_scan/config.ini
125         ;;
126         "copper")
127             python ${FUNCTEST_TEST_DIR}/features/copper.py $report
128         ;;
129         "moon")
130             python ${REPOS_DIR}/moon/tests/run_tests.py $report
131         ;;
132         *)
133             echo "The test case '${test_name}' does not exist."
134             exit 1
135     esac
136
137     if [[ $? != 0 ]]; then exit 1
138     else exit 0
139     fi
140 }
141
142
143 # Parse parameters
144 while [[ $# > 0 ]]
145     do
146     key="$1"
147     case $key in
148         -h|--help)
149             echo "$usage"
150             exit 0
151             shift
152         ;;
153         -r|--report)
154             report="-r"
155         ;;
156         -s|--serial)
157             serial=true
158         ;;
159         -t|--test|--tests)
160             TEST="$2"
161             shift
162         ;;
163         *)
164             echo "unknown option $1 $2"
165             exit 1
166         ;;
167     esac
168     shift # past argument or value
169 done
170
171
172 # Source credentials
173 echo "Sourcing Credentials ${creds} to run the test.."
174 source ${creds}
175
176
177 # Run test
178 run_test $TEST