Use centralized requirements for molecule testing

In order to make molecule tests more widespread across roles to cover
variety of usecases, a centralized approach on managing molecule
requirements is applied.

It ensures that there's no need to separately maintain requirements
for molecule and they can be aligned from integrated repo.

Depends-On: https://review.opendev.org/c/openstack/openstack-ansible/+/938571
Change-Id: I4f0b6705f5bdd0ba14225775108732db32600cb3
This commit is contained in:
Dmitriy Rabotyagov 2024-12-24 12:05:11 +01:00
parent ee7f3c1d5b
commit 7583efdafa
5 changed files with 29 additions and 75 deletions

View File

@ -1,33 +1,6 @@
--- ---
- job:
name: tox-molecule-bookworm
parent: tox-molecule
vars:
tox_envlist: molecule-bookworm
- job:
name: tox-molecule-jammy
parent: tox-molecule
vars:
tox_envlist: molecule-jammy
- job:
name: tox-molecule-stream9
parent: tox-molecule
vars:
tox_envlist: molecule-stream9
- project: - project:
check: templates:
jobs: - openstack-ansible-linters-jobs
- tox-linters - openstack-ansible-molecule
- tox-molecule-bookworm
- tox-molecule-jammy
- tox-molecule-stream9
gate:
jobs:
- tox-linters
- tox-molecule-bookworm
- tox-molecule-jammy
- tox-molecule-stream9

6
examples/playbook.yml Normal file
View File

@ -0,0 +1,6 @@
---
- name: Installing frr
hosts: frr
roles:
- role: "frrouting"

View File

@ -10,8 +10,8 @@ platforms:
- name: primary - name: primary
groups: groups:
- frr - frr
image: "${docker_user:-quay.io/gotmax23}/${docker_image_tag:-debian-systemd:buster}" image: "${DOCKER_REGISTRY:-quay.io/gotmax23}/${DOCKER_IMAGE_TAG:-debian-systemd:bookworm}"
command: ${docker_command:-""} command: ${DOCKER_COMMAND:-""}
privileged: true privileged: true
pre_build_image: true pre_build_image: true
networks: networks:
@ -24,8 +24,8 @@ platforms:
- name: secondary - name: secondary
groups: groups:
- frr - frr
image: "${docker_user:-quay.io/gotmax23}/${docker_image_tag:-debian-systemd:buster}" image: "${DOCKER_REGISTRY:-quay.io/gotmax23}/${DOCKER_IMAGE_TAG:-debian-systemd:bookworm}"
command: ${docker_command:-""} command: ${DOCKER_COMMAND:-""}
privileged: true privileged: true
pre_build_image: true pre_build_image: true
networks: networks:

View File

@ -19,6 +19,7 @@
- ca-certificates - ca-certificates
- "{{ iproute_package_name[ansible_facts['os_family'] | lower] }}" - "{{ iproute_package_name[ansible_facts['os_family'] | lower] }}"
- "{{ iputils_package_name[ansible_facts['os_family'] | lower] }}" - "{{ iputils_package_name[ansible_facts['os_family'] | lower] }}"
- sudo
- name: Clear gathered facts - name: Clear gathered facts
meta: clear_facts meta: clear_facts

56
tox.ini
View File

@ -1,7 +1,7 @@
[tox] [tox]
minversion = 3.1 minversion = 4.0
skipsdist = True skipsdist = True
envlist = linters envlist = linters, molecule
ignore_basepython_conflict = True ignore_basepython_conflict = True
[testenv] [testenv]
@ -10,7 +10,8 @@ usedevelop = False
commands = commands =
/usr/bin/find . -type f -name "*.pyc" -delete /usr/bin/find . -type f -name "*.pyc" -delete
deps = deps =
-r{toxinidir}/test-requirements.txt -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
-rhttps://opendev.org/openstack/openstack-ansible/raw/branch/{env:TEST_BRANCH:master}/test-requirements.txt
passenv = passenv =
COMMON_TESTS_PATH COMMON_TESTS_PATH
HOME HOME
@ -27,7 +28,7 @@ allowlist_externals =
bash bash
setenv = setenv =
PYTHONUNBUFFERED=1 PYTHONUNBUFFERED=1
TEST_IDEMPOTENCE=false TEST_IDEMPOTENCE=true
VIRTUAL_ENV={envdir} VIRTUAL_ENV={envdir}
WORKING_DIR={toxinidir} WORKING_DIR={toxinidir}
@ -37,47 +38,20 @@ setenv =
ANSIBLE_ROLES_PATH={envdir} ANSIBLE_ROLES_PATH={envdir}
commands = commands =
ansible-galaxy role install git+file://{toxinidir} --roles-path {envdir} --force ansible-galaxy role install git+file://{toxinidir} --roles-path {envdir} --force
ansible-lint {toxinidir}/molecule/default/playbook.yml ansible-lint {toxinidir}/examples/playbook.yml
yamllint {toxinidir} yamllint {toxinidir}
[molecule] [testenv:molecule]
deps = # You can use DOCKER_REGISTRY and DOCKER_IMAGE_TAG to switch between
{[testenv]deps} # tested distros. I.e:
docker # DOCKER_IMAGE_TAG=ubuntu-systemd:jammy tox -e molecule
molecule
molecule-plugins[docker]
commands = commands =
molecule test molecule test
setenv = passenv =
{[testenv]setenv} {[testenv]passenv}
DOCKER_REGISTRY
[testenv:molecule-bookworm] DOCKER_IMAGE_TAG
deps = DOCKER_COMMAND
{[molecule]deps}
commands =
{[molecule]commands}
setenv =
{[molecule]setenv}
docker_image_tag=debian-systemd:bookworm
[testenv:molecule-jammy]
deps =
{[molecule]deps}
commands =
{[molecule]commands}
setenv =
{[molecule]setenv}
docker_image_tag=ubuntu-systemd:jammy
[testenv:molecule-stream9]
deps =
{[molecule]deps}
commands =
{[molecule]commands}
setenv =
{[molecule]setenv}
docker_image_tag=centos-systemd:stream9