aboutsummaryrefslogtreecommitdiffstats
path: root/docker/common.sh
blob: 42b7d3e096cc1b32443f621b519c75cdaf0e3e9f (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
#!/bin/bash

#
# Author: Jose Lausuch (jose.lausuch@ericsson.com)
#
# Installs the Functest framework within the Docker container
# and run the tests automatically
#
# If config_functest.yaml is given by the docker run command,
# it must be run like this:
#
#   docker run -ti \
#      -e "INSTALLER_TYPE=<something>" \
#      -e "INSTALLER_IP=<ip>" \
#      -v $(pwd)/config_functest.yaml:/home/opnfv/functest/conf/config_functest.yaml \
#      opnfv/functest /bin/bash
#
# NOTE: $(pwd)/config_functest.yaml means that it will take the one in the
#       current directory.
#
# If it is not provided, take the existing one in the functest repo
#
config_file=/home/opnfv/functest/conf/config_functest.yaml
if [ ! -f ${config_file} ]; then
    config_file=$(find / -name config_functest.yaml)
fi

# Parse config_functest.yaml file
# TODO: this is not the best way to parse a yaml file in bash...

# Directories
REPOS_DIR=$(cat $config_file | grep -w dir_repos | awk 'END {print $NF}')
FUNCTEST_REPO_DIR=$(cat $config_file | grep -w dir_repo_functest | awk 'END {print $NF}')
RALLY_REPO_DIR=$(cat $config_file | grep -w dir_repo_rally | awk 'END {print $NF}')
RELENG_REPO_DIR=$(cat $config_file | grep -w dir_repo_releng | awk 'END {print $NF}')

FUNCTEST_DIR=$(cat $config_file | grep -w dir_functest | awk 'END {print $NF}')
FUNCTEST_RESULTS_DIR=$(cat $config_file | grep -w dir_results | awk 'END {print $NF}')
FUNCTEST_CONF_DIR=$(cat $config_file | grep -w dir_functest_conf | awk 'END {print $NF}')
FUNCTEST_DATA_DIR=$(cat $config_file | grep -w dir_functest_data | awk 'END {print $NF}')
RALLY_VENV_DIR=$(cat $config_file | grep -w dir_rally_inst | awk 'END {print $NF}')

# Repos
RALLY_BRANCH=$(cat $config_file | grep -w rally_branch | awk 'END {print $NF}')
RALLY_COMMIT=$(cat $config_file | grep -w rally_commit | awk 'END {print $NF}')
FUNCTEST_BRANCH=$(cat $config_file | grep -w functest_branch | awk 'END {print $NF}')
FUNCTEST_COMMIT=$(cat $config_file | grep -w functest_commit | awk 'END {print $NF}')
RELENG_BRANCH=$(cat $config_file | grep -w releng_branch | awk 'END {print $NF}')
RELENG_COMMIT=$(cat $config_file | grep -w releng_commit | awk 'END {print $NF}')

echo "_____Parsed needed data from ${config_file}:"
echo "####### Directories #######"
echo "REPOS_DIR=${REPOS_DIR}"
echo "FUNCTEST_REPO_DIR=${FUNCTEST_REPO_DIR}"
echo "RALLY_REPO_DIR=${RALLY_REPO_DIR}"
echo "RELENG_REPO_DIR=${RELENG_REPO_DIR}"
echo "FUNCTEST_DIR=${FUNCTEST_DIR}"
echo "FUNCTEST_RESULTS_DIR=${FUNCTEST_RESULTS_DIR}"
echo "FUNCTEST_CONF_DIR=${FUNCTEST_CONF_DIR}"
echo "FUNCTEST_DATA_DIR=${FUNCTEST_DATA_DIR}"
echo "RALLY_VENV_DIR=${RALLY_VENV_DIR}"
echo "####### Repositories #######"
echo "FUNCTEST_BRANCH=${FUNCTEST_BRANCH}"
echo "FUNCTEST_COMMIT=${FUNCTEST_COMMIT}"
echo "RELENG_BRANCH=${RELENG_BRANCH}"
echo "RELENG_COMMIT=${RELENG_COMMIT}"
echo "RALLY_BRANCH=${RALLY_BRANCH}"
echo "RALLY_COMMIT=${RALLY_COMMIT}"
echo "############################"

info ()  {
    logger -s -t "FUNCTEST.info" "$*"
}


error () {
    logger -s -t "FUNCTEST.error" "$*"
    exit 1
}