Move VM image build to remote DUT
[yardstick.git] / docker / exec_tests.sh
1 #!/bin/bash
2 ##############################################################################
3 # Copyright (c) 2015 Ericsson AB and others.
4 #
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
10
11 set -e
12
13 : ${YARDSTICK_REPO:='https://gerrit.opnfv.org/gerrit/yardstick'}
14 : ${YARDSTICK_REPO_DIR:='/home/opnfv/repos/yardstick'}
15 : ${YARDSTICK_BRANCH:='master'} # branch, tag, sha1 or refspec
16
17 # git update using reference as a branch.
18 # git_update_branch ref
19 function git_update_branch {
20     local git_branch=$1
21
22     git checkout -f origin/${git_branch}
23     # a local branch might not exist
24     git branch -D ${git_branch} || true
25     git checkout -b ${git_branch}
26 }
27
28 # git update using reference as a branch.
29 # git_update_remote_branch ref
30 function git_update_remote_branch {
31     local git_branch=$1
32
33     git checkout -b ${git_branch} -t origin/${git_branch}
34 }
35
36 # git update using reference as a tag. Be careful editing source at that repo
37 # as working copy will be in a detached mode
38 # git_update_tag ref
39 function git_update_tag {
40     local git_tag=$1
41
42     git tag -d ${git_tag}
43     # fetching given tag only
44     git fetch origin tag ${git_tag}
45     git checkout -f ${git_tag}
46 }
47
48
49 # OpenStack Functions
50
51 git_checkout()
52 {
53     local git_ref=$1
54     if [[ -n "$(git show-ref refs/tags/${git_ref})" ]]; then
55         git_update_tag "${git_ref}"
56     elif [[ -n "$(git show-ref refs/heads/${git_ref})" ]]; then
57         git_update_branch "${git_ref}"
58     elif [[ -n "$(git show-ref refs/remotes/origin/${git_ref})" ]]; then
59         git_update_remote_branch "${git_ref}"
60     # check to see if it is a remote ref
61     elif git fetch --tags origin "${git_ref}"; then
62         # refspec / changeset
63         git checkout FETCH_HEAD
64     else
65         # if we are a random commit id we have to unshallow
66         # to get all the commits
67         git fetch --unshallow origin
68         git checkout -f "${git_ref}"
69     fi
70 }
71
72 # releng is not needed, we bind-mount the credentials
73
74 echo
75 echo "INFO: Updating yardstick -> ${YARDSTICK_BRANCH}"
76 if [ ! -d ${YARDSTICK_REPO_DIR} ]; then
77     git clone ${YARDSTICK_REPO} ${YARDSTICK_REPO_DIR}
78 fi
79 cd ${YARDSTICK_REPO_DIR}
80 git_checkout ${YARDSTICK_BRANCH}
81
82 if [[ "${DEPLOY_SCENARIO:0:2}" == "os" ]];then
83     # setup the environment
84     source ${YARDSTICK_REPO_DIR}/tests/ci/prepare_env.sh
85 fi
86
87 # execute tests
88 ${YARDSTICK_REPO_DIR}/tests/ci/yardstick-verify $@