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,rally,tempest,vims,onos,promise,ovno
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 cp tempest.conf /etc/tempest/
158 echo "[service_available]
159 bgpvpn = True" >> /etc/tempest/tempest.conf
160 ./run_tempest.sh -- networking_bgpvpn_tempest
161 rm -rf /etc/tempest/tempest.conf
165 info "Running VPNSERVICE Robot test case..."
167 cp ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/test_list.txt \
168 ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/test_list.txt.bak
170 test/csit/suites/vpnservice
171 " > ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/test_list.txt
172 ODL_PORT=$odl_port ODL_IP=$odl_ip NEUTRON_IP=$neutron_ip USR_NAME=$usr_name PASS=$password \
173 ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/start_tests.sh
174 cp ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/test_list.txt.bak \
175 ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/test_list.txt
179 info "Running ONOS test case..."
180 if [ $INSTALLER_TYPE == "joid" ]; then
181 python ${FUNCTEST_REPO_DIR}/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py -i joid
183 python ${FUNCTEST_REPO_DIR}/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
187 info "Running PROMISE test case..."
188 python ${FUNCTEST_REPO_DIR}/testcases/features/promise.py --debug ${report}
189 sleep 10 #to let the instances terminate
193 info "Running Doctor test..."
194 python ${FUNCTEST_REPO_DIR}/testcases/features/doctor.py
197 info "Running OpenContrail test..."
198 ${repos_dir}/ovno/Testcases/RunTests.sh
231 echo "unknown option $1 $2"
235 shift # past argument or value
239 tests_file="/home/opnfv/functest/conf/testcase-list.txt"
240 if [[ -n "$DEPLOY_SCENARIO" && "$DEPLOY_SCENARIO" != "none" ]] &&\
241 [[ -f $tests_file ]]; then
242 arr_test=($(cat $tests_file))
244 arr_test=(vping_ssh tempest vims rally)
248 source ${BASEDIR}/common.sh
250 info "Tests to be executed: ${arr_test[@]}"
252 # Check that the given tests are correct
253 if [ "${TEST}" != "" ]; then
254 arr_test_exec=(${TEST//,/ })
255 for i in "${arr_test_exec[@]}"; do
256 if [[ " ${arr_test[*]} " != *" $i "* ]]; then
257 error "Unknown test: $i. Available tests are: ${arr_test[@]}"
260 info "Tests to execute: ${TEST}."
263 # Check that the functest environment has been installed
264 if [ ! -f ${FUNCTEST_CONF_DIR}/env_active ]; then
265 error "The Functest environment is not installed. \
266 Please run prepare_env.sh before running this script...."
271 info "Sourcing Credentials ${FUNCTEST_CONF_DIR}/openstack.creds to run the tests.."
272 source ${FUNCTEST_CONF_DIR}/openstack.creds
275 if [ "${TEST}" != "" ]; then
276 for i in "${arr_test_exec[@]}"; do
280 info "Executing tests..."
281 for i in "${arr_test[@]}"; do