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"
39 source ${BASEDIR}/common.sh
45 # Get the list of runnable tests
46 # Check if we are in CI mode
48 if [[ "${CI_DEBUG,,}" == "true" ]];then
52 function clean_openstack(){
53 if [ $clean == true ]; then
55 info "Cleaning Openstack environment..."
56 python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py \
63 keystone_ip=$(openstack catalog show identity |grep publicURL| cut -f3 -d"/" | cut -f1 -d":")
64 # historically most of the installers use the same IP for neutron and keystone API
65 neutron_ip=$keystone_ip
66 odl_ip=$(openstack catalog show network | grep publicURL | cut -f3 -d"/" | cut -f1 -d":")
67 usr_name=$(env | grep OS | grep OS_USERNAME | cut -f2 -d'=')
68 password=$(env | grep OS | grep OS_PASSWORD | cut -f2 -d'=')
70 if [ $INSTALLER_TYPE == "fuel" ]; then
72 elif [ $INSTALLER_TYPE == "apex" ]; then
74 elif [ $INSTALLER_TYPE == "joid" ]; then
75 odl_ip=$(env | grep SDN_CONTROLLER | cut -f2 -d'=')
76 neutron_ip=$(openstack catalog show network | grep publicURL | cut -f3 -d"/" | cut -f1 -d":")
79 elif [ $INSTALLER_TYPE == "compass" ]; then
82 error "INSTALLER_TYPE not valid."
89 echo "----------------------------------------------"
90 echo " Running test case: $i"
91 echo "----------------------------------------------"
94 if [ $clean == "false" ]; then
98 if [ $serial == "true" ]; then
104 info "Running health check test..."
105 ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/healthcheck.sh
108 info "Running vPing-SSH test..."
109 python ${FUNCTEST_REPO_DIR}/testcases/vPing/CI/libraries/vPing_ssh.py \
113 info "Running vPing-userdata test... "
114 python ${FUNCTEST_REPO_DIR}/testcases/vPing/CI/libraries/vPing_userdata.py \
118 info "Running ODL test..."
120 ODL_PORT=$odl_port ODL_IP=$odl_ip KEYSTONE_IP=$keystone_ip NEUTRON_IP=$neutron_ip USR_NAME=$usr_name PASS=$password \
121 ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/start_tests.sh
123 # push results to the DB in case of CI
124 if [[ -n "$DEPLOY_SCENARIO" && "$DEPLOY_SCENARIO" != "none" ]]; then
125 odl_logs="/home/opnfv/functest/results/odl/logs/2"
126 odl_path="${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI"
127 node_name=$(env | grep NODE_NAME | cut -f2 -d'=')
128 python ${odl_path}/odlreport2db.py -x ${odl_logs}/output.xml -i ${INSTALLER_TYPE} -p ${node_name} -s ${DEPLOY_SCENARIO}
132 info "Running Tempest tests..."
133 python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/run_tempest.py \
134 $debug $serial_flag $clean_flag -m smoke $report
135 # save tempest.conf for further troubleshooting
136 tempest_conf="${RALLY_VENV_DIR}/tempest/for-deployment-*/tempest.conf"
137 if [ -f ${tempest_conf} ]; then
138 cp $tempest_conf ${FUNCTEST_CONF_DIR}
142 info "Running vIMS test..."
143 python ${FUNCTEST_REPO_DIR}/testcases/vIMS/CI/vIMS.py \
144 $debug $clean_flag $report
147 info "Running Rally benchmark suite..."
148 python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py \
149 $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 error "Make sure tempest was running before"
161 tempest_dir=/home/opnfv/.rally/tempest/$tempest_dir
163 mkdir -p /etc/tempest/
164 cp tempest.conf /etc/tempest/
165 echo "[service_available]
166 bgpvpn = True" >> /etc/tempest/tempest.conf
167 ./run_tempest.sh -t -N -- networking_bgpvpn_tempest
168 rm -rf /etc/tempest/tempest.conf
172 info "Running ONOS test case..."
173 if [ $INSTALLER_TYPE == "joid" ]; then
174 python ${FUNCTEST_REPO_DIR}/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py -i joid
176 python ${FUNCTEST_REPO_DIR}/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
180 info "Running PROMISE test case..."
181 python ${FUNCTEST_REPO_DIR}/testcases/features/promise.py $debug $report
182 sleep 10 # to let the instances terminate
185 info "Running Doctor test..."
186 python ${FUNCTEST_REPO_DIR}/testcases/features/doctor.py
189 info "Running OpenContrail test..."
190 ${repos_dir}/ovno/Testcases/RunTests.sh
194 if [ $clean == "true" ]; then
224 echo "unknown option $1 $2"
228 shift # past argument or value
232 tests_file="/home/opnfv/functest/conf/testcase-list.txt"
233 if [[ -n "$DEPLOY_SCENARIO" && "$DEPLOY_SCENARIO" != "none" ]] &&\
234 [[ -f $tests_file ]]; then
235 arr_test=($(cat $tests_file))
237 arr_test=(healthcheck vping_ssh vping_userdata tempest vims rally)
241 info "Tests to be executed: ${arr_test[@]}"
243 # Check that the given tests are correct
244 if [ "${TEST}" != "" ]; then
245 arr_test_exec=(${TEST//,/ })
246 for i in "${arr_test_exec[@]}"; do
247 if [[ " ${arr_test[*]} " != *" $i "* ]]; then
248 error "Unknown test: $i. Available tests are: ${arr_test[@]}"
251 info "Tests to execute: ${TEST}."
254 # Check that the functest environment has been installed
255 if [ ! -f ${FUNCTEST_CONF_DIR}/env_active ]; then
256 error "The Functest environment is not installed. \
257 Please run prepare_env.sh before running this script...."
262 info "Sourcing Credentials ${FUNCTEST_CONF_DIR}/openstack.creds to run the tests.."
263 source ${FUNCTEST_CONF_DIR}/openstack.creds
266 if [ "${TEST}" != "" ]; then
267 for i in "${arr_test_exec[@]}"; do
271 info "Executing tests..."
272 for i in "${arr_test[@]}"; do