Merge "Fix dns problem on E/// pod"
[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 mkdir -p /home/opnfv/functest/conf
24 config_file=/home/opnfv/functest/conf/config_functest.yaml
25 if [ ! -f ${config_file} ]; then
26     default_config_file=$(find /home/opnfv/repos -name config_functest.yaml)
27     cp $default_config_file $config_file
28     echo "config_functest.yaml not provided. Using default one"
29 fi
30
31
32 # Parse config_functest.yaml file
33 # TODO: this is not the best way to parse a yaml file in bash...
34
35 # Directories
36 REPOS_DIR=$(cat $config_file | grep -w dir_repos | awk 'END {print $NF}')
37 FUNCTEST_REPO_DIR=$(cat $config_file | grep -w dir_repo_functest | awk 'END {print $NF}')
38 RALLY_REPO_DIR=$(cat $config_file | grep -w dir_repo_rally | awk 'END {print $NF}')
39 RELENG_REPO_DIR=$(cat $config_file | grep -w dir_repo_releng | awk 'END {print $NF}')
40 VIMS_REPO_DIR=$(cat $config_file | grep -w dir_repo_vims_test | awk 'END {print $NF}')
41 BGPVPN_REPO_DIR=$(cat $config_file | grep -w dir_repo_bgpvpn | awk 'END {print $NF}')
42
43 FUNCTEST_DIR=$(cat $config_file | grep -w dir_functest | awk 'END {print $NF}')
44 FUNCTEST_RESULTS_DIR=$(cat $config_file | grep -w dir_results | awk 'END {print $NF}')
45 FUNCTEST_CONF_DIR=$(cat $config_file | grep -w dir_functest_conf | awk 'END {print $NF}')
46 FUNCTEST_DATA_DIR=$(cat $config_file | grep -w dir_functest_data | awk 'END {print $NF}')
47 RALLY_VENV_DIR=$(cat $config_file | grep -w dir_rally_inst | awk 'END {print $NF}')
48
49 # Repos
50 RALLY_BRANCH=$(cat $config_file | grep -w rally_branch | awk 'END {print $NF}')
51 RALLY_COMMIT=$(cat $config_file | grep -w rally_commit | awk 'END {print $NF}')
52 FUNCTEST_BRANCH=$(cat $config_file | grep -w functest_branch | awk 'END {print $NF}')
53 FUNCTEST_COMMIT=$(cat $config_file | grep -w functest_commit | awk 'END {print $NF}')
54 RELENG_BRANCH=$(cat $config_file | grep -w releng_branch | awk 'END {print $NF}')
55 RELENG_COMMIT=$(cat $config_file | grep -w releng_commit | awk 'END {print $NF}')
56 VIMS_BRANCH=$(cat $config_file | grep -w vims_test_branch | awk 'END {print $NF}')
57 VIMS_COMMIT=$(cat $config_file | grep -w vims_test_commit | awk 'END {print $NF}')
58 BGPVPN_BRANCH=$(cat $config_file | grep -w bgpvpn_branch | awk 'END {print $NF}')
59 BGPVPN_COMMIT=$(cat $config_file | grep -w bgpvpn_commit | awk 'END {print $NF}')
60 ONOS_BRANCH=$(cat $config_file | grep -w onos_branch | awk 'END {print $NF}')
61 ONOS_COMMIT=$(cat $config_file | grep -w onos_commit | awk 'END {print $NF}')
62 PROMISE_BRANCH=$(cat $config_file | grep -w promise_branch | awk 'END {print $NF}')
63 PROMISE_COMMIT=$(cat $config_file | grep -w promise_commit | awk 'END {print $NF}')
64
65
66 echo "_____Parsed needed data from ${config_file}:"
67 echo "####### Directories #######"
68 echo "REPOS_DIR=${REPOS_DIR}"
69 echo "FUNCTEST_REPO_DIR=${FUNCTEST_REPO_DIR}"
70 echo "RALLY_REPO_DIR=${RALLY_REPO_DIR}"
71 echo "RELENG_REPO_DIR=${RELENG_REPO_DIR}"
72 echo "VIMS_REPO_DIR=${VIMS_REPO_DIR}"
73 echo "FUNCTEST_DIR=${FUNCTEST_DIR}"
74 echo "FUNCTEST_RESULTS_DIR=${FUNCTEST_RESULTS_DIR}"
75 echo "FUNCTEST_CONF_DIR=${FUNCTEST_CONF_DIR}"
76 echo "FUNCTEST_DATA_DIR=${FUNCTEST_DATA_DIR}"
77 echo "RALLY_VENV_DIR=${RALLY_VENV_DIR}"
78 echo "####### Repositories #######"
79 echo "FUNCTEST_BRANCH=${FUNCTEST_BRANCH}"
80 echo "FUNCTEST_COMMIT=${FUNCTEST_COMMIT}"
81 echo "RELENG_BRANCH=${RELENG_BRANCH}"
82 echo "RELENG_COMMIT=${RELENG_COMMIT}"
83 echo "RALLY_BRANCH=${RALLY_BRANCH}"
84 echo "RALLY_COMMIT=${RALLY_COMMIT}"
85 echo "VIMS_BRANCH=${VIMS_BRANCH}"
86 echo "VIMS_COMMIT=${VIMS_COMMIT}"
87 echo "ONOS_BRANCH=${ONOS_BRANCH}"
88 echo "ONOS_COMMIT=${ONOS_COMMIT}"
89 echo "PROMISE_BRANCH=${PROMISE_BRANCH}"
90 echo "PROMISE_COMMIT=${PROMISE_COMMIT}"
91 echo "############################"
92
93 info ()  {
94     logger -s -t "FUNCTEST.info" "$*"
95 }
96
97
98 error () {
99     logger -s -t "FUNCTEST.error" "$*"
100     exit 1
101 }