4 # Author: Jose Lausuch (jose.lausuch@ericsson.com)
6 # Installs the Functest framework within the Docker container
7 # and run the tests automatically
11 source ${BASEDIR}/common.sh
13 # Support for Functest offline
14 # NOTE: Still not 100% working when running the tests
16 if [ ! -z "$1" ] && [ $1 == "--offline" ]; then
20 info "######### Preparing Functest environment #########"
21 if [ $offline == false ]; then
28 # Check if environment variables are set
29 info "Checking environment variables INSTALLER_TYPE and INSTALLER_IP"
30 if [ -z ${INSTALLER_TYPE} ]; then
31 error "Environment variable 'INSTALLER_TYPE' is not defined."
32 elif [ "${INSTALLER_TYPE}" != "fuel" ] && [ "${INSTALLER_TYPE}" != "foreman" ]; then
33 error "Invalid environment variable INSTALLER_TYPE=${INSTALLER_TYPE}"
35 info "INSTALLER_TYPE env variable found: ${INSTALLER_TYPE}"
37 if [ -z ${INSTALLER_IP} ]; then
38 error "Environment variable 'INSTALLER_IP' is not defined."
40 info "INSTALLER_IP env variable found: ${INSTALLER_IP}"
43 if [ $offline == false ]; then
45 info "Updating Functest repository...."
46 cd ${FUNCTEST_REPO_DIR}
47 if [ ${FUNCTEST_BRANCH} != "master" ]; then
48 info "Functest repo: checkout ${FUNCTEST_BRANCH} branch..."
49 git checkout ${FUNCTEST_BRANCH}
51 info "Functest repo: pulling to latest..."
53 if [ ${FUNCTEST_COMMIT} != "latest" ]; then
54 info "Functest repo: given commit is ${FUNCTEST_COMMIT}. Reseting..."
55 git reset --hard ${FUNCTEST_COMMIT}
58 info "Updating Releng repository...."
60 if [ ${RELENG_BRANCH} != "master" ]; then
61 info "Releng repo: checkout ${RELENG_BRANCH} branch..."
62 git checkout ${RELENG_BRANCH}
64 info "Releng repo: pulling to latest..."
66 if [ ${RELENG_COMMIT} != "latest" ]; then
67 info "Releng repo: given commit is ${RELENG_COMMIT}. Reseting..."
68 git reset --hard ${RELENG_COMMIT}
71 info "Updating Rally repository...."
73 info "Rally repo: pulling to latest..."
77 # We do this regardless if its online or offline mode.
78 if [ ${RALLY_COMMIT} != "latest" ]; then
79 info "Rally repo: given commit is ${RALLY_COMMIT}. Reseting..."
80 git reset --hard ${RALLY_COMMIT}
85 mkdir -p ${FUNCTEST_CONF_DIR}
86 mkdir -p ${FUNCTEST_DATA_DIR}
87 mkdir -p ${FUNCTEST_RESULTS_DIR}/ODL
89 # Detect type of installer
90 # NOTE: this is tricky, since the IPs will have to be the same ALWAYS
93 # Create Openstack credentials file
94 ${REPOS_DIR}/releng/utils/fetch_os_creds.sh -d ${FUNCTEST_CONF_DIR}/openstack.creds \
95 -i ${INSTALLER_TYPE} -a ${INSTALLER_IP}
97 if [ $retval != 0 ]; then
98 echo "Cannot retrieve credentials file from installation. Check logs."
104 source ${FUNCTEST_CONF_DIR}/openstack.creds
107 # Prepare Functest Environment
108 echo "Functest: prepare Functest environment"
109 python ${FUNCTEST_REPO_DIR}/testcases/config_functest.py --debug ${FUNCTEST_REPO_DIR}/ start
111 if [ $retval != 0 ]; then
112 echo "Error when configuring Functest environment"
116 echo "1" > ${FUNCTEST_CONF_DIR}/env_active