Convert tox to native zuul

This change implements a native zuul runner for all role tests.
The change will now run role tests, executing molecule, in the
same was as tripleo-ansible.

To ensure we're passing lint checks, several files have been
updated to resolve lint issues which are now more strict due
to the pre-commit changes.

Scripts have been added to allow developers to run molecule tests
on local environments. These tools will allow developers to mimic
the upstream test process locally.

Change-Id: I07bbcc0b331aa89dafdae5978ea2bb4859a59143
Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
(cherry picked from commit 4908e1647f)
This commit is contained in:
Gael Chamoulaud 2019-07-29 13:16:51 +02:00
parent 0e5c743925
commit 93bee0f53c
22 changed files with 561 additions and 33 deletions

View File

@ -11,7 +11,7 @@ repos:
- id: check-merge-conflict - id: check-merge-conflict
- id: debug-statements - id: debug-statements
- id: flake8 - id: flake8
entry: flake8 --ignore=E123,E125,W503,W504,W605 entry: flake8 --ignore=E24,E121,E122,E123,E124,E126,E226,E265,E305,E402,F401,F405,E501,E704,F403,F841,W503,W605
- id: check-yaml - id: check-yaml
files: .*\.(yaml|yml)$ files: .*\.(yaml|yml)$
- repo: https://github.com/adrienverge/yamllint.git - repo: https://github.com/adrienverge/yamllint.git

22
ansible-test-env.rc Normal file
View File

@ -0,0 +1,22 @@
export TRIPLEO_VALIDATIONS_WORKPATH="$(dirname $(readlink -f ${BASH_SOURCE[0]}))"
export ANSIBLE_STDOUT_CALLBACK=debug
export ANSIBLE_CALLBACK_PLUGINS="${TRIPLEO_VALIDATIONS_WORKPATH}/callback_plugins"
export ANSIBLE_LIBRARY="${TRIPLEO_VALIDATIONS_WORKPATH}/library"
export ANSIBLE_LOOKUP_PLUGINS="${TRIPLEO_VALIDATIONS_WORKPATH}/lookup_plugins"
export ANSIBLE_ROLES_PATH="${TRIPLEO_VALIDATIONS_WORKPATH}/roles"
export ANSIBLE_INVENTORY="${TRIPLEO_VALIDATIONS_WORKPATH}/tests/hosts.ini"
export ANSIBLE_RETRY_FILES_ENABLED="0"
export ANSIBLE_LOAD_CALLBACK_PLUGINS="1"
export ANSIBLE_HOST_KEY_CHECKING=False
function unset-ansible-test-env {
for i in $(env | grep ANSIBLE_ | awk -F'=' '{print $1}'); do
unset ${i}
done
unset TRIPLEO_VALIDATIONS_WORKPATH
echo -e "Ansible test environment deactivated.\n"
unset -f unset-ansible-test-env
}
echo -e "Ansible test environment is now active"
echo -e "Run 'unset-ansible-test-env' to deactivate.\n"

View File

@ -175,8 +175,9 @@ class CallbackModule(CallbackBase):
def v2_playbook_on_stats(self, stats): def v2_playbook_on_stats(self, stats):
def failed(host): def failed(host):
return (stats.summarize(host).get('failures', 0) > 0 or _failures = stats.summarize(host).get('failures', 0) > 0
stats.summarize(host).get('unreachable', 0) > 0) _unreachable = stats.summarize(host).get('unreachable', 0) > 0
return (_failures or _unreachable)
hosts = sorted(stats.processed.keys()) hosts = sorted(stats.processed.keys())
failed_hosts = [host for host in hosts if failed(host)] failed_hosts = [host for host in hosts if failed(host)]

View File

@ -524,3 +524,37 @@ will perform the basic tasks noted above.
$ cd tripleo-validations/ $ cd tripleo-validations/
$ ansible-playbook -i localhost, role-addition.yml -e role_name=${NEWROLENAME} $ ansible-playbook -i localhost, role-addition.yml -e role_name=${NEWROLENAME}
When the role is ready for CI, add a **job** entry into the
`zuul.d/molecule.yaml`.
.. code-block:: yaml
- job:
files:
- ^roles/${NEWROLENAME}/.*
name: tripleo-validations-centos-7-molecule-${NEWROLENAME}
parent: tripleo-validations-centos-7-base
vars:
tripleo_validations_role_name: ${NEWROLENAME}
Make sure to add the **job** name into the check and gate section at the top
of the `molecule.yaml` file.
.. code-block:: yaml
- project:
check:
jobs:
- tripleo-validations-centos-7-molecule-${NEWROLENAME}
gate:
jobs:
- tripleo-validations-centos-7-molecule-${NEWROLENAME}
Finally add a role documentation file at
`doc/source/roles/role-${NEWROLENAME}.rst`. This file will need to contain
a title, a literal include of the defaults yaml and a literal include of
the molecule playbook, or playbooks, used to test the role, which is noted
as an "example" playbook.

View File

@ -34,6 +34,51 @@
args: args:
creates: "roles/{{ role_name }}" creates: "roles/{{ role_name }}"
- name: Read zuul molecule file
slurp:
src: zuul.d/molecule.yaml
register: molecule_yaml
- name: Create molecule entry
copy:
content: |-
---
{% set items = molecule_yaml['content'] | b64decode | from_yaml %}
{% set job_index = [] %}
{% set new_job_name = "tripleo-validations-centos-7-molecule-" ~ role_name %}
{% for item in items %}
{% if 'project-template' in item %}
{% if item['project-template']['name'] == "tripleo-validations-molecule-jobs" %}
{% if not (new_job_name in item['project-template']['check']['jobs']) %}
{% set _ = item['project-template']['check']['jobs'].append(new_job_name) %}
{% endif %}
{% if not (new_job_name in item['project-template']['gate']['jobs']) %}
{% set _ = item['project-template']['gate']['jobs'].append(new_job_name) %}
{% endif %}
{% endif %}
{% else %}
{% if item['job']['name'] == new_job_name %}
{% set _ = job_index.append(new_job_name) %}
{% endif %}
{% endif %}
{% endfor %}
{% if (job_index | length) < 1 %}
{% set new_job = {
"name": new_job_name,
"parent": "tripleo-validations-centos-7-base",
"files": [
"^roles/" ~ role_name ~ "/.*"
],
"vars": {
"tripleo_validations_role_name": role_name
}
}
%}
{% set _ = items.append({"job": new_job}) %}
{% endif %}
{{ items | to_nice_yaml(indent=2, width=1337) }}
dest: zuul.d/molecule.yaml
- name: Create role documentation - name: Create role documentation
copy: copy:
content: | content: |

View File

@ -4,6 +4,7 @@
systemctl list-units --failed --plain --no-legend --no-pager | systemctl list-units --failed --plain --no-legend --no-pager |
awk '{print $1}' awk '{print $1}'
register: systemd_status register: systemd_status
changed_when: False
- name: Fails if we find failed units - name: Fails if we find failed units
assert: assert:

45
scripts/bindep-install Executable file
View File

@ -0,0 +1,45 @@
#!/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.
## Shell Opts ----------------------------------------------------------------
set -o pipefail
set -xeuo
## Vars ----------------------------------------------------------------------
export BINDEP_FILE="${BINDEP_FILE:-$(dirname $(readlink -f ${BASH_SOURCE[0]}))/../bindep.txt}"
## Main ----------------------------------------------------------------------
# Source distribution information
source /etc/os-release || source /usr/lib/os-release
RHT_PKG_MGR=$(command -v dnf || command -v yum)
# NOTE(cloudnull): Get a list of packages to install with bindep. If packages
# need to be installed, bindep exits with an exit code of 1.
BINDEP_PKGS=$(bindep -b -f "${BINDEP_FILE}" test || true)
if [[ ${#BINDEP_PKGS} > 0 ]]; then
case "${ID,,}" in
amzn|rhel|centos|fedora)
sudo "${RHT_PKG_MGR}" install -y ${BINDEP_PKGS}
;;
esac
fi

70
scripts/run-local-test Executable file
View File

@ -0,0 +1,70 @@
#!/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.
## Shell Opts ----------------------------------------------------------------
set -o pipefail
set -xeuo
## Vars ----------------------------------------------------------------------
export PROJECT_DIR="$(dirname $(readlink -f ${BASH_SOURCE[0]}))/../"
export ROLE_NAME="${ROLE_NAME:-$1}"
export TRIPLEO_JOB_ANSIBLE_ARGS=${TRIPLEO_JOB_ANSIBLE_ARGS:-"-v"}
## Main ----------------------------------------------------------------------
# Source distribution information
source /etc/os-release || source /usr/lib/os-release
RHT_PKG_MGR=$(command -v dnf || command -v yum)
PYTHON_EXEC=$(command -v python3 || command -v python)
# Install the one requirement we need to run any local test
case "${ID,,}" in
amzn|rhel|centos|fedora)
sudo "${RHT_PKG_MGR}" install -y python*-virtualenv
;;
esac
# Create a virtual env
"${PYTHON_EXEC}" -m virtualenv --system-site-packages "${HOME}/test-python"
# Run bindep
"${HOME}/test-python/bin/pip" install pip 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
PS1="[\u@\h \W]\$" source "${HOME}/test-python/bin/activate"
source "${PROJECT_DIR}/ansible-test-env.rc"
export ANSIBLE_ROLES_PATH="${ANSIBLE_ROLES_PATH}:${HOME}/zuul-jobs/roles"
ansible-playbook -i "${PROJECT_DIR}/tests/hosts.ini" \
-e "tripleo_src=$(realpath --relative-to="${HOME}" "${PROJECT_DIR}")" \
-e "tripleo_validations_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}/zuul.d/playbooks/run-local.yml"

18
tests/conftest.py Normal file
View File

@ -0,0 +1,18 @@
# 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.
def pytest_addoption(parser):
parser.addoption('--scenario', help='scenario setting')
parser.addoption(
'--ansible-args', help='ansible args passed into test runner.')

1
tests/hosts.ini Normal file
View File

@ -0,0 +1 @@
test ansible_connection=local ansible_host=localhost

View File

@ -0,0 +1,68 @@
---
# 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.
- name: pre prepare
hosts: all
gather_facts: false
tasks:
- name: set basic user fact
fail:
msg: >-
The variable `ansible_user` set this option and try again. On the
CLI this can be defined with "-e ansible_user=${USER}"
when:
- ansible_user is undefined
- name: set basic home fact
fail:
msg: >-
The variable `ansible_user_dir` set this option and try again. On
the CLI this can be defined with "-e ansible_user_dir=${HOME}"
when:
- ansible_user_dir is undefined
- name: Ensure the user has a .ssh directory
file:
path: "{{ ansible_user_dir }}/.ssh"
state: directory
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: "0700"
- name: Create ssh key pair
user:
name: "{{ ansible_user }}"
generate_ssh_key: true
ssh_key_bits: 2048
ssh_key_file: "{{ ansible_user_dir }}/.ssh/id_rsa"
- name: Slurp pub key
slurp:
src: "{{ ansible_user_dir ~ '/.ssh/id_rsa.pub' }}"
register: pub_key
- name: Ensure can ssh to can connect to localhost
authorized_key:
user: "{{ ansible_user }}"
key: "{{ pub_key['content'] | b64decode }}"
- name: Get the zuul/zuul-jobs repo
git:
repo: https://opendev.org/zuul/zuul-jobs
dest: "{{ ansible_user_dir }}/zuul-jobs"
version: master
force: true

44
tests/test_molecule.py Normal file
View File

@ -0,0 +1,44 @@
# 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.
import pytest
import subprocess
def test_molecule(pytestconfig):
cmd = ['python', '-m', 'molecule']
scenario = pytestconfig.getoption("scenario")
ansible_args = pytestconfig.getoption("ansible_args")
if ansible_args:
cmd.append('converge')
if scenario:
cmd.extend(['--scenario-name', scenario])
cmd.append('--')
cmd.extend(ansible_args.split())
else:
cmd.append('test')
if scenario:
cmd.extend(['--scenario-name', scenario])
else:
cmd.append('--all')
try:
assert subprocess.call(cmd) == 0
finally:
if ansible_args:
cmd = ['python', '-m', 'molecule', 'destroy']
if scenario:
cmd.extend(['--scenario-name', scenario])
subprocess.call(cmd)

20
tox.ini
View File

@ -82,7 +82,6 @@ deps =
-r {toxinidir}/test-requirements.txt -r {toxinidir}/test-requirements.txt
-r {toxinidir}/molecule-requirements.txt -r {toxinidir}/molecule-requirements.txt
commands = commands =
{[testenv:pep8]commands}
{[testenv:ansible-lint]commands} {[testenv:ansible-lint]commands}
{[testenv:bashate]commands} {[testenv:bashate]commands}
{[testenv:whitespace]commands} {[testenv:whitespace]commands}
@ -117,25 +116,6 @@ commands=
extensions = .rst extensions = .rst
ignore = D001 ignore = D001
[testenv:venv]
commands = {posargs}
[testenv:molecule]
basepython = python3
deps =
ansi2html
docker>=3.7
mock
molecule>=2.22rc3
pytest>=4.4.0
pytest-cov
pytest-html
pytest-molecule>=1.0rc1
pytest-xdist
selinux
commands =
python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {posargs:roles}
[testenv:lower-constraints] [testenv:lower-constraints]
basepython = python3 basepython = python3
deps = deps =

View File

@ -59,10 +59,14 @@ class TestIPRange(base.TestCase):
'''Test ip_range when range is less than minimal''' '''Test ip_range when range is less than minimal'''
errors = validation.check_IP_range('192.168.0.1', '192.168.0.5', 6) errors = validation.check_IP_range('192.168.0.1', '192.168.0.5', 6)
self.assertEqual(len(errors), 2) self.assertEqual(len(errors), 2)
self.assertEqual('The IP range 192.168.0.1 - 192.168.0.5 ' + self.assertEqual(
'contains 5 addresses.', errors[0]) 'The IP range 192.168.0.1 - 192.168.0.5 contains 5 addresses.',
self.assertEqual('This might not be enough for the deployment ' + errors[0]
'or later scaling.', errors[1]) )
self.assertEqual(
'This might not be enough for the deployment or later scaling.',
errors[1]
)
def test_check_lower_bound_greater_than_upper(self): def test_check_lower_bound_greater_than_upper(self):
"""Test ip_range when lower IP bound is greater than upper""" """Test ip_range when lower IP bound is greater than upper"""

View File

@ -175,8 +175,9 @@ class CallbackModule(CallbackBase):
def v2_playbook_on_stats(self, stats): def v2_playbook_on_stats(self, stats):
def failed(host): def failed(host):
return (stats.summarize(host).get('failures', 0) > 0 or _failures = stats.summarize(host).get('failures', 0) > 0
stats.summarize(host).get('unreachable', 0) > 0) _unreachable = stats.summarize(host).get('unreachable', 0) > 0
return (_failures or _unreachable)
hosts = sorted(stats.processed.keys()) hosts = sorted(stats.processed.keys())
failed_hosts = [host for host in hosts if failed(host)] failed_hosts = [host for host in hosts if failed(host)]

View File

@ -109,9 +109,8 @@ class DHCPDiscover(object):
def udp_checksum(self): def udp_checksum(self):
pseudo_header = self.ip_pseudo_header() pseudo_header = self.ip_pseudo_header()
generated_checksum = self._checksum(pseudo_header + generated_checksum = self._checksum(pseudo_header + self.udp_header(
self.udp_header(checksum=0) + checksum=0) + self.dhcp_discover_payload())
self.dhcp_discover_payload())
return socket.htons(generated_checksum) return socket.htons(generated_checksum)
def ip_pseudo_header(self): def ip_pseudo_header(self):

21
zuul.d/base.yaml Normal file
View File

@ -0,0 +1,21 @@
---
- job:
description: Base tripleo-validations job
name: tripleo-validations-centos-7-base
nodeset: centos-7
parent: base
success-url: "reports.html"
failure-url: "reports.html"
pre-run:
- tests/prepare-test-host.yml
- zuul.d/playbooks/pre.yml
run:
- zuul.d/playbooks/run.yml
timeout: 1800
voting: true
- job:
files:
- ^doc/.*
- ^README.rst
name: tripleo-validations-docs
parent: openstack-tox-docs

View File

@ -4,12 +4,13 @@
- openstack-python-jobs - openstack-python-jobs
- openstack-python35-jobs - openstack-python35-jobs
- openstack-python36-jobs - openstack-python36-jobs
- tripleo-validations-molecule-jobs
- check-requirements - check-requirements
- publish-openstack-docs-pti
- release-notes-jobs-python3 - release-notes-jobs-python3
check: check:
jobs: jobs:
- openstack-tox-linters - openstack-tox-linters
- tripleo-validations-docs
- openstack-tox-lower-constraints - openstack-tox-lower-constraints
- tripleo-ci-centos-7-scenario004-standalone: - tripleo-ci-centos-7-scenario004-standalone:
files: files:
@ -17,7 +18,11 @@
gate: gate:
jobs: jobs:
- openstack-tox-linters - openstack-tox-linters
- tripleo-validations-docs
- openstack-tox-lower-constraints - openstack-tox-lower-constraints
- tripleo-ci-centos-7-scenario004-standalone: - tripleo-ci-centos-7-scenario004-standalone:
files: files:
- ^roles/ceph.*$ - ^roles/ceph.*$
post:
jobs:
- publish-openstack-tox-docs

109
zuul.d/molecule.yaml Normal file
View File

@ -0,0 +1,109 @@
---
- project-template:
check:
queue: integrated
jobs:
- tripleo-validations-centos-7-molecule-controller-token
- tripleo-validations-centos-7-molecule-controller-ulimits
- tripleo-validations-centos-7-molecule-ctlplane-ip-range
- tripleo-validations-centos-7-molecule-dns
- tripleo-validations-centos-7-molecule-haproxy
- tripleo-validations-centos-7-molecule-repos
- tripleo-validations-centos-7-molecule-undercloud-cpu
- tripleo-validations-centos-7-molecule-undercloud-ram
- tripleo-validations-centos-7-molecule-undercloud-debug
- tripleo-validations-centos-7-molecule-undercloud-disk-space
- tripleo-validations-centos-7-molecule-xfs-check-ftype
gate:
queue: integrated
jobs:
- tripleo-validations-centos-7-molecule-controller-token
- tripleo-validations-centos-7-molecule-controller-ulimits
- tripleo-validations-centos-7-molecule-ctlplane-ip-range
- tripleo-validations-centos-7-molecule-dns
- tripleo-validations-centos-7-molecule-haproxy
- tripleo-validations-centos-7-molecule-repos
- tripleo-validations-centos-7-molecule-undercloud-cpu
- tripleo-validations-centos-7-molecule-undercloud-ram
- tripleo-validations-centos-7-molecule-undercloud-debug
- tripleo-validations-centos-7-molecule-undercloud-disk-space
- tripleo-validations-centos-7-molecule-xfs-check-ftype
name: tripleo-validations-molecule-jobs
- job:
files:
- ^roles/controller-token/.*
name: tripleo-validations-centos-7-molecule-controller-token
parent: tripleo-validations-centos-7-base
vars:
tripleo_validations_role_name: controller-token
- job:
files:
- ^roles/controller-ulimits/.*
name: tripleo-validations-centos-7-molecule-controller-ulimits
parent: tripleo-validations-centos-7-base
vars:
tripleo_validations_role_name: controller-ulimits
- job:
files:
- ^roles/ctlplane-ip-range/.*
name: tripleo-validations-centos-7-molecule-ctlplane-ip-range
parent: tripleo-validations-centos-7-base
vars:
tripleo_validations_role_name: ctlplane-ip-range
- job:
files:
- ^roles/dns/.*
name: tripleo-validations-centos-7-molecule-dns
parent: tripleo-validations-centos-7-base
vars:
tripleo_validations_role_name: dns
- job:
files:
- ^roles/haproxy/.*
name: tripleo-validations-centos-7-molecule-haproxy
parent: tripleo-validations-centos-7-base
vars:
tripleo_validations_role_name: haproxy
- job:
files:
- ^roles/repos/.*
name: tripleo-validations-centos-7-molecule-repos
parent: tripleo-validations-centos-7-base
vars:
tripleo_validations_role_name: repos
- job:
files:
- ^roles/undercloud-cpu/.*
name: tripleo-validations-centos-7-molecule-undercloud-cpu
parent: tripleo-validations-centos-7-base
vars:
tripleo_validations_role_name: undercloud-cpu
- job:
files:
- ^roles/undercloud-ram/.*
name: tripleo-validations-centos-7-molecule-undercloud-ram
parent: tripleo-validations-centos-7-base
vars:
tripleo_validations_role_name: undercloud-ram
- job:
files:
- ^roles/undercloud-debug/.*
name: tripleo-validations-centos-7-molecule-undercloud-debug
parent: tripleo-validations-centos-7-base
vars:
tripleo_validations_role_name: undercloud-debug
- job:
files:
- ^roles/undercloud-disk-space/.*
name: tripleo-validations-centos-7-molecule-undercloud-disk-space
parent: tripleo-validations-centos-7-base
vars:
tripleo_validations_role_name: undercloud-disk-space
- job:
files:
- ^roles/xfs-check-ftype/.*
name: tripleo-validations-centos-7-molecule-xfs-check-ftype
parent: tripleo-validations-centos-7-base
voting: false
vars:
tripleo_validations_role_name: xfs-check-ftype

28
zuul.d/playbooks/pre.yml Normal file
View File

@ -0,0 +1,28 @@
---
- hosts: all
pre_tasks:
- name: Ensure output dirs
file:
path: "{{ ansible_user_dir }}/zuul-output/logs"
state: directory
- name: Setup bindep
pip:
name: "bindep"
virtualenv: "{{ ansible_user_dir }}/test-python"
virtualenv_site_packages: true
- name: Run bindep
shell: |-
. {{ ansible_user_dir }}/test-python/bin/activate
{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/scripts/bindep-install
become: true
changed_when: False
- name: Setup test-python
pip:
requirements: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/molecule-requirements.txt"
virtualenv: "{{ ansible_user_dir }}/test-python"
virtualenv_site_packages: true
roles:
- role: install-docker

View File

@ -0,0 +1,13 @@
---
- hosts: all
tasks:
- name: set basic zuul fact
set_fact:
zuul:
project:
src_dir: "{{ tripleo_src }}"
ansible_connection: ssh
- import_playbook: pre.yml
- import_playbook: run.yml

19
zuul.d/playbooks/run.yml Normal file
View File

@ -0,0 +1,19 @@
---
- hosts: all
environment:
ANSIBLE_LOG_PATH: "{{ ansible_user_dir }}/zuul-output/logs/ansible-execution.log"
tasks:
- name: Run role test job
shell: |-
. {{ ansible_user_dir }}/test-python/bin/activate
. {{ ansible_user_dir }}/{{ zuul.project.src_dir }}/ansible-test-env.rc
pytest --color=no \
--html={{ ansible_user_dir }}/zuul-output/logs/reports.html \
--self-contained-html \
--ansible-args='{{ tripleo_job_ansible_args | default("-v") }}' \
{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/tests/test_molecule.py
args:
chdir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/roles/{{ tripleo_validations_role_name }}"
executable: /bin/bash
changed_when: False