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 info "######### Preparing Functest environment #########"
52 # definition of available installer names
53 INSTALLERS=(fuel compass apex joid)
55 if [ ! -f ${FUNCTEST_CONF_DIR}/openstack.creds ]; then
56 # If credentials file is not given, check if environment variables are set
57 # to get the creds using fetch_os_creds.sh later on
58 info "Checking environment variables INSTALLER_TYPE and INSTALLER_IP"
59 if [ -z ${INSTALLER_TYPE} ]; then
60 error "Environment variable 'INSTALLER_TYPE' is not defined."
61 elif [[ ${INSTALLERS[@]} =~ ${INSTALLER_TYPE} ]]; then
62 info "INSTALLER_TYPE env variable found: ${INSTALLER_TYPE}"
64 error "Invalid environment variable INSTALLER_TYPE=${INSTALLER_TYPE}"
67 if [ -z ${INSTALLER_IP} ]; then
68 error "Environment variable 'INSTALLER_IP' is not defined."
70 info "INSTALLER_IP env variable found: ${INSTALLER_IP}"
75 mkdir -p ${FUNCTEST_CONF_DIR}
76 mkdir -p ${FUNCTEST_DATA_DIR}
77 mkdir -p ${FUNCTEST_RESULTS_DIR}/ODL
80 # Create Openstack credentials file
81 # $creds is an env varialbe in the docker container pointing to
82 # /home/opnfv/functest/conf/openstack.creds
83 if [ ! -f ${creds} ]; then
84 ${REPOS_DIR}/releng/utils/fetch_os_creds.sh -d ${creds} \
85 -i ${INSTALLER_TYPE} -a ${INSTALLER_IP}
87 if [ $retval != 0 ]; then
88 error "Cannot retrieve credentials file from installation. Check logs."
92 info "OpenStack credentials file given to the docker and stored in ${FUNCTEST_CONF_DIR}/openstack.creds."
95 # If we use SSL, by default use option OS_INSECURE=true which means that
96 # the cacert will be self-signed
97 if grep -Fq "OS_CACERT" ${creds}; then
98 echo "OS_INSECURE=true">>${creds};
105 info "Checking that the basic OpenStack services are functional..."
106 ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/check_os.sh
108 if [ $RETVAL -ne 0 ]; then
112 # Prepare Functest Environment
113 info "Preparing Functest environment..."
114 python ${FUNCTEST_REPO_DIR}/testcases/config_functest.py --debug start
116 if [ $retval != 0 ]; then
117 error "Error when configuring Functest environment"
122 # Generate OpenStack defaults
123 info "Generating OpenStack defaults..."
124 python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/generate_defaults.py -d
126 ifconfig eth0 mtu 1450
128 echo "1" > ${FUNCTEST_CONF_DIR}/env_active