blob: b1aa71738e3f3e581b71b8ba97597b2558f028b6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
#!/bin/bash
#
# Author: Jose Lausuch (jose.lausuch@ericsson.com)
#
# Installs the Functest framework within the Docker container
# and run the tests automatically
#
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
#
usage="Script to prepare the Functest environment.
usage:
bash $(basename "$0") [-h|--help] [-t <test_name>]
where:
-h|--help show this help text
examples:
$(basename "$0")"
# Parse parameters
while [[ $# > 0 ]]
do
key="$1"
case $key in
-h|--help)
echo "$usage"
exit 0
shift
;;
*)
error "unknown option $1"
exit 1
;;
esac
shift # past argument or value
done
BASEDIR=`dirname $0`
source ${BASEDIR}/common.sh
info "######### Preparing Functest environment #########"
# definition of available installer names
INSTALLERS=(fuel compass apex joid)
if [ ! -f ${FUNCTEST_CONF_DIR}/openstack.creds ]; then
# If credentials file is not given, check if environment variables are set
# to get the creds using fetch_os_creds.sh later on
info "Checking environment variables INSTALLER_TYPE and INSTALLER_IP"
if [ -z ${INSTALLER_TYPE} ]; then
error "Environment variable 'INSTALLER_TYPE' is not defined."
elif [[ ${INSTALLERS[@]} =~ ${INSTALLER_TYPE} ]]; then
info "INSTALLER_TYPE env variable found: ${INSTALLER_TYPE}"
else
error "Invalid environment variable INSTALLER_TYPE=${INSTALLER_TYPE}"
fi
if [ -z ${INSTALLER_IP} ]; then
error "Environment variable 'INSTALLER_IP' is not defined."
fi
info "INSTALLER_IP env variable found: ${INSTALLER_IP}"
fi
# Create directories
mkdir -p ${FUNCTEST_CONF_DIR}
mkdir -p ${FUNCTEST_DATA_DIR}
mkdir -p ${FUNCTEST_RESULTS_DIR}/ODL
# Create Openstack credentials file
# $creds is an env varialbe in the docker container pointing to
# /home/opnfv/functest/conf/openstack.creds
if [ ! -f ${creds} ]; then
${REPOS_DIR}/releng/utils/fetch_os_creds.sh -d ${creds} \
-i ${INSTALLER_TYPE} -a ${INSTALLER_IP}
retval=$?
if [ $retval != 0 ]; then
error "Cannot retrieve credentials file from installation. Check logs."
exit $retval
fi
else
info "OpenStack credentials file given to the docker and stored in ${FUNCTEST_CONF_DIR}/openstack.creds."
fi
# If we use SSL, by default use option OS_INSECURE=true which means that
# the cacert will be self-signed
if grep -Fq "OS_CACERT" ${creds}; then
echo "OS_INSECURE=true">>${creds};
fi
# Source credentials
source ${creds}
# Check OpenStack
info "Checking that the basic OpenStack services are functional..."
${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/check_os.sh
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
exit 1
fi
# Prepare Functest Environment
info "Preparing Functest environment..."
python ${FUNCTEST_REPO_DIR}/testcases/config_functest.py --debug start
retval=$?
if [ $retval != 0 ]; then
error "Error when configuring Functest environment"
exit $retval
fi
# Generate OpenStack defaults
info "Generating OpenStack defaults..."
python ${FUNCTEST_REPO_DIR}/testcases/VIM/OpenStack/CI/libraries/generate_defaults.py -d
ifconfig eth0 mtu 1450
echo "1" > ${FUNCTEST_CONF_DIR}/env_active
|