4 # Author: Jose Lausuch (jose.lausuch@ericsson.com)
6 # Installs the Functest framework within the Docker container
7 # and run the tests automatically
10 usage="Script to trigger the tests automatically.
13 bash $(basename "$0") [--offline] [-h|--help] [-t <test_name>]
16 -o|--offline optional offline mode (experimental)
17 -h|--help show this help text
18 -r|--report push results to database (false by default)
19 -t|--test run specific set of tests
20 <test_name> one or more of the following: vping,odl,rally,tempest,vims,onos,promise,ovno. Separated by comma.
25 $(basename "$0") --test vping,odl
26 $(basename "$0") --offline -t tempest,rally"
29 # Support for Functest offline
30 # NOTE: Still not 100% working when running the tests
33 # Get the list of runnable tests
34 # Check if we are in CI mode
35 tests_file="/home/opnfv/functest/conf/testcase-list.txt"
36 if [[ -n "$DEPLOY_SCENARIO" && "$DEPLOY_SCENARIO" != "none" ]] &&\
37 [[ -f $tests_file ]]; then
38 arr_test=($(cat $tests_file))
40 arr_test=(vping tempest vims rally)
43 function clean_openstack(){
44 echo -e "\n\nCleaning Openstack environment..."
45 python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/clean_openstack.py \
53 echo "----------------------------------------------"
54 echo " Running test cases: $i"
55 echo "----------------------------------------------"
59 info "Running vPing test..."
60 python ${FUNCTEST_REPO_DIR}/testcases/vPing/CI/libraries/vPing.py \
64 info "Running ODL test..."
65 neutron_ip=$(keystone catalog --service identity | grep publicURL | cut -f3 -d"/" | cut -f1 -d":")
66 odl_ip=$(keystone catalog --service 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
76 elif [ $INSTALLER_TYPE == "compass" ]; then
79 error "INSTALLER_TYPE not valid."
82 ODL_PORT=$odl_port ODL_IP=$odl_ip NEUTRON_IP=$neutron_ip USR_NAME=$usr_name PASS=$password \
83 ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/start_tests.sh
86 odl_logs="${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/logs"
87 if [ -d ${odl_logs} ]; then
88 cp -Rf ${odl_logs} ${FUNCTEST_CONF_DIR}/ODL/
92 info "Running Tempest tests..."
93 python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/run_tempest.py \
94 --debug -m custom ${report}
95 # save tempest.conf for further troubleshooting
96 tempest_conf="${RALLY_VENV_DIR}/tempest/for-deployment-*/tempest.conf"
97 if [ -f ${tempest_conf} ]; then
98 cp $tempest_conf ${FUNCTEST_CONF_DIR}
103 info "Running vIMS test..."
104 python ${FUNCTEST_REPO_DIR}/testcases/vIMS/CI/vIMS.py \
109 info "Running Rally benchmark suite..."
110 cinder type-create volume-test #provisional
111 python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/run_rally.py \
112 --debug all ${report}
113 cinder type-delete $(cinder type-list|grep test|awk '{print $2}')
118 info "Running BGPVPN Tempest test case..."
119 tempest_dir=$(find /root/.rally -type d -name for-deploy*)
121 # do the call of your test case here.
122 # the bgpvpn repo is cloned in $BGPVPN_REPO_DIR
123 # tempest is installed in $tempest_dir
125 # mkdir ${tempest_dir}/tempest/api/bgpvpn/
126 # cp ${BGPVPN_REPO_DIR}/networking_bgpvpn_tempest/<whatever you need> \
127 # ${tempest_dir}/tempest/api/bgpvpn/
128 # ${tempest_dir}/run_tempest.sh tempest.api.bgpvpn.<test_case_name>
131 info "Running ONOS test case..."
132 python ${FUNCTEST_REPO_DIR}/testcases/Controllers/ONOS/Teston/CI/onosfunctest.py
135 info "Running PROMISE test case..."
139 info "Running Doctor test..."
140 python ${FUNCTEST_REPO_DIR}/testcases/features/doctor.py
143 info "Running OpenContrail test..."
171 echo "unknown option $1 $2"
175 shift # past argument or value
179 source ${BASEDIR}/common.sh
182 # Check that the given tests are correct
183 if [ "${TEST}" != "" ]; then
184 arr_test_exec=(${TEST//,/ })
185 for i in "${arr_test_exec[@]}"; do
186 if [[ " ${arr_test[*]} " != *" $i "* ]]; then
187 error "Unknown test: $i. Available tests are: ${arr_test[@]}"
190 info "Tests to execute: ${TEST}."
193 if [ $offline == false ]; then
199 # Check that the functest environment has been installed
200 if [ ! -f ${FUNCTEST_CONF_DIR}/env_active ]; then
201 error "The Functest environment is not installed. \
202 Please run prepare_env.sh before running this script...."
207 info "Sourcing Credentials ${FUNCTEST_CONF_DIR}/openstack.creds to run the tests.."
208 source ${FUNCTEST_CONF_DIR}/openstack.creds
211 if [ "${TEST}" != "" ]; then
212 for i in "${arr_test_exec[@]}"; do
216 info "Executing all the tests"
217 for i in "${arr_test[@]}"; do