From b0112d6fae6c91245a4f9a0246690dee58aab145 Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Wed, 5 Dec 2018 16:41:56 -0500 Subject: [PATCH] Add .zuul.yaml testing This moves our testing in-tree for zuul. Change-Id: If91ba558bc9741341df689b3927cda916beebb5d Depends-On: https://review.openstack.org/623119/ Signed-off-by: Paul Belanger --- .zuul.yaml | 61 ++++++++++++++++++++++++++++++++++++++++ tests/ansible.cfg | 2 -- tests/inventory | 4 +-- tests/playbooks/pre.yaml | 28 ++++++++++++++++++ tests/playbooks/run.yaml | 20 +++++++++++++ tests/test.yaml | 39 ------------------------- tox.ini | 18 +++--------- 7 files changed, 115 insertions(+), 57 deletions(-) create mode 100644 .zuul.yaml delete mode 100644 tests/ansible.cfg create mode 100644 tests/playbooks/pre.yaml create mode 100644 tests/playbooks/run.yaml delete mode 100644 tests/test.yaml diff --git a/.zuul.yaml b/.zuul.yaml new file mode 100644 index 0000000..ae03c01 --- /dev/null +++ b/.zuul.yaml @@ -0,0 +1,61 @@ +- job: + name: ansible-role-virtualenv-base + parent: unittests + pre-run: tests/playbooks/pre.yaml + run: tests/playbooks/run.yaml + roles: + - zuul: openstack/ansible-role-virtualenv + +# Testing for virtualenv_install_method: pip +- job: + name: ansible-role-virtualenv + parent: ansible-role-virtualenv-base + vars: + virtualenv_install_method: pip + +- job: + name: ansible-role-virtualenv-fedora-latest + parent: ansible-role-virtualenv + nodeset: fedora-latest + +- job: + name: ansible-role-virtualenv-ubuntu-bionic + parent: ansible-role-virtualenv + nodeset: ubuntu-bionic + +# Testing for virtualenv_install_method: git +- job: + name: ansible-role-virtualenv-src + parent: ansible-role-virtualenv-base + vars: + virtualenv_git_update: false + virtualenv_install_method: git + +- job: + name: ansible-role-virtualenv-src-fedora-latest + parent: ansible-role-virtualenv-src + nodeset: fedora-latest + +- job: + name: ansible-role-virtualenv-src-ubuntu-bionic + parent: ansible-role-virtualenv-src + nodeset: ubuntu-bionic + +- project: + templates: + - windmill-jobs-fedora-latest + - windmill-jobs-bionic + check: + jobs: + - ansible-role-virtualenv-fedora-latest + - ansible-role-virtualenv-ubuntu-bionic + - ansible-role-virtualenv-src-fedora-latest + - ansible-role-virtualenv-src-ubuntu-bionic + - tox-linters + gate: + jobs: + - ansible-role-virtualenv-fedora-latest + - ansible-role-virtualenv-ubuntu-bionic + - ansible-role-virtualenv-src-fedora-latest + - ansible-role-virtualenv-src-ubuntu-bionic + - tox-linters diff --git a/tests/ansible.cfg b/tests/ansible.cfg deleted file mode 100644 index 6c8a344..0000000 --- a/tests/ansible.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[defaults] -roles_path = ../.. diff --git a/tests/inventory b/tests/inventory index 68b2dac..4ff05aa 100644 --- a/tests/inventory +++ b/tests/inventory @@ -1,2 +1,2 @@ -[all] -localhost +[test] +test01 ansible_host=127.0.0.1 diff --git a/tests/playbooks/pre.yaml b/tests/playbooks/pre.yaml new file mode 100644 index 0000000..0dce620 --- /dev/null +++ b/tests/playbooks/pre.yaml @@ -0,0 +1,28 @@ +# Copyright 2018 Red Hat, 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. +--- +- hosts: all + tasks: + # TODO(pabelanger): Remove once this lands in our base job in + # project-config. + - name: Execute ensure-output-dirs role + include_role: + name: ensure-output-dirs + + - name: Disable extra wheels mirror + become: yes + lineinfile: + dest: /etc/pip.conf + regexp: ^extra-index-url + state: absent diff --git a/tests/playbooks/run.yaml b/tests/playbooks/run.yaml new file mode 100644 index 0000000..9ee634b --- /dev/null +++ b/tests/playbooks/run.yaml @@ -0,0 +1,20 @@ +# Copyright 2018 Red Hat, 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. +--- +- hosts: all + vars: + rolename: ansible-role-virtualenv + + roles: + - "{{ rolename }}" diff --git a/tests/test.yaml b/tests/test.yaml deleted file mode 100644 index dfba720..0000000 --- a/tests/test.yaml +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright 2015 Red Hat, 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. ---- -- hosts: localhost - vars: - rolename: "{{ lookup('pipe', 'pwd') | dirname | basename }}" - pre_tasks: - # Make sure OS does not have a stale package cache. - - name: Update apt cache. - become: yes - apt: - update_cache: yes - when: ansible_os_family == 'Debian' - - roles: - - "{{ rolename }}" - - post_tasks: - - name: Register virtualenv_git_dest_stat. - stat: - path: /opt/ansible-role-virtualenv/git/pypa/virtualenv - register: virtualenv_git_dest_stat - - - name: Assert virtualenv_git_dest tests. - assert: - that: - - virtualenv_git_dest_stat.stat.exists - - virtualenv_git_dest_stat.stat.isdir diff --git a/tox.ini b/tox.ini index 60b7f91..33fa54c 100644 --- a/tox.ini +++ b/tox.ini @@ -4,20 +4,10 @@ envlist = docs,linters skipsdist = True [testenv] +basepython = python3 deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt -[testenv:functional] -commands = - # NOTE(pabelanger): Because ansible default ansible_user to null now, we need to pass it via CLI. - ansible-playbook -i tests/inventory tests/test.yaml -e ansible_user={env:USER} -passenv = - HOME - USER -setenv = - ANSIBLE_CONFIG = {toxinidir}/tests/ansible.cfg - PYTHONUNBUFFERED = 1 - [testenv:docs] commands = python setup.py build_sphinx @@ -34,14 +24,14 @@ exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build [testenv:linters] setenv = - ANSIBLE_CONFIG = tests/ansible.cfg + ANSIBLE_ROLES_PATH = .. whitelist_externals = bash commands = # PEP8 Lint Check flake8 # Ansible Lint Check - bash -c "find . -type f -regex '.*.y[a]?ml' -print0 | xargs -t -n1 -0 \ - ansible-lint" + bash -c "find . -not -path '*/\.*' -type f -regex '.*.y[a]?ml' -print0 | \ + xargs -t -n1 -0 ansible-lint" # Ansible Syntax Check bash -c "find tests -type f -regex '.*.y[a]?ml' -print | xargs -t -n1 \ ansible-playbook --syntax-check -i tests/inventory \