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") [--offline] [-h|--help] [-t <test_name>]
22 -o|--offline optional offline mode (experimental)
23 -h|--help show this help text
27 $(basename "$0") --offline"
45 error "unknown option $1"
49 shift # past argument or value
53 source ${BASEDIR}/common.sh
55 # Support for Functest offline
56 # NOTE: Still not 100% working when running the tests
58 info "######### Preparing Functest environment #########"
59 if [ $offline == false ]; then
65 # definition of available installer names
66 INSTALLERS=(fuel compass apex joid)
68 if [ ! -f ${FUNCTEST_CONF_DIR}/openstack.creds ]; then
69 # If credentials file is not given, check if environment variables are set
70 # to get the creds using fetch_os_creds.sh later on
71 info "Checking environment variables INSTALLER_TYPE and INSTALLER_IP"
72 if [ -z ${INSTALLER_TYPE} ]; then
73 error "Environment variable 'INSTALLER_TYPE' is not defined."
74 elif [[ ${INSTALLERS[@]} =~ ${INSTALLER_TYPE} ]]; then
75 info "INSTALLER_TYPE env variable found: ${INSTALLER_TYPE}"
77 error "Invalid environment variable INSTALLER_TYPE=${INSTALLER_TYPE}"
80 if [ -z ${INSTALLER_IP} ]; then
81 error "Environment variable 'INSTALLER_IP' is not defined."
83 info "INSTALLER_IP env variable found: ${INSTALLER_IP}"
87 if [ $offline == false ]; then
89 info "Updating Releng repository...."
91 if [ ${RELENG_BRANCH} != "master" ]; then
92 info "Releng repo: checkout ${RELENG_BRANCH} branch..."
93 git checkout ${RELENG_BRANCH}
95 info "Releng repo: pulling to latest..."
97 if [ ${RELENG_COMMIT} != "latest" ]; then
98 info "Releng repo: given commit is ${RELENG_COMMIT}. Reseting..."
99 git reset --hard ${RELENG_COMMIT}
102 info "Updating Rally repository...."
104 if [ ${RALLY_BRANCH} != "master" ]; then
105 info "Rally repo: checkout ${RALLY_BRANCH} branch..."
106 git checkout ${RALLY_BRANCH}
108 info "Rally repo: pulling to latest..."
110 # We leave the reset command for later.
112 info "Updating vIMS test repository...."
114 if [ ${VIMS_BRANCH} != "stable" ]; then
115 info "Releng repo: checkout ${VIMS_TEST_BRANCH} branch..."
116 git checkout ${VIMS_BRANCH}
118 info "vIMS test repo: pulling to latest..."
120 if [ ${VIMS_COMMIT} != "latest" ]; then
121 info "vIMS test repo: given commit is ${VIMS_TEST_COMMIT}. Reseting..."
122 git reset --hard ${VIMS_COMMIT}
125 info "Updating BGPVPN repository...."
126 cd ${BGPVPN_REPO_DIR}
127 if [ ${BGPVPN_BRANCH} != "master" ]; then
128 info "BGPVPN repo: checkout ${BGPVPN_BRANCH} branch..."
129 git checkout ${BGPVPN_BRANCH}
131 info "BGPVPN repo: pulling to latest..."
133 if [ ${BGPVPN_COMMIT} != "latest" ]; then
134 info "BGPVPN repo: given commit is ${BGPVPN_COMMIT}. Reseting..."
135 git reset --hard ${BGPVPN_COMMIT}
138 info "Updating ONOS repository...."
140 if [ ${ONOS_BRANCH} != "master" ]; then
141 info "ONOS repo: checkout ${ONOS} branch..."
142 git checkout ${ONOS_BRANCH}
144 info "ONOS repo: pulling to latest..."
146 if [ ${ONOS_COMMIT} != "latest" ]; then
147 info "ONOS repo: given commit is ${ONOS_COMMIT}. Reseting..."
148 git reset --hard ${ONOS_COMMIT}
151 info "Updating PROMISE repository...."
152 cd ${PROMISE_REPO_DIR}
153 if [ ${PROMISE_BRANCH} != "master" ]; then
154 info "PROMISE repo: checkout ${PROMISE} branch..."
155 git checkout ${PROMISE_BRANCH}
157 info "PROMISE repo: pulling to latest..."
159 if [ ${PROMISE_COMMIT} != "latest" ]; then
160 info "PROMISE repo: given commit is ${PROMISE_COMMIT}. Reseting..."
161 git reset --hard ${PROMISE_COMMIT}
164 info "Updating OVNO repository...."
166 if [ ${OVNO_BRANCH} != "master" ]; then
167 info "OVNO repo: checkout ${OVNO} branch..."
168 git checkout ${OVNO_BRANCH}
170 info "OVNO repo: pulling to latest..."
172 if [ ${OVNO_COMMIT} != "latest" ]; then
173 info "OVNO repo: given commit is ${OVNO_COMMIT}. Reseting..."
174 git reset --hard ${OVNO_COMMIT}
179 # We do this regardless if its online or offline mode.
180 # Assumption: the docker image contains a newer rally repo than the given commit.
181 if [ ${RALLY_COMMIT} != "latest" ]; then
183 info "Rally repo: given commit is ${RALLY_COMMIT}. Reseting..."
184 git reset --hard ${RALLY_COMMIT}
189 mkdir -p ${FUNCTEST_CONF_DIR}
190 mkdir -p ${FUNCTEST_DATA_DIR}
191 mkdir -p ${FUNCTEST_RESULTS_DIR}/ODL
195 # Create Openstack credentials file
196 if [ ! -f ${FUNCTEST_CONF_DIR}/openstack.creds ]; then
197 ${REPOS_DIR}/releng/utils/fetch_os_creds.sh -d ${FUNCTEST_CONF_DIR}/openstack.creds \
198 -i ${INSTALLER_TYPE} -a ${INSTALLER_IP}
200 if [ $retval != 0 ]; then
201 error "Cannot retrieve credentials file from installation. Check logs."
205 info "OpenStack credentials file given to the docker and stored in ${FUNCTEST_CONF_DIR}/openstack.creds."
208 source ${FUNCTEST_CONF_DIR}/openstack.creds
211 info "Checking that the basic OpenStack services are functional..."
212 ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/check_os.sh
214 if [ $RETVAL -ne 0 ]; then
218 # Prepare Functest Environment
219 info "Functest: prepare Functest environment"
220 python ${FUNCTEST_REPO_DIR}/testcases/config_functest.py --debug start
222 if [ $retval != 0 ]; then
223 error "Error when configuring Functest environment"
227 ifconfig eth0 mtu 1450
229 echo "1" > ${FUNCTEST_CONF_DIR}/env_active