summaryrefslogtreecommitdiffstats
path: root/docker/common.sh
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2015-10-21 11:06:43 +0200
committerjose.lausuch <jose.lausuch@ericsson.com>2015-10-21 13:50:02 +0200
commit73c8f0a8ed1d6b18356d52a3ce6d3638c2c91ad3 (patch)
treec2249fc511c98b2463f2fa0ce1629dd20d24ad44 /docker/common.sh
parent62b213816e46d66125904be73bad2c3ebca09c3b (diff)
Refactor Functest docker container
1. start.sh has been splitted into 2 scripts: - prepare_env.sh : installs functest environment without running any test - run_tests.sh : run the Functest tests 2. Add possibility to give the config_functest.yaml in the docker run command. So far, it has always been used the default in the repo. 3. Possible to give the repos the branch and commit ID to be checkout/reset to. This allows versioning control for the repos 4. Added -x permissions to shell scripts JIRA: FUNCTEST-29 Change-Id: If4b779f5baa37531603955db3681e24a5e08251a Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'docker/common.sh')
-rwxr-xr-xdocker/common.sh79
1 files changed, 79 insertions, 0 deletions
diff --git a/docker/common.sh b/docker/common.sh
new file mode 100755
index 000000000..42b7d3e09
--- /dev/null
+++ b/docker/common.sh
@@ -0,0 +1,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
+}