Ansible playbooks for deploying OpenStack.
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.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. COMMON_TESTS_PATH="${WORKING_DIR}/tests/common"
  32. TESTING_HOME=${TESTING_HOME:-$HOME}
  33. ZUUL_TESTS_CLONE_LOCATION="/home/zuul/src/git.openstack.org/openstack/openstack-ansible-tests"
  34. # Use .gitreview as the key to determine the appropriate
  35. # branch to clone for tests.
  36. TESTING_BRANCH=$(awk -F'=' '/defaultbranch/ {print $2}' "${WORKING_DIR}/.gitreview")
  37. if [[ "${TESTING_BRANCH}" == "" ]]; then
  38. TESTING_BRANCH="master"
  39. fi
  40. ## Main ----------------------------------------------------------------------
  41. # Source distribution information
  42. source /etc/os-release || source /usr/lib/os-release
  43. # Prefer dnf over yum for CentOS.
  44. which dnf &>/dev/null && RHT_PKG_MGR='dnf' || RHT_PKG_MGR='yum'
  45. # Figure out the appropriate package install command
  46. case ${ID,,} in
  47. *suse*) pkg_mgr_cmd="zypper -n in" ;;
  48. centos|rhel|fedora) pkg_mgr_cmd="${RHT_PKG_MGR} install -y" ;;
  49. ubuntu|debian) pkg_mgr_cmd="apt-get install -y" ;;
  50. *) echo "unsupported distribution: ${ID,,}"; exit 1 ;;
  51. esac
  52. # Install git so that we can clone the tests repo
  53. eval sudo $pkg_mgr_cmd git
  54. # Clone the tests repo for access to the common test script
  55. if [[ ! -d ${COMMON_TESTS_PATH} ]]; then
  56. # The tests repo doesn't need a clone, we can just
  57. # symlink it.
  58. if [[ "$(basename ${WORKING_DIR})" == "openstack-ansible-tests" ]]; then
  59. ln -s ${WORKING_DIR} ${COMMON_TESTS_PATH}
  60. # In zuul v3 any dependent repository is placed into
  61. # /home/zuul/src/git.openstack.org, so we check to see
  62. # if there is a tests checkout there already. If so, we
  63. # symlink that and use it.
  64. elif [[ -d "${ZUUL_TESTS_CLONE_LOCATION}" ]]; then
  65. ln -s "${ZUUL_TESTS_CLONE_LOCATION}" ${COMMON_TESTS_PATH}
  66. # Otherwise we're clearly not in zuul or using a previously setup
  67. # repo in some way, so just clone it from upstream.
  68. else
  69. git clone -b ${TESTING_BRANCH} \
  70. https://git.openstack.org/openstack/openstack-ansible-tests \
  71. ${COMMON_TESTS_PATH}
  72. fi
  73. fi
  74. # Execute the common test script
  75. source tests/common/run_tests_common.sh