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

@ -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:
check:
jobs:
- tox-linters
- tox-molecule-bookworm
- tox-molecule-jammy
- tox-molecule-stream9
gate:
jobs:
- tox-linters
- tox-molecule-bookworm
- tox-molecule-jammy
- tox-molecule-stream9
templates:
- openstack-ansible-linters-jobs
- openstack-ansible-molecule

6
examples/playbook.yml Normal file

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

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

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

56
tox.ini

@ -1,7 +1,7 @@
[tox]
minversion = 3.1
minversion = 4.0
skipsdist = True
envlist = linters
envlist = linters, molecule
ignore_basepython_conflict = True
[testenv]
@ -10,7 +10,8 @@ usedevelop = False
commands =
/usr/bin/find . -type f -name "*.pyc" -delete
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 =
COMMON_TESTS_PATH
HOME
@ -27,7 +28,7 @@ allowlist_externals =
bash
setenv =
PYTHONUNBUFFERED=1
TEST_IDEMPOTENCE=false
TEST_IDEMPOTENCE=true
VIRTUAL_ENV={envdir}
WORKING_DIR={toxinidir}
@ -37,47 +38,20 @@ setenv =
ANSIBLE_ROLES_PATH={envdir}
commands =
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}
[molecule]
deps =
{[testenv]deps}
docker
molecule
molecule-plugins[docker]
[testenv:molecule]
# You can use DOCKER_REGISTRY and DOCKER_IMAGE_TAG to switch between
# tested distros. I.e:
# DOCKER_IMAGE_TAG=ubuntu-systemd:jammy tox -e molecule
commands =
molecule test
setenv =
{[testenv]setenv}
[testenv:molecule-bookworm]
deps =
{[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
passenv =
{[testenv]passenv}
DOCKER_REGISTRY
DOCKER_IMAGE_TAG
DOCKER_COMMAND