Merge "Add vPing troubleshooting guides"
[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
24 # this pull is to be removed right before the B release, once we build
25 # a release candidate docker
26 #
27 # All rights reserved. This program and the accompanying materials
28 # are made available under the terms of the Apache License, Version 2.0
29 # which accompanies this distribution, and is available at
30 # http://www.apache.org/licenses/LICENSE-2.0
31 #
32
33 mkdir -p /home/opnfv/functest/conf
34 config_file=/home/opnfv/functest/conf/config_functest.yaml
35 if [ ! -f ${config_file} ]; then
36     default_config_file=$(find /home/opnfv/repos -name config_functest.yaml)
37     cp $default_config_file $config_file
38     echo "config_functest.yaml not provided. Using default one"
39 fi
40
41
42 # Parse config_functest.yaml file
43 # TODO: this is not the best way to parse a yaml file in bash...
44
45 # Directories
46 REPOS_DIR=$(cat $config_file | grep -w dir_repos | awk 'END {print $NF}')
47 FUNCTEST_REPO_DIR=$(cat $config_file | grep -w dir_repo_functest | awk 'END {print $NF}')
48 RALLY_REPO_DIR=$(cat $config_file | grep -w dir_repo_rally | awk 'END {print $NF}')
49 RELENG_REPO_DIR=$(cat $config_file | grep -w dir_repo_releng | awk 'END {print $NF}')
50 VIMS_REPO_DIR=$(cat $config_file | grep -w dir_repo_vims_test | awk 'END {print $NF}')
51 BGPVPN_REPO_DIR=$(cat $config_file | grep -w dir_repo_bgpvpn | awk 'END {print $NF}')
52 ONOS_REPO_DIR=$(cat $config_file | grep -w dir_repo_onos | awk 'END {print $NF}')
53 PROMISE_REPO_DIR=$(cat $config_file | grep -w dir_repo_promise | awk 'END {print $NF}')
54 OVNO_REPO_DIR=$(cat $config_file | grep -w dir_repo_ovno | awk 'END {print $NF}')
55 DOCTOR_REPO_DIR=$(cat $config_file | grep -w dir_repo_doctor | awk 'END {print $NF}')
56
57
58 FUNCTEST_DIR=$(cat $config_file | grep -w dir_functest | awk 'END {print $NF}')
59 FUNCTEST_RESULTS_DIR=$(cat $config_file | grep -w dir_results | awk 'END {print $NF}')
60 FUNCTEST_CONF_DIR=$(cat $config_file | grep -w dir_functest_conf | awk 'END {print $NF}')
61 FUNCTEST_DATA_DIR=$(cat $config_file | grep -w dir_functest_data | awk 'END {print $NF}')
62 RALLY_VENV_DIR=$(cat $config_file | grep -w dir_rally_inst | awk 'END {print $NF}')
63
64 # Repos
65 RALLY_BRANCH=$(cat $config_file | grep -w rally_branch | awk 'END {print $NF}')
66 RALLY_COMMIT=$(cat $config_file | grep -w rally_commit | awk 'END {print $NF}')
67 RELENG_BRANCH=$(cat $config_file | grep -w releng_branch | awk 'END {print $NF}')
68 RELENG_COMMIT=$(cat $config_file | grep -w releng_commit | awk 'END {print $NF}')
69 VIMS_BRANCH=$(cat $config_file | grep -w vims_test_branch | awk 'END {print $NF}')
70 VIMS_COMMIT=$(cat $config_file | grep -w vims_test_commit | awk 'END {print $NF}')
71 BGPVPN_BRANCH=$(cat $config_file | grep -w bgpvpn_branch | awk 'END {print $NF}')
72 BGPVPN_COMMIT=$(cat $config_file | grep -w bgpvpn_commit | awk 'END {print $NF}')
73 ONOS_BRANCH=$(cat $config_file | grep -w onos_branch | awk 'END {print $NF}')
74 ONOS_COMMIT=$(cat $config_file | grep -w onos_commit | awk 'END {print $NF}')
75 PROMISE_BRANCH=$(cat $config_file | grep -w promise_branch | awk 'END {print $NF}')
76 PROMISE_COMMIT=$(cat $config_file | grep -w promise_commit | awk 'END {print $NF}')
77 OVNO_BRANCH=$(cat $config_file | grep -w ovno_branch | awk 'END {print $NF}')
78 OVNO_COMMIT=$(cat $config_file | grep -w ovno_commit | awk 'END {print $NF}')
79 DOCTOR_BRANCH=$(cat $config_file | grep -w doctor_branch | awk 'END {print $NF}')
80 DOCTOR_COMMIT=$(cat $config_file | grep -w doctor_commit | awk 'END {print $NF}')
81
82 echo "_____Parsed needed data from ${config_file}:"
83 echo "####### Directories #######"
84 echo "REPOS_DIR=${REPOS_DIR}"
85 echo "FUNCTEST_REPO_DIR=${FUNCTEST_REPO_DIR}"
86 echo "RALLY_REPO_DIR=${RALLY_REPO_DIR}"
87 echo "RELENG_REPO_DIR=${RELENG_REPO_DIR}"
88 echo "VIMS_REPO_DIR=${VIMS_REPO_DIR}"
89 echo "FUNCTEST_DIR=${FUNCTEST_DIR}"
90 echo "FUNCTEST_RESULTS_DIR=${FUNCTEST_RESULTS_DIR}"
91 echo "FUNCTEST_CONF_DIR=${FUNCTEST_CONF_DIR}"
92 echo "FUNCTEST_DATA_DIR=${FUNCTEST_DATA_DIR}"
93 echo "RALLY_VENV_DIR=${RALLY_VENV_DIR}"
94 echo "####### Repositories #######"
95 echo "RELENG_BRANCH=${RELENG_BRANCH}"
96 echo "RELENG_COMMIT=${RELENG_COMMIT}"
97 echo "RALLY_BRANCH=${RALLY_BRANCH}"
98 echo "RALLY_COMMIT=${RALLY_COMMIT}"
99 echo "VIMS_BRANCH=${VIMS_BRANCH}"
100 echo "VIMS_COMMIT=${VIMS_COMMIT}"
101 echo "ONOS_BRANCH=${ONOS_BRANCH}"
102 echo "ONOS_COMMIT=${ONOS_COMMIT}"
103 echo "PROMISE_BRANCH=${PROMISE_BRANCH}"
104 echo "PROMISE_COMMIT=${PROMISE_COMMIT}"
105 echo "OVNO_BRANCH=${OVNO_BRANCH}"
106 echo "OVNO_COMMIT=${OVNO_COMMIT}"
107 echo "DOCTOR_BRANCH=${DOCTOR_BRANCH}"
108 echo "DOCTOR_COMMIT=${DOCTOR_COMMIT}"
109 echo "############################"
110
111 info ()  {
112     logger -s -t "FUNCTEST.info" "$*"
113 }
114
115
116 error () {
117     logger -s -t "FUNCTEST.error" "$*"
118     exit 1
119 }