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 -t|--test run specific set of tests
26 <test_name> one or more of the following: vping,odl,rally,tempest,vims,onos,promise,ovno. Separated by comma.
31 $(basename "$0") --test vping,odl
32 $(basename "$0") -t tempest,rally"
35 # Support for Functest offline
36 # NOTE: Still not 100% working when running the tests
40 # Get the list of runnable tests
41 # Check if we are in CI mode
44 function clean_openstack(){
45 if [ $clean == true ]; then
46 echo -e "\n\nCleaning Openstack environment..."
47 python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py \
54 keystone_ip=$(keystone catalog --service identity | grep publicURL | cut -f3 -d"/" | cut -f1 -d":")
55 # historically most of the installers use the same IP for neutron and keystone API
56 neutron_ip=$keystone_ip
57 odl_ip=$(keystone catalog --service network | grep publicURL | cut -f3 -d"/" | cut -f1 -d":")
58 usr_name=$(env | grep OS | grep OS_USERNAME | cut -f2 -d'=')
59 password=$(env | grep OS | grep OS_PASSWORD | cut -f2 -d'=')
61 if [ $INSTALLER_TYPE == "fuel" ]; then
63 elif [ $INSTALLER_TYPE == "apex" ]; then
65 elif [ $INSTALLER_TYPE == "joid" ]; then
66 odl_ip=$(env | grep ODL_CONTROLLER | cut -f2 -d'=')
67 neutron_ip=$(keystone catalog --service network | grep publicURL | cut -f3 -d"/" | cut -f1 -d":")
70 elif [ $INSTALLER_TYPE == "compass" ]; then
73 error "INSTALLER_TYPE not valid."
80 echo "----------------------------------------------"
81 echo " Running test cases: $i"
82 echo "----------------------------------------------"
86 info "Running vPing test..."
87 python ${FUNCTEST_REPO_DIR}/testcases/vPing/CI/libraries/vPing2.py \
91 info "Running vPing test using userdata/cloudinit.... "
92 python ${FUNCTEST_REPO_DIR}/testcases/vPing/CI/libraries/vPing.py \
96 info "Running ODL test..."
98 ODL_PORT=$odl_port ODL_IP=$odl_ip KEYSTONE_IP=$keystone_ip NEUTRON_IP=$neutron_ip USR_NAME=$usr_name PASS=$password \
99 ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/start_tests.sh
101 # push results to the DB in case of CI
102 if [[ -n "$DEPLOY_SCENARIO" && "$DEPLOY_SCENARIO" != "none" ]]; then
103 odl_logs="/home/opnfv/functest/results/odl/logs/2"
104 odl_path="${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI"
105 node_name=$(env | grep NODE_NAME | cut -f2 -d'=')
106 python ${odl_path}/odlreport2db.py -x ${odl_logs}/output.xml -i ${INSTALLER_TYPE} -p ${node_name} -s ${DEPLOY_SCENARIO}
110 info "Running Tempest tests..."
111 python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/run_tempest.py \
112 --debug -m custom ${report}
113 # save tempest.conf for further troubleshooting
114 tempest_conf="${RALLY_VENV_DIR}/tempest/for-deployment-*/tempest.conf"
115 if [ -f ${tempest_conf} ]; then
116 cp $tempest_conf ${FUNCTEST_CONF_DIR}
121 info "Running vIMS test..."
122 python ${FUNCTEST_REPO_DIR}/testcases/vIMS/CI/vIMS.py \
127 info "Running Rally benchmark suite..."
128 cinder type-create volume-test #provisional
129 python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py \
130 --debug all ${report}
131 cinder type-delete $(cinder type-list|grep test|awk '{print $2}')
136 info "Running BGPVPN Tempest test case..."
137 tempest_dir=$(ls -t /home/opnfv/.rally/tempest/ |grep for-deploy |tail -1)
138 if [[ $tempest_dir == "" ]]; then
139 echo "Make sure tempest was running before"
142 tempest_dir=/home/opnfv/.rally/tempest/$tempest_dir
145 pip install --no-deps -e ~/repos/bgpvpn/.
146 cp tempest.conf /etc/tempest/
147 echo "[service_available]
148 bgpvpn = True" >> /etc/tempest/tempest.conf
149 ./run_tempest.sh -- networking_bgpvpn_tempest
150 rm -rf /etc/tempest/tempest.conf
154 info "Running VPNSERVICE Robot test case..."
156 cp ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/test_list.txt \
157 ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/test_list.txt.bak
159 test/csit/suites/vpnservice
160 " > ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/test_list.txt
161 ODL_PORT=$odl_port ODL_IP=$odl_ip NEUTRON_IP=$neutron_ip USR_NAME=$usr_name PASS=$password \
162 ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/start_tests.sh
163 cp ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/test_list.txt.bak \
164 ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/test_list.txt
168 info "Running ONOS test case..."
169 python ${FUNCTEST_REPO_DIR}/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
172 info "Running PROMISE test case..."
173 python ${FUNCTEST_REPO_DIR}/testcases/features/promise.py --debug ${report}
177 info "Running Doctor test..."
178 python ${FUNCTEST_REPO_DIR}/testcases/features/doctor.py
181 info "Running OpenContrail test..."
212 echo "unknown option $1 $2"
216 shift # past argument or value
220 tests_file="/home/opnfv/functest/conf/testcase-list.txt"
221 if [[ -n "$DEPLOY_SCENARIO" && "$DEPLOY_SCENARIO" != "none" ]] &&\
222 [[ -f $tests_file ]]; then
223 arr_test=($(cat $tests_file))
225 arr_test=(vping tempest vims rally)
227 echo "arr_test: "${arr_test[@]}
230 source ${BASEDIR}/common.sh
233 # Check that the given tests are correct
234 if [ "${TEST}" != "" ]; then
235 arr_test_exec=(${TEST//,/ })
236 for i in "${arr_test_exec[@]}"; do
237 if [[ " ${arr_test[*]} " != *" $i "* ]]; then
238 error "Unknown test: $i. Available tests are: ${arr_test[@]}"
241 info "Tests to execute: ${TEST}."
244 if [ $offline == false ]; then
250 # Check that the functest environment has been installed
251 if [ ! -f ${FUNCTEST_CONF_DIR}/env_active ]; then
252 error "The Functest environment is not installed. \
253 Please run prepare_env.sh before running this script...."
258 info "Sourcing Credentials ${FUNCTEST_CONF_DIR}/openstack.creds to run the tests.."
259 source ${FUNCTEST_CONF_DIR}/openstack.creds
262 if [ "${TEST}" != "" ]; then
263 for i in "${arr_test_exec[@]}"; do
267 info "Executing tests..."
268 for i in "${arr_test[@]}"; do