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 separated by comma:
27 vping_ssh,vping_userdata,odl,rally,tempest,vims,onos,promise,ovno
32 $(basename "$0") --test vping_ssh,odl
33 $(basename "$0") -t tempest,rally"
36 # Support for Functest offline
37 # NOTE: Still not 100% working when running the tests
41 # Get the list of runnable tests
42 # Check if we are in CI mode
45 function clean_openstack(){
46 if [ $clean == true ]; then
47 echo -e "\n\nCleaning Openstack environment..."
48 python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py \
55 keystone_ip=$(openstack catalog show identity |grep publicURL| cut -f3 -d"/" | cut -f1 -d":")
56 # historically most of the installers use the same IP for neutron and keystone API
57 neutron_ip=$keystone_ip
58 odl_ip=$(openstack catalog show network | grep publicURL | cut -f3 -d"/" | cut -f1 -d":")
59 usr_name=$(env | grep OS | grep OS_USERNAME | cut -f2 -d'=')
60 password=$(env | grep OS | grep OS_PASSWORD | cut -f2 -d'=')
62 if [ $INSTALLER_TYPE == "fuel" ]; then
64 elif [ $INSTALLER_TYPE == "apex" ]; then
66 elif [ $INSTALLER_TYPE == "joid" ]; then
67 odl_ip=$(env | grep SDN_CONTROLLER | cut -f2 -d'=')
68 neutron_ip=$(openstack catalog show network | grep publicURL | cut -f3 -d"/" | cut -f1 -d":")
71 elif [ $INSTALLER_TYPE == "compass" ]; then
74 error "INSTALLER_TYPE not valid."
81 echo "----------------------------------------------"
82 echo " Running test case: $i"
83 echo "----------------------------------------------"
87 info "Running vPing-SSH test..."
88 python ${FUNCTEST_REPO_DIR}/testcases/vPing/CI/libraries/vPing_ssh.py \
92 info "Running vPing-userdata test... "
93 python ${FUNCTEST_REPO_DIR}/testcases/vPing/CI/libraries/vPing_userdata.py \
97 info "Running ODL test..."
99 ODL_PORT=$odl_port ODL_IP=$odl_ip KEYSTONE_IP=$keystone_ip NEUTRON_IP=$neutron_ip USR_NAME=$usr_name PASS=$password \
100 ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/start_tests.sh
102 # push results to the DB in case of CI
103 if [[ -n "$DEPLOY_SCENARIO" && "$DEPLOY_SCENARIO" != "none" ]]; then
104 odl_logs="/home/opnfv/functest/results/odl/logs/2"
105 odl_path="${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI"
106 node_name=$(env | grep NODE_NAME | cut -f2 -d'=')
107 python ${odl_path}/odlreport2db.py -x ${odl_logs}/output.xml -i ${INSTALLER_TYPE} -p ${node_name} -s ${DEPLOY_SCENARIO}
111 info "Running Tempest tests..."
112 python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/run_tempest.py \
113 --debug -m custom ${report}
114 # save tempest.conf for further troubleshooting
115 tempest_conf="${RALLY_VENV_DIR}/tempest/for-deployment-*/tempest.conf"
116 if [ -f ${tempest_conf} ]; then
117 cp $tempest_conf ${FUNCTEST_CONF_DIR}
122 info "Running vIMS test..."
123 python ${FUNCTEST_REPO_DIR}/testcases/vIMS/CI/vIMS.py \
128 info "Running Rally benchmark suite..."
129 python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py \
130 --debug all ${report}
135 info "Running BGPVPN Tempest test case..."
136 tempest_dir=$(ls -t /home/opnfv/.rally/tempest/ |grep for-deploy |tail -1)
137 if [[ $tempest_dir == "" ]]; then
138 echo "Make sure tempest was running before"
141 tempest_dir=/home/opnfv/.rally/tempest/$tempest_dir
144 pip install --no-deps -e ~/repos/bgpvpn/.
145 cp tempest.conf /etc/tempest/
146 echo "[service_available]
147 bgpvpn = True" >> /etc/tempest/tempest.conf
148 ./run_tempest.sh -- networking_bgpvpn_tempest
149 rm -rf /etc/tempest/tempest.conf
153 info "Running VPNSERVICE Robot test case..."
155 cp ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/test_list.txt \
156 ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/test_list.txt.bak
158 test/csit/suites/vpnservice
159 " > ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/test_list.txt
160 ODL_PORT=$odl_port ODL_IP=$odl_ip NEUTRON_IP=$neutron_ip USR_NAME=$usr_name PASS=$password \
161 ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/start_tests.sh
162 cp ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/test_list.txt.bak \
163 ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/test_list.txt
167 info "Running ONOS test case..."
168 if [ $INSTALLER_TYPE == "joid" ]; then
169 python ${FUNCTEST_REPO_DIR}/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py -i joid
171 python ${FUNCTEST_REPO_DIR}/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
175 info "Running PROMISE test case..."
176 python ${FUNCTEST_REPO_DIR}/testcases/features/promise.py --debug ${report}
177 sleep 10 #to let the instances terminate
181 info "Running Doctor test..."
182 python ${FUNCTEST_REPO_DIR}/testcases/features/doctor.py
185 info "Running OpenContrail test..."
186 ${repos_dir}/ovno/Testcases/RunTests.sh
216 echo "unknown option $1 $2"
220 shift # past argument or value
224 tests_file="/home/opnfv/functest/conf/testcase-list.txt"
225 if [[ -n "$DEPLOY_SCENARIO" && "$DEPLOY_SCENARIO" != "none" ]] &&\
226 [[ -f $tests_file ]]; then
227 arr_test=($(cat $tests_file))
229 arr_test=(vping_ssh tempest vims rally)
233 source ${BASEDIR}/common.sh
235 info "Tests to be executed: ${arr_test[@]}"
237 # Check that the given tests are correct
238 if [ "${TEST}" != "" ]; then
239 arr_test_exec=(${TEST//,/ })
240 for i in "${arr_test_exec[@]}"; do
241 if [[ " ${arr_test[*]} " != *" $i "* ]]; then
242 error "Unknown test: $i. Available tests are: ${arr_test[@]}"
245 info "Tests to execute: ${TEST}."
248 # Check that the functest environment has been installed
249 if [ ! -f ${FUNCTEST_CONF_DIR}/env_active ]; then
250 error "The Functest environment is not installed. \
251 Please run prepare_env.sh before running this script...."
256 info "Sourcing Credentials ${FUNCTEST_CONF_DIR}/openstack.creds to run the tests.."
257 source ${FUNCTEST_CONF_DIR}/openstack.creds
260 if [ "${TEST}" != "" ]; then
261 for i in "${arr_test_exec[@]}"; do
265 info "Executing tests..."
266 for i in "${arr_test[@]}"; do