Role openstack_openrc for OpenStack-Ansible
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.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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://opendev.org/openstack/openstack-ansible-tests/src/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/opendev.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 needs to have version set since it's rolling
  52. gentoo) pkg_mgr_cmd="emerge --jobs=4"; VERSION="rolling" ;;
  53. *) echo "unsupported distribution: ${ID,,}"; exit 1 ;;
  54. esac
  55. # Install git so that we can clone the tests repo if git is not available
  56. which git &>/dev/null || eval sudo "${pkg_mgr_cmd}" git
  57. # Clone the tests repo for access to the common test script
  58. if [[ ! -d "${COMMON_TESTS_PATH}" ]]; then
  59. # The tests repo doesn't need a clone, we can just
  60. # symlink it.
  61. if [[ "${OSA_PROJECT_NAME}" == "openstack-ansible-tests" ]]; then
  62. ln -s "${WORKING_DIR}" "${COMMON_TESTS_PATH}"
  63. # In zuul v3 any dependent repository is placed into
  64. # /home/zuul/src/opendev.org, so we check to see
  65. # if there is a tests checkout there already. If so, we
  66. # symlink that and use it.
  67. elif [[ -d "${ZUUL_TESTS_CLONE_LOCATION}" ]]; then
  68. ln -s "${ZUUL_TESTS_CLONE_LOCATION}" "${COMMON_TESTS_PATH}"
  69. # Otherwise we're clearly not in zuul or using a previously setup
  70. # repo in some way, so just clone it from upstream.
  71. else
  72. git clone -b "${TESTING_BRANCH}" \
  73. https://opendev.org/openstack/openstack-ansible-tests \
  74. "${COMMON_TESTS_PATH}"
  75. fi
  76. fi
  77. # Execute the common test script
  78. source tests/common/run_tests_common.sh