Browse Source

Updated from OpenStack Ansible Tests

Change-Id: I5e3dd7efc31f4f7ed5366e7a9ebeecaa40aa458c
OpenStack Proposal Bot 1 year ago
parent
commit
1d929cb35a
2 changed files with 53 additions and 19 deletions
  1. 1
    0
      .gitignore
  2. 52
    19
      run_tests.sh

+ 1
- 0
.gitignore View File

@@ -69,3 +69,4 @@ tests/*.retry
69 69
 
70 70
 # Git clones
71 71
 openstack-ansible-ops
72
+previous

+ 52
- 19
run_tests.sh View File

@@ -12,8 +12,14 @@
12 12
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 13
 # See the License for the specific language governing permissions and
14 14
 # limitations under the License.
15
-#
16
-# Note:
15
+
16
+# PURPOSE:
17
+# This script clones the openstack-ansible-tests repository to the
18
+# tests/common folder in order to be able to re-use test components
19
+# for role testing. This is intended to be the thinnest possible
20
+# shim for test execution outside of OpenStack CI.
21
+
22
+# WARNING:
17 23
 # This file is maintained in the openstack-ansible-tests repository.
18 24
 # https://git.openstack.org/cgit/openstack/openstack-ansible-tests/tree/run_tests.sh
19 25
 # If you need to modify this file, update the one in the openstack-ansible-tests
@@ -26,33 +32,60 @@ set -xeu
26 32
 
27 33
 ## Vars ----------------------------------------------------------------------
28 34
 
29
-export WORKING_DIR=${WORKING_DIR:-$(pwd)}
35
+WORKING_DIR="$(readlink -f $(dirname $0))"
36
+
37
+COMMON_TESTS_PATH="${WORKING_DIR}/tests/common"
38
+TESTING_HOME=${TESTING_HOME:-$HOME}
39
+ZUUL_TESTS_CLONE_LOCATION="/home/zuul/src/git.openstack.org/openstack/openstack-ansible-tests"
40
+
41
+# Use .gitreview as the key to determine the appropriate
42
+# branch to clone for tests.
43
+TESTING_BRANCH=$(awk -F'=' '/defaultbranch/ {print $2}' "${WORKING_DIR}/.gitreview")
44
+if [[ "${TESTING_BRANCH}" == "" ]]; then
45
+  TESTING_BRANCH="master"
46
+fi
30 47
 
31 48
 ## Main ----------------------------------------------------------------------
32 49
 
50
+# Source distribution information
33 51
 source /etc/os-release || source /usr/lib/os-release
34 52
 
35
-install_pkg_deps() {
36
-    pkg_deps="git"
53
+# Prefer dnf over yum for CentOS.
54
+which dnf &>/dev/null && RHT_PKG_MGR='dnf' || RHT_PKG_MGR='yum'
37 55
 
38
-    # Prefer dnf over yum for CentOS.
39
-    which dnf &>/dev/null && RHT_PKG_MGR='dnf' || RHT_PKG_MGR='yum'
56
+# Figure out the appropriate package install command
57
+case ${ID,,} in
58
+    *suse*) pkg_mgr_cmd="zypper -n in" ;;
59
+    centos|rhel|fedora) pkg_mgr_cmd="${RHT_PKG_MGR} install -y" ;;
60
+    ubuntu|debian) pkg_mgr_cmd="apt-get install -y" ;;
61
+    *) echo "unsupported distribution: ${ID,,}"; exit 1 ;;
62
+esac
40 63
 
41
-    case ${ID,,} in
42
-        *suse*) pkg_mgr_cmd="zypper -n in" ;;
43
-        centos|rhel|fedora) pkg_mgr_cmd="${RHT_PKG_MGR} install -y" ;;
44
-        ubuntu|debian) pkg_mgr_cmd="apt-get install -y" ;;
45
-        *) echo "unsupported distribution: ${ID,,}"; exit 1 ;;
46
-    esac
64
+# Install git so that we can clone the tests repo
65
+eval sudo $pkg_mgr_cmd git
47 66
 
48
-    eval sudo $pkg_mgr_cmd $pkg_deps
49
-}
67
+# Clone the tests repo for access to the common test script
68
+if [[ ! -d ${COMMON_TESTS_PATH} ]]; then
69
+    # The tests repo doesn't need a clone, we can just
70
+    # symlink it.
71
+    if [[ "$(basename ${WORKING_DIR})" == "openstack-ansible-tests" ]]; then
72
+        ln -s ${WORKING_DIR} ${COMMON_TESTS_PATH}
50 73
 
51
-# Install the host distro package dependencies
52
-install_pkg_deps
74
+    # In zuul v3 any dependent repository is placed into
75
+    # /home/zuul/src/git.openstack.org, so we check to see
76
+    # if there is a tests checkout there already. If so, we
77
+    # symlink that and use it.
78
+    elif [[ -d "${ZUUL_TESTS_CLONE_LOCATION}" ]]; then
79
+        ln -s "${ZUUL_TESTS_CLONE_LOCATION}" ${COMMON_TESTS_PATH}
53 80
 
54
-# Clone the tests repo for access to the common test script
55
-source tests/tests-repo-clone.sh
81
+    # Otherwise we're clearly not in zuul or using a previously setup
82
+    # repo in some way, so just clone it from upstream.
83
+    else
84
+        git clone -b ${TESTING_BRANCH} \
85
+            https://git.openstack.org/openstack/openstack-ansible-tests \
86
+            ${COMMON_TESTS_PATH}
87
+    fi
88
+fi
56 89
 
57 90
 # Execute the common test script
58 91
 source tests/common/run_tests_common.sh

Loading…
Cancel
Save