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 prepare the Functest environment.
13 bash $(basename "$0") [--offline] [-h|--help] [-t <test_name>]
16 -o|--offline optional offline mode (experimental)
17 -h|--help show this help text
21 $(basename "$0") --offline"
39 error "unknown option $1"
43 shift # past argument or value
47 source ${BASEDIR}/common.sh
49 # Support for Functest offline
50 # NOTE: Still not 100% working when running the tests
52 info "######### Preparing Functest environment #########"
53 if [ $offline == false ]; then
60 # Check if environment variables are set
61 info "Checking environment variables INSTALLER_TYPE and INSTALLER_IP"
62 if [ -z ${INSTALLER_TYPE} ]; then
63 error "Environment variable 'INSTALLER_TYPE' is not defined."
64 elif [ "${INSTALLER_TYPE}" != "fuel" ] && [ "${INSTALLER_TYPE}" != "foreman" ]; then
65 error "Invalid environment variable INSTALLER_TYPE=${INSTALLER_TYPE}"
67 info "INSTALLER_TYPE env variable found: ${INSTALLER_TYPE}"
69 if [ -z ${INSTALLER_IP} ]; then
70 error "Environment variable 'INSTALLER_IP' is not defined."
72 info "INSTALLER_IP env variable found: ${INSTALLER_IP}"
75 if [ $offline == false ]; then
77 info "Updating Functest repository...."
78 cd ${FUNCTEST_REPO_DIR}
79 if [ ${FUNCTEST_BRANCH} != "master" ]; then
80 info "Functest repo: checkout ${FUNCTEST_BRANCH} branch..."
81 git checkout ${FUNCTEST_BRANCH}
83 info "Functest repo: pulling to latest..."
85 if [ ${FUNCTEST_COMMIT} != "latest" ]; then
86 info "Functest repo: given commit is ${FUNCTEST_COMMIT}. Reseting..."
87 git reset --hard ${FUNCTEST_COMMIT}
90 info "Updating Releng repository...."
92 if [ ${RELENG_BRANCH} != "master" ]; then
93 info "Releng repo: checkout ${RELENG_BRANCH} branch..."
94 git checkout ${RELENG_BRANCH}
96 info "Releng repo: pulling to latest..."
98 if [ ${RELENG_COMMIT} != "latest" ]; then
99 info "Releng repo: given commit is ${RELENG_COMMIT}. Reseting..."
100 git reset --hard ${RELENG_COMMIT}
103 info "Updating Rally repository...."
105 info "Rally repo: pulling to latest..."
109 # We do this regardless if its online or offline mode.
110 if [ ${RALLY_COMMIT} != "latest" ]; then
111 info "Rally repo: given commit is ${RALLY_COMMIT}. Reseting..."
112 git reset --hard ${RALLY_COMMIT}
117 mkdir -p ${FUNCTEST_CONF_DIR}
118 mkdir -p ${FUNCTEST_DATA_DIR}
119 mkdir -p ${FUNCTEST_RESULTS_DIR}/ODL
123 # Create Openstack credentials file
124 ${REPOS_DIR}/releng/utils/fetch_os_creds.sh -d ${FUNCTEST_CONF_DIR}/openstack.creds \
125 -i ${INSTALLER_TYPE} -a ${INSTALLER_IP}
127 if [ $retval != 0 ]; then
128 error "Cannot retrieve credentials file from installation. Check logs."
134 source ${FUNCTEST_CONF_DIR}/openstack.creds
137 # Prepare Functest Environment
138 info "Functest: prepare Functest environment"
139 python ${FUNCTEST_REPO_DIR}/testcases/config_functest.py --debug ${FUNCTEST_REPO_DIR}/ start
141 if [ $retval != 0 ]; then
142 error "Error when configuring Functest environment"
146 echo "1" > ${FUNCTEST_CONF_DIR}/env_active