
This patch adds the support for running the molecule tests on Fedora through the molecule command. This patch also updates the README file to point out the developer to the molecule testing procedure hosted in tripleo-validations. Change-Id: Ia5ba005874a5cff3bdd94338f31a424f626e22e3 Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
90 lines
3.2 KiB
Bash
Executable File
90 lines
3.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Copyright 2019 Red Hat, Inc.
|
|
# All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
|
|
## Functions -----------------------------------------------------------------
|
|
function usage {
|
|
echo "Usage: ROLE_NAME=ROLE_NAME ${0##*/} or ${0##*/} ROLE_NAME"
|
|
}
|
|
|
|
## Vars ----------------------------------------------------------------------
|
|
|
|
export PROJECT_DIR="$(dirname $(readlink -f ${BASH_SOURCE[0]}))/../"
|
|
if [ "${ROLE_NAME}x" = "x" -a "${1}x" = "x" ]; then
|
|
usage;
|
|
exit 2
|
|
fi
|
|
export ROLE_NAME="${ROLE_NAME:-$1}"
|
|
export TRIPLEO_JOB_ANSIBLE_ARGS=${TRIPLEO_JOB_ANSIBLE_ARGS:-""}
|
|
|
|
## Shell Opts ----------------------------------------------------------------
|
|
|
|
set -o pipefail
|
|
set -xeuo
|
|
|
|
## Main ----------------------------------------------------------------------
|
|
|
|
# Source distribution information
|
|
source /etc/os-release || source /usr/lib/os-release
|
|
RHT_PKG_MGR=$(command -v dnf || command -v yum)
|
|
|
|
# Install the one requirement we need to run any local test
|
|
case "${ID,,}" in
|
|
amzn|rhel|centos|fedora)
|
|
sudo "${RHT_PKG_MGR}" install -y python3 python*-virtualenv
|
|
;;
|
|
esac
|
|
|
|
# Ensure the required ci file is present
|
|
sudo mkdir -p /etc/ci
|
|
sudo touch /etc/ci/mirror_info.sh
|
|
|
|
# Get Python Executable
|
|
PYTHON_EXEC=$(command -v python3 || command -v python)
|
|
|
|
# Create a virtual env
|
|
"${PYTHON_EXEC}" -m virtualenv --system-site-packages "${HOME}/test-python"
|
|
|
|
# Activate a virtual env
|
|
PS1="[\u@\h \W]\$" source "${HOME}/test-python/bin/activate"
|
|
|
|
# Run bindep
|
|
"${HOME}/test-python/bin/pip" install "pip>=19.1.1" setuptools bindep --upgrade
|
|
"${PROJECT_DIR}/scripts/bindep-install"
|
|
|
|
# Install local requirements
|
|
if [[ -d "${HOME}/.cache/pip/wheels" ]]; then
|
|
rm -rf "${HOME}/.cache/pip/wheels"
|
|
fi
|
|
"${HOME}/test-python/bin/pip" install \
|
|
-r "${PROJECT_DIR}/requirements.txt" \
|
|
-r "${PROJECT_DIR}/test-requirements.txt" \
|
|
-r "${PROJECT_DIR}/molecule-requirements.txt"
|
|
|
|
# Run local test
|
|
source "${PROJECT_DIR}/ansible-test-env.rc"
|
|
export ANSIBLE_ROLES_PATH="${ANSIBLE_ROLES_PATH}:${HOME}/zuul-jobs/roles"
|
|
ansible-galaxy install -fr "${PROJECT_DIR}/ansible-collections-requirements.yml"
|
|
ansible-playbook -i "${PROJECT_DIR}/tests/hosts.ini" \
|
|
-e "tripleo_src=$(realpath --relative-to="${HOME}" "${PROJECT_DIR}")" \
|
|
-e "validations_common_role_name=${ROLE_NAME}" \
|
|
-e "tripleo_job_ansible_args='${TRIPLEO_JOB_ANSIBLE_ARGS}'" \
|
|
-e "ansible_user=${USER}" \
|
|
-e "ansible_user_dir=${HOME}" \
|
|
"${PROJECT_DIR}/tests/prepare-test-host.yml" \
|
|
"${PROJECT_DIR}/playbooks/molecule/run-local.yml" \
|
|
-v
|