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 Tempest 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 healthcheck,vping_ssh,vping_userdata,odl,onos,
29 tempest,rally,vims,promise,doctor
34 $(basename "$0") --test vping_ssh,odl
35 $(basename "$0") -t tempest,rally"
42 # Get the list of runnable tests
43 # Check if we are in CI mode
45 if [[ "${CI_DEBUG,,}" == "true" ]];then
49 function clean_openstack(){
50 if [ $clean == true ]; then
51 echo -e "\n\nCleaning Openstack environment..."
52 python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py \
59 keystone_ip=$(openstack catalog show identity |grep publicURL| cut -f3 -d"/" | cut -f1 -d":")
60 # historically most of the installers use the same IP for neutron and keystone API
61 neutron_ip=$keystone_ip
62 odl_ip=$(openstack catalog show network | grep publicURL | cut -f3 -d"/" | cut -f1 -d":")
63 usr_name=$(env | grep OS | grep OS_USERNAME | cut -f2 -d'=')
64 password=$(env | grep OS | grep OS_PASSWORD | cut -f2 -d'=')
66 if [ $INSTALLER_TYPE == "fuel" ]; then
68 elif [ $INSTALLER_TYPE == "apex" ]; then
70 elif [ $INSTALLER_TYPE == "joid" ]; then
71 odl_ip=$(env | grep SDN_CONTROLLER | cut -f2 -d'=')
72 neutron_ip=$(openstack catalog show network | grep publicURL | cut -f3 -d"/" | cut -f1 -d":")
75 elif [ $INSTALLER_TYPE == "compass" ]; then
78 error "INSTALLER_TYPE not valid."
85 echo "----------------------------------------------"
86 echo " Running test case: $i"
87 echo "----------------------------------------------"
90 if [ $clean == "false" ]; then
94 if [ $serial == "true" ]; then
100 info "Running health check test..."
101 ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/healthcheck.sh
105 info "Running vPing-SSH test..."
106 python ${FUNCTEST_REPO_DIR}/testcases/vPing/CI/libraries/vPing_ssh.py \
107 $debug $clean_flag $report
110 info "Running vPing-userdata test... "
111 python ${FUNCTEST_REPO_DIR}/testcases/vPing/CI/libraries/vPing_userdata.py \
112 $debug $clean_flag $report
115 info "Running ODL test..."
117 ODL_PORT=$odl_port ODL_IP=$odl_ip KEYSTONE_IP=$keystone_ip NEUTRON_IP=$neutron_ip USR_NAME=$usr_name PASS=$password \
118 ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/start_tests.sh
120 # push results to the DB in case of CI
121 if [[ -n "$DEPLOY_SCENARIO" && "$DEPLOY_SCENARIO" != "none" ]]; then
122 odl_logs="/home/opnfv/functest/results/odl/logs/2"
123 odl_path="${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI"
124 node_name=$(env | grep NODE_NAME | cut -f2 -d'=')
125 python ${odl_path}/odlreport2db.py -x ${odl_logs}/output.xml -i ${INSTALLER_TYPE} -p ${node_name} -s ${DEPLOY_SCENARIO}
129 info "Running Tempest tests..."
130 python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/run_tempest.py \
131 $debug $serial_flag $clean_flag -m smoke $report
132 # save tempest.conf for further troubleshooting
133 tempest_conf="${RALLY_VENV_DIR}/tempest/for-deployment-*/tempest.conf"
134 if [ -f ${tempest_conf} ]; then
135 cp $tempest_conf ${FUNCTEST_CONF_DIR}
140 info "Running vIMS test..."
141 python ${FUNCTEST_REPO_DIR}/testcases/vIMS/CI/vIMS.py \
142 $debug $clean_flag $report
146 info "Running Rally benchmark suite..."
147 python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py \
148 $debug $clean_flag all $report
153 info "Running BGPVPN Tempest test case..."
154 pushd ${repos_dir}/bgpvpn/
155 pip install --no-deps -e .
157 tempest_dir=$(ls -t /home/opnfv/.rally/tempest/ |grep for-deploy |tail -1)
158 if [[ $tempest_dir == "" ]]; then
159 echo "Make sure tempest was running before"
162 tempest_dir=/home/opnfv/.rally/tempest/$tempest_dir
164 mkdir -p /etc/tempest/
165 cp tempest.conf /etc/tempest/
166 echo "[service_available]
167 bgpvpn = True" >> /etc/tempest/tempest.conf
168 ./run_tempest.sh -t -N -- networking_bgpvpn_tempest
169 rm -rf /etc/tempest/tempest.conf
174 info "Running ONOS test case..."
175 if [ $INSTALLER_TYPE == "joid" ]; then
176 python ${FUNCTEST_REPO_DIR}/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py -i joid
178 python ${FUNCTEST_REPO_DIR}/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
182 info "Running PROMISE test case..."
183 python ${FUNCTEST_REPO_DIR}/testcases/features/promise.py $debug $report
184 sleep 10 #to let the instances terminate
188 info "Running Doctor test..."
189 python ${FUNCTEST_REPO_DIR}/testcases/features/doctor.py
192 info "Running OpenContrail test..."
193 ${repos_dir}/ovno/Testcases/RunTests.sh
223 echo "unknown option $1 $2"
227 shift # past argument or value
231 tests_file="/home/opnfv/functest/conf/testcase-list.txt"
232 if [[ -n "$DEPLOY_SCENARIO" && "$DEPLOY_SCENARIO" != "none" ]] &&\
233 [[ -f $tests_file ]]; then
234 arr_test=($(cat $tests_file))
236 arr_test=(healthcheck vping_ssh vping_userdata tempest vims rally)
240 source ${BASEDIR}/common.sh
242 info "Tests to be executed: ${arr_test[@]}"
244 # Check that the given tests are correct
245 if [ "${TEST}" != "" ]; then
246 arr_test_exec=(${TEST//,/ })
247 for i in "${arr_test_exec[@]}"; do
248 if [[ " ${arr_test[*]} " != *" $i "* ]]; then
249 error "Unknown test: $i. Available tests are: ${arr_test[@]}"
252 info "Tests to execute: ${TEST}."
255 # Check that the functest environment has been installed
256 if [ ! -f ${FUNCTEST_CONF_DIR}/env_active ]; then
257 error "The Functest environment is not installed. \
258 Please run prepare_env.sh before running this script...."
263 info "Sourcing Credentials ${FUNCTEST_CONF_DIR}/openstack.creds to run the tests.."
264 source ${FUNCTEST_CONF_DIR}/openstack.creds
267 if [ "${TEST}" != "" ]; then
268 for i in "${arr_test_exec[@]}"; do
272 info "Executing tests..."
273 for i in "${arr_test[@]}"; do