Monitoring plugin framework for OpenStack clouds
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

run_tests.sh 3.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/usr/bin/env bash
  2. # Copyright 2015, Rackspace US, Inc.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # PURPOSE:
  16. # This script clones the openstack-ansible-tests repository to the
  17. # tests/common folder in order to be able to re-use test components
  18. # for role testing. This is intended to be the thinnest possible
  19. # shim for test execution outside of OpenStack CI.
  20. # WARNING:
  21. # This file is maintained in the openstack-ansible-tests repository.
  22. # https://git.openstack.org/cgit/openstack/openstack-ansible-tests/tree/run_tests.sh
  23. # If you need to modify this file, update the one in the openstack-ansible-tests
  24. # repository and then update this file as well. The purpose of this file is to
  25. # prepare the host and then execute all the tox tests.
  26. #
  27. ## Shell Opts ----------------------------------------------------------------
  28. set -xeu
  29. ## Vars ----------------------------------------------------------------------
  30. WORKING_DIR="$(readlink -f $(dirname $0))"
  31. OSA_PROJECT_NAME="$(sed -n 's|^project=openstack/\(.*\).git$|\1|p' $(pwd)/.gitreview)"
  32. COMMON_TESTS_PATH="${WORKING_DIR}/tests/common"
  33. TESTING_HOME=${TESTING_HOME:-$HOME}
  34. ZUUL_TESTS_CLONE_LOCATION="/home/zuul/src/git.openstack.org/openstack/openstack-ansible-tests"
  35. # Use .gitreview as the key to determine the appropriate
  36. # branch to clone for tests.
  37. TESTING_BRANCH=$(awk -F'=' '/defaultbranch/ {print $2}' "${WORKING_DIR}/.gitreview")
  38. if [[ "${TESTING_BRANCH}" == "" ]]; then
  39. TESTING_BRANCH="master"
  40. fi
  41. ## Main ----------------------------------------------------------------------
  42. # Source distribution information
  43. source /etc/os-release || source /usr/lib/os-release
  44. # Prefer dnf over yum for CentOS.
  45. which dnf &>/dev/null && RHT_PKG_MGR='dnf' || RHT_PKG_MGR='yum'
  46. # Figure out the appropriate package install command
  47. case ${ID,,} in
  48. *suse*) pkg_mgr_cmd="zypper -n in" ;;
  49. centos|rhel|fedora) pkg_mgr_cmd="${RHT_PKG_MGR} install -y" ;;
  50. ubuntu|debian) pkg_mgr_cmd="apt-get install -y" ;;
  51. gentoo) pkg_mgr_cmd="emerge" ;;
  52. *) echo "unsupported distribution: ${ID,,}"; exit 1 ;;
  53. esac
  54. # Install git so that we can clone the tests repo if git is not available
  55. which git &>/dev/null || eval sudo "${pkg_mgr_cmd}" git
  56. # Clone the tests repo for access to the common test script
  57. if [[ ! -d "${COMMON_TESTS_PATH}" ]]; then
  58. # The tests repo doesn't need a clone, we can just
  59. # symlink it.
  60. if [[ "${OSA_PROJECT_NAME}" == "openstack-ansible-tests" ]]; then
  61. ln -s "${WORKING_DIR}" "${COMMON_TESTS_PATH}"
  62. # In zuul v3 any dependent repository is placed into
  63. # /home/zuul/src/git.openstack.org, so we check to see
  64. # if there is a tests checkout there already. If so, we
  65. # symlink that and use it.
  66. elif [[ -d "${ZUUL_TESTS_CLONE_LOCATION}" ]]; then
  67. ln -s "${ZUUL_TESTS_CLONE_LOCATION}" "${COMMON_TESTS_PATH}"
  68. # Otherwise we're clearly not in zuul or using a previously setup
  69. # repo in some way, so just clone it from upstream.
  70. else
  71. git clone -b "${TESTING_BRANCH}" \
  72. https://git.openstack.org/openstack/openstack-ansible-tests \
  73. "${COMMON_TESTS_PATH}"
  74. fi
  75. fi
  76. # Execute the common test script
  77. source tests/common/run_tests_common.sh