4 # Author: Jose Lausuch (jose.lausuch@ericsson.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 prepare the Functest environment.
19 bash $(basename "$0") [-h|--help] [-t <test_name>]
22 -h|--help show this help text
39 error "unknown option $1"
43 shift # past argument or value
47 source ${BASEDIR}/common.sh
50 if [[ "${CI_DEBUG,,}" == "true" ]];then
55 info "######### Preparing Functest environment #########"
57 # definition of available installer names
58 INSTALLERS=(fuel compass apex joid)
60 if [ ! -f ${FUNCTEST_CONF_DIR}/openstack.creds ]; then
61 # If credentials file is not given, check if environment variables are set
62 # to get the creds using fetch_os_creds.sh later on
63 info "Checking environment variables INSTALLER_TYPE and INSTALLER_IP"
64 if [ -z ${INSTALLER_TYPE} ]; then
65 error "Environment variable 'INSTALLER_TYPE' is not defined."
66 elif [[ ${INSTALLERS[@]} =~ ${INSTALLER_TYPE} ]]; then
67 info "INSTALLER_TYPE env variable found: ${INSTALLER_TYPE}"
69 error "Invalid environment variable INSTALLER_TYPE=${INSTALLER_TYPE}"
72 if [ -z ${INSTALLER_IP} ]; then
73 error "Environment variable 'INSTALLER_IP' is not defined."
75 info "INSTALLER_IP env variable found: ${INSTALLER_IP}"
80 mkdir -p ${FUNCTEST_CONF_DIR}
81 mkdir -p ${FUNCTEST_DATA_DIR}
82 mkdir -p ${FUNCTEST_RESULTS_DIR}/ODL
85 # Create Openstack credentials file
86 # $creds is an env varialbe in the docker container pointing to
87 # /home/opnfv/functest/conf/openstack.creds
88 if [ ! -f ${creds} ]; then
89 ${REPOS_DIR}/releng/utils/fetch_os_creds.sh -d ${creds} \
90 -i ${INSTALLER_TYPE} -a ${INSTALLER_IP}
92 if [ $retval != 0 ]; then
93 error "Cannot retrieve credentials file from installation. Check logs."
97 info "OpenStack credentials file given to the docker and stored in ${FUNCTEST_CONF_DIR}/openstack.creds."
100 # If we use SSL, by default use option OS_INSECURE=true which means that
101 # the cacert will be self-signed
102 if grep -Fq "OS_CACERT" ${creds}; then
103 echo "OS_INSECURE=true">>${creds};
110 info "Checking that the basic OpenStack services are functional..."
111 ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/check_os.sh
113 if [ $RETVAL -ne 0 ]; then
117 # Prepare Functest Environment
118 info "Preparing Functest environment..."
119 python ${FUNCTEST_REPO_DIR}/testcases/config_functest.py $debug start
121 if [ $retval != 0 ]; then
122 error "Error when configuring Functest environment"
127 # Generate OpenStack defaults
128 info "Generating OpenStack defaults..."
129 python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/generate_defaults.py -d
131 ifconfig eth0 mtu 1450
133 echo "1" > ${FUNCTEST_CONF_DIR}/env_active