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
59 # definition of available installer names
60 INSTALLERS=(fuel compass apex joid)
62 if [ ! -f ${FUNCTEST_CONF_DIR}/openstack.creds ]; then
63 # If credentials file is not given, check if environment variables are set
64 # to get the creds using fetch_os_creds.sh later on
65 info "Checking environment variables INSTALLER_TYPE and INSTALLER_IP"
66 if [ -z ${INSTALLER_TYPE} ]; then
67 error "Environment variable 'INSTALLER_TYPE' is not defined."
68 elif [[ ${INSTALLERS[@]} =~ ${INSTALLER_TYPE} ]]; then
69 info "INSTALLER_TYPE env variable found: ${INSTALLER_TYPE}"
71 error "Invalid environment variable INSTALLER_TYPE=${INSTALLER_TYPE}"
74 if [ -z ${INSTALLER_IP} ]; then
75 error "Environment variable 'INSTALLER_IP' is not defined."
77 info "INSTALLER_IP env variable found: ${INSTALLER_IP}"
81 if [ $offline == false ]; then
83 info "Updating Releng repository...."
85 if [ ${RELENG_BRANCH} != "master" ]; then
86 info "Releng repo: checkout ${RELENG_BRANCH} branch..."
87 git checkout ${RELENG_BRANCH}
89 info "Releng repo: pulling to latest..."
91 if [ ${RELENG_COMMIT} != "latest" ]; then
92 info "Releng repo: given commit is ${RELENG_COMMIT}. Reseting..."
93 git reset --hard ${RELENG_COMMIT}
96 info "Updating Rally repository...."
98 if [ ${RALLY_BRANCH} != "master" ]; then
99 info "Rally repo: checkout ${RALLY_BRANCH} branch..."
100 git checkout ${RALLY_BRANCH}
102 info "Rally repo: pulling to latest..."
104 # We leave the reset command for later.
106 info "Updating vIMS test repository...."
108 if [ ${VIMS_BRANCH} != "stable" ]; then
109 info "Releng repo: checkout ${VIMS_TEST_BRANCH} branch..."
110 git checkout ${VIMS_BRANCH}
112 info "vIMS test repo: pulling to latest..."
114 if [ ${VIMS_COMMIT} != "latest" ]; then
115 info "vIMS test repo: given commit is ${VIMS_TEST_COMMIT}. Reseting..."
116 git reset --hard ${VIMS_COMMIT}
119 info "Updating BGPVPN repository...."
120 cd ${BGPVPN_REPO_DIR}
121 if [ ${BGPVPN_BRANCH} != "master" ]; then
122 info "BGPVPN repo: checkout ${BGPVPN_BRANCH} branch..."
123 git checkout ${BGPVPN_BRANCH}
125 info "BGPVPN repo: pulling to latest..."
127 if [ ${BGPVPN_COMMIT} != "latest" ]; then
128 info "BGPVPN repo: given commit is ${BGPVPN_COMMIT}. Reseting..."
129 git reset --hard ${BGPVPN_COMMIT}
132 info "Updating ONOS repository...."
134 if [ ${ONOS_BRANCH} != "master" ]; then
135 info "ONOS repo: checkout ${ONOS} branch..."
136 git checkout ${ONOS_BRANCH}
138 info "ONOS repo: pulling to latest..."
140 if [ ${ONOS_COMMIT} != "latest" ]; then
141 info "ONOS repo: given commit is ${ONOS_COMMIT}. Reseting..."
142 git reset --hard ${ONOS_COMMIT}
145 info "Updating PROMISE repository...."
146 cd ${PROMISE_REPO_DIR}
147 if [ ${PROMISE_BRANCH} != "master" ]; then
148 info "PROMISE repo: checkout ${PROMISE} branch..."
149 git checkout ${PROMISE_BRANCH}
151 info "PROMISE repo: pulling to latest..."
153 if [ ${PROMISE_COMMIT} != "latest" ]; then
154 info "PROMISE repo: given commit is ${PROMISE_COMMIT}. Reseting..."
155 git reset --hard ${PROMISE_COMMIT}
160 # We do this regardless if its online or offline mode.
161 # Assumption: the docker image contains a newer rally repo than the given commit.
162 if [ ${RALLY_COMMIT} != "latest" ]; then
164 info "Rally repo: given commit is ${RALLY_COMMIT}. Reseting..."
165 git reset --hard ${RALLY_COMMIT}
170 mkdir -p ${FUNCTEST_CONF_DIR}
171 mkdir -p ${FUNCTEST_DATA_DIR}
172 mkdir -p ${FUNCTEST_RESULTS_DIR}/ODL
176 # Create Openstack credentials file
177 if [ ! -f ${FUNCTEST_CONF_DIR}/openstack.creds ]; then
178 ${REPOS_DIR}/releng/utils/fetch_os_creds.sh -d ${FUNCTEST_CONF_DIR}/openstack.creds \
179 -i ${INSTALLER_TYPE} -a ${INSTALLER_IP}
181 if [ $retval != 0 ]; then
182 error "Cannot retrieve credentials file from installation. Check logs."
186 info "OpenStack credentials file given to the docker and stored in ${FUNCTEST_CONF_DIR}/openstack.creds."
189 source ${FUNCTEST_CONF_DIR}/openstack.creds
192 info "Checking that the basic OpenStack services are functional..."
193 ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/check_os.sh
195 if [ $RETVAL -ne 0 ]; then
199 # Prepare Functest Environment
200 info "Functest: prepare Functest environment"
201 python ${FUNCTEST_REPO_DIR}/testcases/config_functest.py --debug start
203 if [ $retval != 0 ]; then
204 error "Error when configuring Functest environment"
208 ifconfig eth0 mtu 1450
210 echo "1" > ${FUNCTEST_CONF_DIR}/env_active