Add base role tests

Depends-On: https://review.openstack.org/#/c/554402/
Change-Id: If4047f2d3f2286dc6188cc62e3d17c47b2f88cd4
This commit is contained in:
Logan V 2018-03-19 15:23:14 -05:00
parent 3791c7520b
commit cc125a7437
9 changed files with 246 additions and 107 deletions

View File

@ -2,40 +2,51 @@
# before the execution of any tests. # before the execution of any tests.
# #
# See the following for details: # See the following for details:
# - http://docs.openstack.org/infra/bindep/ # - https://docs.openstack.org/infra/bindep/
# - https://github.com/openstack-infra/bindep # - https://git.openstack.org/cgit/openstack-infra/bindep
# #
# Even if the role does not make use of this facility, it # Even if the role does not make use of this facility, it
# is better to have this file empty, otherwise OpenStack-CI # is better to have this file empty, otherwise OpenStack-CI
# will fall back to installing its default packages which # will fall back to installing its default packages which
# will potentially be detrimental to the tests executed. # will potentially be detrimental to the tests executed.
#
# Note:
# This file is maintained in the openstack-ansible-tests repository.
# https://git.openstack.org/cgit/openstack/openstack-ansible-tests/tree/bindep.txt
# If you need to remove or add extra dependencies, you should modify
# the central file instead and once your change is accepted then update
# this file as well. The purpose of this file is to ensure that Python and
# Ansible have all their necessary binary requirements on the test host before
# tox executes. Any binary requirements needed by services/roles should be
# installed by those roles in their applicable package install tasks, not through
# using this file.
#
# The gcc compiler
gcc
# Base requirements for Ubuntu # Base requirements for Ubuntu
build-essential [platform:dpkg]
git-core [platform:dpkg] git-core [platform:dpkg]
libssl-dev [platform:dpkg] libssl-dev [platform:dpkg]
libffi-dev [platform:dpkg] libffi-dev [platform:dpkg]
python2.7 [platform:dpkg] python2.7 [platform:dpkg]
python-apt [platform:dpkg]
python-dev [platform:dpkg] python-dev [platform:dpkg]
python3 [platform:dpkg]
python3-apt [platform:dpkg]
python3-dev [platform:dpkg]
# Base requirements for CentOS # Base requirements for RPM distros
gcc [platform:rpm]
gcc-c++ [platform:rpm] gcc-c++ [platform:rpm]
git [platform:rpm] git [platform:rpm]
python-devel [platform:rpm]
libffi-devel [platform:rpm] libffi-devel [platform:rpm]
openssl-devel [platform:rpm] openssl-devel [platform:rpm]
python-devel [platform:rpm]
python2-dnf [platform:fedora]
# For SELinux # For SELinux
libselinux-python [platform:rpm] libselinux-python [platform:redhat]
libsemanage-python [platform:redhat]
# For SSL SNI support
python-pyasn1 [platform:dpkg]
python-openssl [platform:dpkg]
python-ndg-httpsclient [platform:ubuntu !platform:ubuntu-trusty]
python2-pyasn1 [platform:rpm]
python2-pyOpenSSL [platform:rpm]
python-ndg_httpsclient [platform:rpm]
# Required for compressing collected log files in CI # Required for compressing collected log files in CI
gzip gzip

View File

@ -22,7 +22,6 @@
# All configuration values have a default; values that are commented out # All configuration values have a default; values that are commented out
# serve to show the default. # serve to show the default.
import openstackdocstheme
import pbr.version import pbr.version
import os import os
@ -40,8 +39,8 @@ import os
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones. # ones.
extensions = [ extensions = [
'openstackdocstheme',
'sphinx.ext.autodoc', 'sphinx.ext.autodoc',
'oslosphinx',
'sphinxmark' 'sphinxmark'
] ]
@ -62,15 +61,17 @@ master_doc = 'index'
# General information about the project. # General information about the project.
author = 'OpenStack-Ansible Contributors' author = 'OpenStack-Ansible Contributors'
category = 'Miscellaneous' category = 'Miscellaneous'
copyright = '2014-2018, OpenStack-Ansible Contributors' copyright = '2014-2016, OpenStack-Ansible Contributors'
description = 'OpenStack-Ansible deploys OpenStack environments using Ansible.' description = 'OpenStack-Ansible deploys OpenStack environments using Ansible.'
project = 'OpenStack-Ansible' project = 'OpenStack-Ansible'
role_name = 'os_nova' role_name = 'systemd_mount'
target_name = 'openstack-ansible-' + role_name target_name = 'openstack-ansible-' + role_name
title = 'OpenStack-Ansible Documentation: ' + role_name + 'role' title = 'OpenStack-Ansible Documentation: ' + role_name + 'role'
# The link to the browsable source code (for the left hand menu) # The link to the browsable source code (for the left hand menu)
oslosphinx_cgit_link = 'https://git.openstack.org/cgit/openstack/' + target_name oslosphinx_cgit_link = (
"https://git.openstack.org/cgit/openstack/{}".format(target_name)
)
# The version info for the project you're documenting, acts as replacement for # The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the # |version| and |release|, also used in various other places throughout the
@ -83,21 +84,10 @@ release = version_info.version_string_with_vcs()
# The short X.Y version. # The short X.Y version.
version = version_info.canonical_version_string() version = version_info.canonical_version_string()
# A few variables have to be set for the log-a-bug feature. # openstackdocstheme options
# giturl: The location of conf.py on Git. Must be set manually. repository_name = 'openstack/' + target_name
# gitsha: The SHA checksum of the bug description.
# Automatically extracted from git log.
# bug_tag: Tag for categorizing the bug. Must be set manually.
# These variables are passed to the logabug code via html_context.
giturl = ("https://git.openstack.org/cgit/openstack/{0}"
"/tree/doc/source").format(target_name)
git_cmd = "/usr/bin/git log | head -n1 | cut -f2 -d' '"
gitsha = os.popen(git_cmd).read().strip('\n')
bug_project = project.lower() bug_project = project.lower()
bug_title = "Documentation bug" bug_tag = ''
html_context = {"gitsha": gitsha, "giturl": giturl,
"bug_tag": "docs", "bug_title": bug_title,
"bug_project": bug_project}
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.
@ -156,7 +146,7 @@ html_theme = 'openstackdocs'
# html_theme_options = {} # html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory. # Add any paths that contain custom themes here, relative to this directory.
html_theme_path = [openstackdocstheme.get_html_theme_path()] # html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to # The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation". # "<project> v<release> documentation".

View File

@ -1,6 +1,6 @@
======================================= ========================================
systemd_mount role for OpenStack-Ansible systemd_mount role for OpenStack-Ansible
======================================= ========================================
:tags: openstack, systemd_mount, cloud, ansible :tags: openstack, systemd_mount, cloud, ansible
:category: \*nix :category: \*nix

View File

@ -22,8 +22,6 @@
# All configuration values have a default; values that are commented out # All configuration values have a default; values that are commented out
# serve to show the default. # serve to show the default.
import pbr.version
# If extensions (or modules to document with autodoc) are in another directory, # If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the # add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here. # documentation root, use os.path.abspath to make it absolute, like shown here.
@ -38,7 +36,7 @@ import pbr.version
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones. # ones.
extensions = [ extensions = [
'oslosphinx', 'openstackdocstheme',
'reno.sphinxext', 'reno.sphinxext',
] ]
@ -57,7 +55,7 @@ master_doc = 'index'
# General information about the project. # General information about the project.
author = 'OpenStack-Ansible Contributors' author = 'OpenStack-Ansible Contributors'
category = 'Miscellaneous' category = 'Miscellaneous'
copyright = '2014-2018, OpenStack-Ansible Contributors' copyright = '2014-2016, OpenStack-Ansible Contributors'
description = 'OpenStack-Ansible deploys OpenStack environments using Ansible.' description = 'OpenStack-Ansible deploys OpenStack environments using Ansible.'
project = 'OpenStack-Ansible' project = 'OpenStack-Ansible'
role_name = 'systemd_mount' role_name = 'systemd_mount'
@ -65,18 +63,21 @@ target_name = 'openstack-ansible-' + role_name
title = 'OpenStack-Ansible Release Notes: ' + role_name + 'role' title = 'OpenStack-Ansible Release Notes: ' + role_name + 'role'
# The link to the browsable source code (for the left hand menu) # The link to the browsable source code (for the left hand menu)
oslosphinx_cgit_link = 'https://git.openstack.org/cgit/openstack/' + target_name oslosphinx_cgit_link = (
"https://git.openstack.org/cgit/openstack/{}".format(target_name)
)
# The version info for the project you're documenting, acts as replacement for # Release notes do not need a version number in the title,
# |version| and |release|, also used in various other places throughout the # they cover multiple versions.
# built documents.
#
# The short X.Y version.
version_info = pbr.version.VersionInfo(target_name)
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = version_info.version_string_with_vcs() release = ''
# The short X.Y version. # The short X.Y version.
version = version_info.canonical_version_string() version = ''
# openstackdocstheme options
repository_name = 'openstack/' + target_name
bug_project = project.lower()
bug_tag = ''
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.
@ -121,7 +122,7 @@ pygments_style = 'sphinx'
# The theme to use for HTML and HTML Help pages. See the documentation for # The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes. # a list of builtin themes.
html_theme = 'default' html_theme = 'openstackdocs'
# Theme options are theme-specific and customize the look and feel of a theme # Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the # further. For a list of options available for each theme, see the

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright 2018, Rackspace US, Inc. # Copyright 2015, Rackspace US, Inc.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -12,63 +12,48 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
#
# Note:
# This file is maintained in the openstack-ansible-tests repository.
# https://git.openstack.org/cgit/openstack/openstack-ansible-tests/tree/run_tests.sh
# If you need to modify this file, update the one in the openstack-ansible-tests
# repository and then update this file as well. The purpose of this file is to
# prepare the host and then execute all the tox tests.
#
set -xeuo pipefail ## Shell Opts ----------------------------------------------------------------
set -xeu
FUNCTIONAL_TEST=${FUNCTIONAL_TEST:-true} ## Vars ----------------------------------------------------------------------
# Install python2 for Ubuntu 16.04 and CentOS 7 export WORKING_DIR=${WORKING_DIR:-$(pwd)}
if which apt-get; then
sudo apt-get update && sudo apt-get install -y python
fi
if which yum; then ## Main ----------------------------------------------------------------------
sudo yum install -y python
fi
# Install pip. source /etc/os-release || source /usr/lib/os-release
if ! which pip; then
curl --silent --show-error --retry 5 \
https://bootstrap.pypa.io/get-pip.py | sudo python2.7
fi
# Install bindep and tox with pip. install_pkg_deps() {
sudo pip install bindep tox pkg_deps="git"
# CentOS 7 requires two additional packages: # Prefer dnf over yum for CentOS.
# redhat-lsb-core - for bindep profile support which dnf &>/dev/null && RHT_PKG_MGR='dnf' || RHT_PKG_MGR='yum'
# epel-release - required to install python-ndg_httpsclient/python2-pyasn1
if which yum; then
sudo yum -y install redhat-lsb-core epel-release
fi
# Get a list of packages to install with bindep. If packages need to be case ${ID,,} in
# installed, bindep exits with an exit code of 1. *suse*) pkg_mgr_cmd="zypper -n in" ;;
BINDEP_PKGS=$(bindep -b -f bindep.txt test || true) centos|rhel|fedora) pkg_mgr_cmd="${RHT_PKG_MGR} install -y" ;;
echo "Packages to install: ${BINDEP_PKGS}" ubuntu|debian) pkg_mgr_cmd="apt-get install -y" ;;
*) echo "unsupported distribution: ${ID,,}"; exit 1 ;;
esac
# Install a list of OS packages provided by bindep. eval sudo $pkg_mgr_cmd $pkg_deps
if which apt-get; then }
sudo apt-get update
DEBIAN_FRONTEND=noninteractive \ # Install the host distro package dependencies
sudo apt-get -q --option "Dpkg::Options::=--force-confold" \ install_pkg_deps
--assume-yes install $BINDEP_PKGS
elif which yum; then # Clone the tests repo for access to the common test script
# Don't run yum with an empty list of packages. source tests/tests-repo-clone.sh
# It will fail and cause the script to exit with an error.
if [[ ${#BINDEP_PKGS} > 0 ]]; then # Execute the common test script
sudo yum install -y $BINDEP_PKGS source tests/common/run_tests_common.sh
fi
fi
# Loop through each tox environment and run tests.
for tox_env in $(awk -F= '/envlist/ { gsub(",", " "); print $2 }' tox.ini); do
echo "Executing tox environment: ${tox_env}"
if [[ ${tox_env} == ansible-functional ]]; then
if ${FUNCTIONAL_TEST}; then
tox -e ${tox_env}
fi
else
tox -e ${tox_env}
fi
done

View File

@ -2,7 +2,7 @@
name = systemd_mount name = systemd_mount
summary = systemd_mount for OpenStack Ansible summary = systemd_mount for OpenStack Ansible
description-file = description-file =
README.rst README.md
author = OpenStack author = OpenStack
author-email = openstack-dev@lists.openstack.org author-email = openstack-dev@lists.openstack.org
home-page = http://docs.openstack.org/developer/ansible-systemd_mount/ home-page = http://docs.openstack.org/developer/ansible-systemd_mount/

View File

@ -1,5 +1,6 @@
--- ---
# Copyright 2018, Rackspace US, Inc. # Copyright 2018, Rackspace US, Inc.
# Copyright 2018, Logan Vig <logan2211@gmail.com>
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -13,7 +14,11 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
- hosts: localhost - name: Playbook for role testing
gather_facts: true hosts: localhost
tasks: connection: local
- debug: msg=testing user: root
become: true
roles:
- role: "systemd_mount"

117
tests/tests-repo-clone.sh Executable file
View File

@ -0,0 +1,117 @@
#!/bin/bash
# Copyright 2017, Rackspace US, Inc.
#
# 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.
# PURPOSE:
# This script clones the openstack-ansible-tests repository to the
# tests/common folder in order to be able to re-use test components
# for role testing.
# WARNING:
# This file is maintained in the openstack-ansible-tests repository:
# https://git.openstack.org/cgit/openstack/openstack-ansible-tests
# If you need to change this script, then propose the change there.
# Once it merges, the change will be replicated to the other repositories.
## Shell Opts ----------------------------------------------------------------
set -e
## Vars ----------------------------------------------------------------------
export TESTING_HOME=${TESTING_HOME:-$HOME}
export WORKING_DIR=${WORKING_DIR:-$(pwd)}
export CLONE_UPGRADE_TESTS=${CLONE_UPGRADE_TESTS:-no}
export ZUUL_TESTS_CLONE_LOCATION="/home/zuul/src/git.openstack.org/openstack/openstack-ansible-tests"
## Functions -----------------------------------------------------------------
function create_tests_clonemap {
# Prepare the clonemap for zuul-cloner to use
cat > ${TESTING_HOME}/tests-clonemap.yaml << EOF
clonemap:
- name: openstack/openstack-ansible-tests
dest: ${WORKING_DIR}/tests/common
EOF
}
## Main ----------------------------------------------------------------------
# If zuul-cloner is present, use it so that we
# also include any dependent patches from the
# tests repo noted in the commit message.
# We only want to use zuul-cloner if we detect
# zuul v2 running, so we check for the presence
# of the ZUUL_REF environment variable.
# ref: http://git.openstack.org/cgit/openstack-infra/zuul/tree/zuul/ansible/filter/zuul_filters.py?h=feature/zuulv3#n17
if [[ -x /usr/zuul-env/bin/zuul-cloner ]] && [[ "${ZUUL_REF:-none}" != "none" ]]; then
# Prepare the clonemap for zuul-cloner to use
create_tests_clonemap
# Execute the clone
/usr/zuul-env/bin/zuul-cloner \
--cache-dir /opt/git \
--map ${TESTING_HOME}/tests-clonemap.yaml \
git://git.openstack.org \
openstack/openstack-ansible-tests
# Clean up the clonemap.
rm -f ${TESTING_HOME}/tests-clonemap.yaml
# Alternatively, use a simple git-clone. We do
# not re-clone if the directory exists already
# to prevent overwriting any local changes which
# may have been made.
elif [[ ! -d tests/common ]]; then
# The tests repo doesn't need a clone, we can just
# symlink it. As zuul v3 clones into a folder called
# 'workspace' we have to use one of its environment
# variables to determine the project name.
if [[ "${ZUUL_SHORT_PROJECT_NAME:-none}" == "openstack-ansible-tests" ]] ||\
[[ "$(basename ${WORKING_DIR})" == "openstack-ansible-tests" ]]; then
ln -s ${WORKING_DIR} ${WORKING_DIR}/tests/common
# In zuul v3 any dependent repository is placed into
# /home/zuul/src/git.openstack.org, so we check to see
# if there is a tests checkout there already. If so, we
# symlink that and use it.
elif [[ -d "${ZUUL_TESTS_CLONE_LOCATION}" ]]; then
ln -s "${ZUUL_TESTS_CLONE_LOCATION}" ${WORKING_DIR}/tests/common
# Otherwise we're clearly not in zuul or using a previously setup
# repo in some way, so just clone it from upstream.
else
git clone \
https://git.openstack.org/openstack/openstack-ansible-tests \
${WORKING_DIR}/tests/common
fi
fi
# If this test set includes an upgrade test, the
# previous stable release tests repo must also be
# cloned.
# Note:
# Dependent patches to the previous stable release
# tests repo are not supported.
if [[ "${CLONE_UPGRADE_TESTS}" == "yes" ]]; then
if [[ ! -d "${WORKING_DIR}/tests/common/previous" ]]; then
git clone -b stable/queens \
https://git.openstack.org/openstack/openstack-ansible-tests \
${WORKING_DIR}/tests/common/previous
fi
fi

30
zuul.d/project.yaml Normal file
View File

@ -0,0 +1,30 @@
# Copyright 2017, Rackspace US, Inc.
#
# 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.
- project:
check:
jobs:
- openstack-ansible-linters
- openstack-ansible-functional-centos-7
- openstack-ansible-functional-opensuse-423
- openstack-ansible-functional-ubuntu-xenial
experimental:
jobs:
- openstack-ansible-integrated-deploy-aio
gate:
jobs:
- openstack-ansible-linters
- openstack-ansible-functional-centos-7
- openstack-ansible-functional-opensuse-423
- openstack-ansible-functional-ubuntu-xenial