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