4 # Author: Jose Lausuch (jose.lausuch@ericsson.com)
6 # Installs the Functest framework within the Docker container
7 # and run the tests automatically
11 config_file=$(find / -name config_functest.yaml)
13 REPOS_DIR=$(cat $config_file | grep -w dir_repos | awk 'END {print $NF}')
14 FUNCTEST_REPO_DIR=$(cat $config_file | grep -w dir_repo_functest | awk 'END {print $NF}')
15 RALLY_REPO_DIR=$(cat $config_file | grep -w dir_repo_rally | awk 'END {print $NF}')
16 RELENG_REPO_DIR=$(cat $config_file | grep -w dir_repo_releng | awk 'END {print $NF}')
18 FUNCTEST_DIR=$(cat $config_file | grep -w dir_functest | awk 'END {print $NF}')
19 FUNCTEST_RESULTS_DIR=$(cat $config_file | grep -w dir_results | awk 'END {print $NF}')
20 FUNCTEST_CONF_DIR=$(cat $config_file | grep -w dir_functest_conf | awk 'END {print $NF}')
21 FUNCTEST_DATA_DIR=$(cat $config_file | grep -w dir_functest_data | awk 'END {print $NF}')
22 RALLY_VENV=$(cat $config_file | grep -w dir_rally_inst | awk 'END {print $NF}')
23 RALLY_COMMIT=$(cat $config_file | grep -w rally_stable_commit | awk 'END {print $NF}')
26 echo "REPOS_DIR=${REPOS_DIR}"
27 echo "FUNCTEST_REPO_DIR=${FUNCTEST_REPO_DIR}"
28 echo "RALLY_REPO_DIR=${RALLY_REPO_DIR}"
29 echo "RELENG_REPO_DIR=${RELENG_REPO_DIR}"
30 echo "FUNCTEST_DIR=${FUNCTEST_DIR}"
31 echo "FUNCTEST_RESULTS_DIR=${FUNCTEST_RESULTS_DIR}"
32 echo "FUNCTEST_CONF_DIR=${FUNCTEST_CONF_DIR}"
33 echo "FUNCTEST_DATA_DIR=${FUNCTEST_DATA_DIR}"
34 echo "RALLY_VENV=${RALLY_VENV}"
35 echo "RALLY_COMMIT=${RALLY_COMMIT}"
39 logger -s -t "start.info" "$*"
44 logger -s -t "start.error" "$*"
48 # Check if environment variables are set
49 if [ -z ${INSTALLER_TYPE} ]; then
50 error "Environment variable 'INSTALLER_TYPE' is not defined."
51 elif [ "${INSTALLER_TYPE}" != "fuel" ] && [ "${INSTALLER_TYPE}" != "foreman" ]; then
52 error "Invalid environment variable INSTALLER_TYPE=${INSTALLER_TYPE}"
55 if [ -z ${INSTALLER_IP} ]; then
56 error "Environment variable 'INSTALLER_IP' is not defined."
61 cd ${FUNCTEST_REPO_DIR}
66 git reset --hard ${RALLY_COMMIT}
70 mkdir -p ${FUNCTEST_CONF_DIR}
71 mkdir -p ${FUNCTEST_DATA_DIR}
72 mkdir -p ${FUNCTEST_RESULTS_DIR}/ODL
74 # Detect type of installer
75 # NOTE: this is tricky, since the IPs will have to be the same ALWAYS
78 # Create Openstack credentials file
79 ${REPOS_DIR}/releng/utils/fetch_os_creds.sh -d ${FUNCTEST_CONF_DIR}/openstack.creds \
80 -i ${INSTALLER_TYPE} -a ${INSTALLER_IP}
82 if [ $retval != 0 ]; then
83 echo "Cannot retrieve credentials file from installation. Check logs."
89 source ${FUNCTEST_CONF_DIR}/openstack.creds
92 # Prepare Functest Environment
93 echo "Functest: prepare Functest environment"
94 python ${FUNCTEST_REPO_DIR}/testcases/config_functest.py --debug ${FUNCTEST_REPO_DIR}/ start
96 if [ $retval != 0 ]; then
97 echo "Error when configuring Functest environment"
102 echo "Functest: run vPing"
103 python ${FUNCTEST_REPO_DIR}/testcases/vPing/CI/libraries/vPing.py --debug ${FUNCTEST_REPO_DIR}/ -r
106 echo "Functest: run ODL suite"
108 if [ $INSTALLER_TYPE == "fuel" ]; then
109 odl_ip=$(keystone catalog --service network | grep publicURL | cut -f3 -d"/" | cut -f1 -d":")
110 neutron_ip=$(keystone catalog --service identity | grep publicURL | cut -f3 -d"/" | cut -f1 -d":")
111 usr_name=$(env | grep OS | grep OS_USERNAME | cut -f2 -d'=')
112 pass=$(env | grep OS | grep OS_PASSWORD | cut -f2 -d'=')
114 ODL_PORT=$odl_port ODL_IP=$odl_ip NEUTRON_IP=$neutron_ip USR_NAME=$usr_name PASS=$pass \
115 ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/start_tests.sh
116 elif [ $INSTALLER_TYPE == "foreman" ]; then
118 ${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/start_tests.sh
120 echo "INSTALLER_TYPE not valid."
125 echo "Functest: run Functest Rally Bench suites"
126 python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/run_rally.py --debug ${FUNCTEST_REPO_DIR}/ all
129 echo "Functest: run Tempest suite"
130 rally verify start smoke
134 echo "Functest: copy results and clean Functest environment"
137 odl_logs="${FUNCTEST_REPO_DIR}/testcases/Controllers/ODL/CI/logs"
138 if [ -d ${tempest_conf} ]; then
139 cp -Rf ${odl_logs} ${FUNCTEST_CONF_DIR}/ODL/
142 # save tempest.conf for further troubleshooting
143 tempest_conf="${RALLY_VENV}/tempest/for-deployment-*/tempest.conf"
144 if [ -f ${tempest_conf} ]; then
145 cp $tempest_conf ${FUNCTEST_CONF_DIR}