Merge "Updated vIMS result format"
[functest.git] / docker / common.sh
1 #!/bin/bash
2
3 #
4 # Author: Jose Lausuch (jose.lausuch@ericsson.com)
5 #
6 # Installs the Functest framework within the Docker container
7 # and run the tests automatically
8 #
9 # If config_functest.yaml is given by the docker run command,
10 # it must be run like this:
11 #
12 #   docker run -ti \
13 #      -e "INSTALLER_TYPE=<something>" \
14 #      -e "INSTALLER_IP=<ip>" \
15 #      -v $(pwd)/config_functest.yaml:/home/opnfv/functest/conf/config_functest.yaml \
16 #      opnfv/functest /bin/bash
17 #
18 # NOTE: $(pwd)/config_functest.yaml means that it will take the one in the
19 #       current directory.
20 #
21 # If it is not provided, take the existing one in the functest repo
22 #
23 config_file=/home/opnfv/functest/conf/config_functest.yaml
24 if [ ! -f ${config_file} ]; then
25     config_file=$(find / -name config_functest.yaml)
26 fi
27
28 # Parse config_functest.yaml file
29 # TODO: this is not the best way to parse a yaml file in bash...
30
31 # Directories
32 REPOS_DIR=$(cat $config_file | grep -w dir_repos | awk 'END {print $NF}')
33 FUNCTEST_REPO_DIR=$(cat $config_file | grep -w dir_repo_functest | awk 'END {print $NF}')
34 RALLY_REPO_DIR=$(cat $config_file | grep -w dir_repo_rally | awk 'END {print $NF}')
35 RELENG_REPO_DIR=$(cat $config_file | grep -w dir_repo_releng | awk 'END {print $NF}')
36 VIMS_REPO_DIR=$(cat $config_file | grep -w dir_repo_vims_test | awk 'END {print $NF}')
37
38 FUNCTEST_DIR=$(cat $config_file | grep -w dir_functest | awk 'END {print $NF}')
39 FUNCTEST_RESULTS_DIR=$(cat $config_file | grep -w dir_results | awk 'END {print $NF}')
40 FUNCTEST_CONF_DIR=$(cat $config_file | grep -w dir_functest_conf | awk 'END {print $NF}')
41 FUNCTEST_DATA_DIR=$(cat $config_file | grep -w dir_functest_data | awk 'END {print $NF}')
42 RALLY_VENV_DIR=$(cat $config_file | grep -w dir_rally_inst | awk 'END {print $NF}')
43
44 # Repos
45 RALLY_BRANCH=$(cat $config_file | grep -w rally_branch | awk 'END {print $NF}')
46 RALLY_COMMIT=$(cat $config_file | grep -w rally_commit | awk 'END {print $NF}')
47 FUNCTEST_BRANCH=$(cat $config_file | grep -w functest_branch | awk 'END {print $NF}')
48 FUNCTEST_COMMIT=$(cat $config_file | grep -w functest_commit | awk 'END {print $NF}')
49 RELENG_BRANCH=$(cat $config_file | grep -w releng_branch | awk 'END {print $NF}')
50 RELENG_COMMIT=$(cat $config_file | grep -w releng_commit | awk 'END {print $NF}')
51 VIMS_BRANCH=$(cat $config_file | grep -w vims_test_branch | awk 'END {print $NF}')
52 VIMS_COMMIT=$(cat $config_file | grep -w vims_test_commit | awk 'END {print $NF}')
53
54 echo "_____Parsed needed data from ${config_file}:"
55 echo "####### Directories #######"
56 echo "REPOS_DIR=${REPOS_DIR}"
57 echo "FUNCTEST_REPO_DIR=${FUNCTEST_REPO_DIR}"
58 echo "RALLY_REPO_DIR=${RALLY_REPO_DIR}"
59 echo "RELENG_REPO_DIR=${RELENG_REPO_DIR}"
60 echo "VIMS_REPO_DIR=${VIMS_REPO_DIR}"
61 echo "FUNCTEST_DIR=${FUNCTEST_DIR}"
62 echo "FUNCTEST_RESULTS_DIR=${FUNCTEST_RESULTS_DIR}"
63 echo "FUNCTEST_CONF_DIR=${FUNCTEST_CONF_DIR}"
64 echo "FUNCTEST_DATA_DIR=${FUNCTEST_DATA_DIR}"
65 echo "RALLY_VENV_DIR=${RALLY_VENV_DIR}"
66 echo "####### Repositories #######"
67 echo "FUNCTEST_BRANCH=${FUNCTEST_BRANCH}"
68 echo "FUNCTEST_COMMIT=${FUNCTEST_COMMIT}"
69 echo "RELENG_BRANCH=${RELENG_BRANCH}"
70 echo "RELENG_COMMIT=${RELENG_COMMIT}"
71 echo "RALLY_BRANCH=${RALLY_BRANCH}"
72 echo "RALLY_COMMIT=${RALLY_COMMIT}"
73 echo "VIMS_BRANCH=${VIMS_BRANCH}"
74 echo "VIMS_COMMIT=${VIMS_COMMIT}"
75 echo "############################"
76
77 info ()  {
78     logger -s -t "FUNCTEST.info" "$*"
79 }
80
81
82 error () {
83     logger -s -t "FUNCTEST.error" "$*"
84     exit 1
85 }