Add test_deps role and basic molecule job
This change creates a role named test_dep which will be used by all roles tested with molecule. This role is iteself is also tested with molecule. To ensure the CI is able to run these jobs as independent tox environments a zuul job was setup which will execute setup the ci node and execute the tox environment. Depends-On: Ib1749721b32b21ba1ab661a64097d79037e416f3 Change-Id: Idc784fa03c15c56d0f516f4db2e9cb5eee463fae Signed-off-by: Kevin Carter <kecarter@redhat.com>
This commit is contained in:
parent
6a4f0b56a1
commit
e6ec1b1cc9
1
tests/hosts.ini
Normal file
1
tests/hosts.ini
Normal file
@ -0,0 +1 @@
|
||||
localhost
|
25
tests/test_molecule.py
Normal file
25
tests/test_molecule.py
Normal file
@ -0,0 +1,25 @@
|
||||
# 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 os
|
||||
import subprocess
|
||||
|
||||
|
||||
def test_molecule():
|
||||
cmd = ['python', '-m', 'molecule', 'test', '-s', os.getenv('MOL_SCENARIO', 'default')]
|
||||
assert subprocess.call(cmd) == 0
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_molecule()
|
32
tox.ini
32
tox.ini
@ -15,6 +15,15 @@ setenv =
|
||||
ANSIBLE_LIBRARY={toxinidir}/tripleo_ansible/ansible_plugins/modules
|
||||
ANSIBLE_MODULE_UTILS={toxinidir}/tripleo_ansible/ansible_plugins/module_utils
|
||||
ANSIBLE_ROLES_PATH={toxinidir}/tripleo_ansible/roles
|
||||
ANSIBLE_INVENTORY={toxinidir}/tests/hosts.ini
|
||||
ANSIBLE_NOCOWS=1
|
||||
ANSIBLE_RETRY_FILES_ENABLED=0
|
||||
ANSIBLE_STDOUT_CALLBACK=debug
|
||||
VIRTUAL_ENV={envdir}
|
||||
# pip: Avoid 2020-01-01 warnings: https://github.com/pypa/pip/issues/6207
|
||||
# paramiko CryptographyDeprecationWarning: https://github.com/ansible/ansible/issues/52598
|
||||
PYTHONWARNINGS=ignore:DEPRECATION::pip._internal.cli.base_command,ignore::UserWarning
|
||||
PIP_DISABLE_PIP_VERSION_CHECK=1
|
||||
deps = -r {toxinidir}/test-requirements.txt
|
||||
whitelist_externals = bash
|
||||
|
||||
@ -81,3 +90,26 @@ commands =
|
||||
|
||||
[testenv:venv]
|
||||
commands = {posargs}
|
||||
|
||||
[testenv:mol] # environment naming scheme "mol-$ROLE_NAME"
|
||||
# basepython forces tox to use system python and avoid other
|
||||
# python versions like pyenv ones
|
||||
basepython=python
|
||||
deps =
|
||||
ansi2html
|
||||
docker>=3.7
|
||||
pytest
|
||||
pytest-cov
|
||||
pytest-html
|
||||
pytest-xdist
|
||||
mock
|
||||
molecule>=2.22rc1
|
||||
selinux
|
||||
|
||||
[testenv:mol-test_deps]
|
||||
basepython={[testenv:mol]basepython}
|
||||
deps={[testenv:mol]deps}
|
||||
changedir = {toxinidir}/tripleo_ansible/roles/test_deps
|
||||
envdir = {toxworkdir}/mol
|
||||
commands =
|
||||
python -m pytest --color=yes --html={envlogdir}/reports.html --self-contained-html {tty:-s} {toxinidir}/tests/test_molecule.py
|
||||
|
29
tripleo_ansible/roles/test_deps/README.md
Normal file
29
tripleo_ansible/roles/test_deps/README.md
Normal file
@ -0,0 +1,29 @@
|
||||
Role Name
|
||||
=========
|
||||
|
||||
A brief description of the role goes here.
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
Any pre-requisites that may not be covered by Ansible itself or the role should
|
||||
be mentioned here.
|
||||
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
A description of the settable variables for this role should go here, including
|
||||
any variables that are in defaults/main.yml, vars/main.yml, and any variables
|
||||
that can/should be set via parameters to the role. Any variables that are read
|
||||
from other roles and/or the global scope (ie. hostvars, group vars, etc.)
|
||||
should be mentioned here as well.
|
||||
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
A list of other roles hosted on Galaxy should go here, plus any details in
|
||||
regards to parameters that may need to be set for other roles, or variables
|
||||
that are used from other roles.
|
21
tripleo_ansible/roles/test_deps/defaults/main.yml
Normal file
21
tripleo_ansible/roles/test_deps/defaults/main.yml
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
# 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.
|
||||
|
||||
|
||||
# All variables intended for modification should place placed in this file.
|
||||
|
||||
# All variables within this role should have a prefix of "test_deps"
|
||||
test_deps_debug: false
|
44
tripleo_ansible/roles/test_deps/meta/main.yml
Normal file
44
tripleo_ansible/roles/test_deps/meta/main.yml
Normal file
@ -0,0 +1,44 @@
|
||||
---
|
||||
# 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.
|
||||
|
||||
|
||||
galaxy_info:
|
||||
author: OpenStack
|
||||
description: TripleO OpenStack Role -- test_deps
|
||||
company: Red Hat
|
||||
license: Apache-2.0
|
||||
min_ansible_version: 2.7
|
||||
#
|
||||
# Provide a list of supported platforms, and for each platform a list of versions.
|
||||
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
|
||||
# To view available platforms and versions (or releases), visit:
|
||||
# https://galaxy.ansible.com/api/v1/platforms/
|
||||
#
|
||||
platforms:
|
||||
- name: Fedora
|
||||
versions:
|
||||
- 28
|
||||
- name: CentOS
|
||||
versions:
|
||||
- 7
|
||||
|
||||
galaxy_tags:
|
||||
- tripleo
|
||||
|
||||
|
||||
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
|
||||
# if you add dependencies to this list.
|
||||
dependencies: []
|
37
tripleo_ansible/roles/test_deps/molecule/default/Dockerfile
Normal file
37
tripleo_ansible/roles/test_deps/molecule/default/Dockerfile
Normal file
@ -0,0 +1,37 @@
|
||||
# Molecule managed
|
||||
# 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.
|
||||
|
||||
|
||||
|
||||
{% if item.registry is defined %}
|
||||
FROM {{ item.registry.url }}/{{ item.image }}
|
||||
{% else %}
|
||||
FROM {{ item.image }}
|
||||
{% endif %}
|
||||
|
||||
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
|
||||
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash {{ item.pkg_extras | default('') }} && dnf clean all; \
|
||||
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl python-setuptools bash {{ item.pkg_extras | default('') }} && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
|
||||
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml {{ item.pkg_extras | default('') }} && zypper clean -a; \
|
||||
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates {{ item.pkg_extras | default('') }}; \
|
||||
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates {{ item.pkg_extras | default('') }} && xbps-remove -O; fi
|
||||
|
||||
{% for pkg in item.easy_install | default([]) %}
|
||||
# install pip for centos where there is no python-pip rpm in default repos
|
||||
RUN easy_install {{ pkg }}
|
||||
{% endfor %}
|
||||
|
||||
CMD ["sh", "-c", "while true; do sleep 10000; done"]
|
@ -0,0 +1,48 @@
|
||||
---
|
||||
driver:
|
||||
name: docker
|
||||
|
||||
log: true
|
||||
|
||||
platforms:
|
||||
- name: centos7
|
||||
hostname: centos7
|
||||
image: centos:7
|
||||
dockerfile: Dockerfile
|
||||
pkg_extras: python-setuptools
|
||||
easy_install:
|
||||
- pip
|
||||
environment: &env
|
||||
http_proxy: "{{ lookup('env', 'http_proxy') }}"
|
||||
https_proxy: "{{ lookup('env', 'https_proxy') }}"
|
||||
|
||||
- name: fedora28
|
||||
hostname: fedora28
|
||||
image: fedora:28
|
||||
dockerfile: Dockerfile
|
||||
pkg_extras: python*-setuptools
|
||||
environment:
|
||||
<<: *env
|
||||
|
||||
provisioner:
|
||||
name: ansible
|
||||
log: true
|
||||
env:
|
||||
ANSIBLE_STDOUT_CALLBACK: yaml
|
||||
|
||||
scenario:
|
||||
test_sequence:
|
||||
- destroy
|
||||
- create
|
||||
- prepare
|
||||
- converge
|
||||
- verify
|
||||
- destroy
|
||||
|
||||
lint:
|
||||
enabled: false
|
||||
|
||||
verifier:
|
||||
name: testinfra
|
||||
lint:
|
||||
name: flake8
|
@ -0,0 +1,21 @@
|
||||
---
|
||||
# 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: Converge
|
||||
hosts: all
|
||||
roles:
|
||||
- role: "test_deps"
|
21
tripleo_ansible/roles/test_deps/molecule/default/prepare.yml
Normal file
21
tripleo_ansible/roles/test_deps/molecule/default/prepare.yml
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
# 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: Prepare
|
||||
hosts: all
|
||||
roles:
|
||||
- role: test_deps
|
15
tripleo_ansible/roles/test_deps/molecule/default/verify.yml
Normal file
15
tripleo_ansible/roles/test_deps/molecule/default/verify.yml
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
# 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.
|
42
tripleo_ansible/roles/test_deps/tasks/main.yml
Normal file
42
tripleo_ansible/roles/test_deps/tasks/main.yml
Normal file
@ -0,0 +1,42 @@
|
||||
---
|
||||
# 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.
|
||||
|
||||
|
||||
# "{{ role_name }}" will search for and load any operating system variable file
|
||||
# found within the "vars/" path. If no OS files are found the task will skip.
|
||||
- name: Gather variables for each operating system
|
||||
include_vars: "{{ item }}"
|
||||
with_first_found:
|
||||
- skip: true
|
||||
files:
|
||||
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml"
|
||||
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
|
||||
- "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
|
||||
- "{{ ansible_distribution | lower }}.yml"
|
||||
- "{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yml"
|
||||
- "{{ ansible_os_family | lower }}.yml"
|
||||
tags:
|
||||
- always
|
||||
|
||||
- name: install deplorean repo
|
||||
get_url:
|
||||
url: "https://trunk.rdoproject.org/{{ ansible_distribution | lower }}{{ ansible_distribution_major_version }}-master/current-tripleo/delorean.repo"
|
||||
dest: /etc/yum.repos.d/delorean.repo
|
||||
|
||||
- name: install deplorean-deps repo
|
||||
get_url:
|
||||
url: "https://trunk.rdoproject.org/{{ ansible_distribution | lower }}{{ ansible_distribution_major_version }}-master/delorean-deps.repo"
|
||||
dest: /etc/yum.repos.d/delorean-deps.repo
|
22
tripleo_ansible/roles/test_deps/vars/main.yml
Normal file
22
tripleo_ansible/roles/test_deps/vars/main.yml
Normal file
@ -0,0 +1,22 @@
|
||||
---
|
||||
# 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.
|
||||
|
||||
|
||||
# While options found within the vars/ path can be overridden using extra
|
||||
# vars, items within this path are considered part of the role and not
|
||||
# intended to be modified.
|
||||
|
||||
# All variables within this role should have a prefix of "test_deps"
|
16
zuul.d/jobs.yaml
Normal file
16
zuul.d/jobs.yaml
Normal file
@ -0,0 +1,16 @@
|
||||
---
|
||||
- job:
|
||||
name: tripleo-ansible-centos
|
||||
parent: tox-molecule
|
||||
description: Basic tripleo-ansible tox job
|
||||
timeout: 900
|
||||
nodeset: centos-7
|
||||
voting: true
|
||||
|
||||
- job:
|
||||
name: tripleo-ansible-centos-7-molecule-test_deps
|
||||
parent: tripleo-ansible-centos
|
||||
files:
|
||||
- ^tripleo_ansible/roles/test_deps/.*
|
||||
vars:
|
||||
tox_envlist: mol-test_deps
|
@ -3,6 +3,7 @@
|
||||
check:
|
||||
jobs:
|
||||
- openstack-tox-linters
|
||||
- tripleo-ansible-centos-7-molecule-test_deps
|
||||
gate:
|
||||
jobs:
|
||||
- openstack-tox-linters
|
||||
|
Loading…
x
Reference in New Issue
Block a user