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
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
16 usage="Script to trigger the tests automatically.
19 bash $(basename "$0") [-h|--help] [-t <test_name>]
22 -h|--help show this help text
23 -r|--report push results to database (false by default)
24 -n|--no-clean do not clean OpenStack resources after test run
25 -s|--serial run tests in one thread
26 -t|--test run specific set of tests
27 <test_name> one or more of the following separated by comma:
28 vping_ssh,vping_userdata,odl,onos,tempest,rally,vims,promise,doctor
33 $(basename "$0") --test vping_ssh,odl
34 $(basename "$0") -t tempest,rally"
37 # Support for Functest offline
38 # NOTE: Still not 100% working when running the tests
44 # Get the list of runnable tests
45 # Check if we are in CI mode
48 function clean_openstack(){
49 if [ $clean == true ]; then
50 echo -e "\n\nCleaning Openstack environment..."
51 python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py \
58 keystone_ip=$(openstack catalog show identity |grep publicURL| cut -f3 -d"/" | cut -f1 -d":")
59 # historically most of the installers use the same IP for neutron and keystone API
60 neutron_ip=$keystone_ip
61 odl_ip=$(openstack catalog show network | grep publicURL | cut -f3 -d"/" | cut -f1 -d":")
62 usr_name=$(env | grep OS | grep OS_USERNAME | cut -f2 -d'=')
63 password=$(env | grep OS | grep OS_PASSWORD | cut -f2 -d'=')
65 if [ $INSTALLER_TYPE == "fuel" ]; then
67 elif [ $INSTALLER_TYPE == "apex" ]; then
69 elif [ $INSTALLER_TYPE == "joid" ]; then
70 odl_ip=$(env | grep SDN_CONTROLLER | cut -f2 -d'=')
71 neutron_ip=$(openstack catalog show network | grep publicURL | cut -f3 -d"/" | cut -f1 -d":")
74 elif [ $INSTALLER_TYPE == "compass" ]; then
77 error "INSTALLER_TYPE not valid."
84 echo "----------------------------------------------"
85 echo " Running test case: $i"
86 echo "----------------------------------------------"
89 if [ $clean == "false" ]; then
93 if [ $serial == "true" ]; then
99 info "Running vPing-SSH test..."
100 python ${FUNCTEST_REPO_DIR}/testcases/vPing/CI/libraries/vPing_ssh.py \
101 --debug $clean_flag ${report}
104 info "Running vPing-userdata test... "
105 python ${FUNCTEST_REPO_DIR}/testcases/vPing/CI/libraries/vPing_userdata.py \
106 --debug $clean_flag ${report}
109 info "Running ODL test..."
111 ODL_PORT=$odl_port ODL_IP=$odl_ip KEYSTONE_IP=$keystone_ip NEUTRON_IP=$neutron_ip USR_NAME=$usr_name PASS=$password \
112 ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/start_tests.sh
114 # push results to the DB in case of CI
115 if [[ -n "$DEPLOY_SCENARIO" && "$DEPLOY_SCENARIO" != "none" ]]; then
116 odl_logs="/home/opnfv/functest/results/odl/logs/2"
117 odl_path="${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI"
118 node_name=$(env | grep NODE_NAME | cut -f2 -d'=')
119 python ${odl_path}/odlreport2db.py -x ${odl_logs}/output.xml -i ${INSTALLER_TYPE} -p ${node_name} -s ${DEPLOY_SCENARIO}
123 info "Running Tempest tests..."
124 python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/run_tempest.py \
125 --debug $serial_flag $clean_flag -m custom ${report}
126 # save tempest.conf for further troubleshooting
127 tempest_conf="${RALLY_VENV_DIR}/tempest/for-deployment-*/tempest.conf"
128 if [ -f ${tempest_conf} ]; then
129 cp $tempest_conf ${FUNCTEST_CONF_DIR}
134 info "Running vIMS test..."
135 python ${FUNCTEST_REPO_DIR}/testcases/vIMS/CI/vIMS.py \
136 --debug $clean_flag ${report}
140 info "Running Rally benchmark suite..."
141 python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py \
142 --debug $clean_flag all ${report}
147 info "Running BGPVPN Tempest test case..."
148 tempest_dir=$(ls -t /home/opnfv/.rally/tempest/ |grep for-deploy |tail -1)
149 if [[ $tempest_dir == "" ]]; then
150 echo "Make sure tempest was running before"
153 tempest_dir=/home/opnfv/.rally/tempest/$tempest_dir
156 pip install --no-deps -e ~/repos/bgpvpn/.
157 mkdir -p /etc/tempest/
158 cp tempest.conf /etc/tempest/
159 echo "[service_available]
160 bgpvpn = True" >> /etc/tempest/tempest.conf
161 ./run_tempest.sh -- networking_bgpvpn_tempest
162 rm -rf /etc/tempest/tempest.conf
166 info "Running VPNSERVICE Robot test case..."
168 cp ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/test_list.txt \
169 ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/test_list.txt.bak
171 test/csit/suites/vpnservice
172 " > ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/test_list.txt
173 ODL_PORT=$odl_port ODL_IP=$odl_ip NEUTRON_IP=$neutron_ip USR_NAME=$usr_name PASS=$password \
174 ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/start_tests.sh
175 cp ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/test_list.txt.bak \
176 ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/test_list.txt
180 info "Running ONOS test case..."
181 if [ $INSTALLER_TYPE == "joid" ]; then
182 python ${FUNCTEST_REPO_DIR}/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py -i joid
184 python ${FUNCTEST_REPO_DIR}/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
188 info "Running PROMISE test case..."
189 python ${FUNCTEST_REPO_DIR}/testcases/features/promise.py --debug ${report}
190 sleep 10 #to let the instances terminate
194 info "Running Doctor test..."
195 python ${FUNCTEST_REPO_DIR}/testcases/features/doctor.py
198 info "Running OpenContrail test..."
199 ${repos_dir}/ovno/Testcases/RunTests.sh
232 echo "unknown option $1 $2"
236 shift # past argument or value
240 tests_file="/home/opnfv/functest/conf/testcase-list.txt"
241 if [[ -n "$DEPLOY_SCENARIO" && "$DEPLOY_SCENARIO" != "none" ]] &&\
242 [[ -f $tests_file ]]; then
243 arr_test=($(cat $tests_file))
245 arr_test=(vping_ssh tempest vims rally)
249 source ${BASEDIR}/common.sh
251 info "Tests to be executed: ${arr_test[@]}"
253 # Check that the given tests are correct
254 if [ "${TEST}" != "" ]; then
255 arr_test_exec=(${TEST//,/ })
256 for i in "${arr_test_exec[@]}"; do
257 if [[ " ${arr_test[*]} " != *" $i "* ]]; then
258 error "Unknown test: $i. Available tests are: ${arr_test[@]}"
261 info "Tests to execute: ${TEST}."
264 # Check that the functest environment has been installed
265 if [ ! -f ${FUNCTEST_CONF_DIR}/env_active ]; then
266 error "The Functest environment is not installed. \
267 Please run prepare_env.sh before running this script...."
272 info "Sourcing Credentials ${FUNCTEST_CONF_DIR}/openstack.creds to run the tests.."
273 source ${FUNCTEST_CONF_DIR}/openstack.creds
276 if [ "${TEST}" != "" ]; then
277 for i in "${arr_test_exec[@]}"; do
281 info "Executing tests..."
282 for i in "${arr_test[@]}"; do