Run molecule tests locally without zuul

Adds the ability to execute molecule tests locally without relying (or
trying to fake) zuul infrastructure.

Uses environment variables to configure config_podman.yml, with default
values that can be sourced from ansible-test-env-podman.rc.

Updates the test_deps role to work without requiring the existence of a
zuul mirror file.

Updates documentation.

Change-Id: Iedcdb48ded439a2a41ace74a983e9d6eed398a94
Signed-off-by: James Slagle <jslagle@redhat.com>
This commit is contained in:
James Slagle 2022-09-07 17:32:51 -04:00
parent 2381a7c3b2
commit edc3541a46
4 changed files with 35 additions and 20 deletions

View File

@ -7,17 +7,13 @@ log: true
platforms:
- name: centos
hostname: centos
image: ubi9/ubi-init
image: ${TRIPLEO_ANSIBLE_MOLECULE_IMAGE:-"ubi9/ubi-init"}
registry:
url: registry.access.redhat.com
url: ${TRIPLEO_ANSIBLE_MOLECULE_REGISTRY:-"registry.access.redhat.com"}
dockerfile: Dockerfile.j2
pkg_extras: python*setuptools
command: /sbin/init
volumes:
- /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro
- /etc/pki/rpm-gpg:/etc/pki/rpm-gpg:O
- /opt/yum.repos.d:/etc/yum.repos.d:O
- /etc/dnf/vars:/etc/dnf/vars:O
command: ${TRIPLEO_ANSIBLE_MOLECULE_COMMAND:-"/sbin/init"}
volumes: ${TRIPLEO_ANSIBLE_MOLECULE_VOLUMES:-['/etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro','/etc/pki/rpm-gpg:/etc/pki/rpm-gpg:O','/opt/yum.repos.d:/etc/yum.repos.d:O','/etc/dnf/vars:/etc/dnf/vars:O']}
privileged: true
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"

View File

@ -0,0 +1,4 @@
export TRIPLEO_ANSIBLE_MOLECULE_COMMAND="/bin/sleep infinity"
export TRIPLEO_ANSIBLE_MOLECULE_VOLUMES="[]"
export TRIPLEO_ANSIBLE_MOLECULE_IMAGE="centos/centos:stream9"
export TRIPLEO_ANSIBLE_MOLECULE_REGISTRY="quay.io"

View File

@ -133,9 +133,19 @@ file from the project root, and then execute the following commands.
.. code-block:: console
(test-python) $ source ansible-test-env.rc
(test-python) $ cd tripleo_ansible/roles/${NEWROLENAME}/
(test-python) $ molecule test --all
(test-python) $ molecule --base-config ../../../.config/molecule/config.yml test --all
To run a test using the `podman` driver, `ansible-test-env-podman.rc` also
needs to be sourced, and specify the `config_podman.yml` molecule config.
.. code-block:: console
(test-python) $ source ansible-test-env.rc
(test-python) $ source ansible-test-env-podman.rc
(test-python) $ cd tripleo_ansible/roles/${NEWROLENAME}/
(test-python) $ molecule --base-config ../../../.config/molecule/config_podman.yml test --all
If a role has more than one scenario, a specific scenario can be
specified on the command line. Running specific scenarios will

View File

@ -48,17 +48,6 @@
- (ansible_facts['os_family'] | lower) == 'redhat'
- mirrors_file.stat.exists | bool
block:
- name: Fetch latest repo version
uri:
url: https://trunk.rdoproject.org/centos{{ ansible_facts['distribution_major_version'] }}/current/delorean.repo
return_content: true
register: tripleo_packages
- name: Create default repo file
copy:
content: "{{ tripleo_packages.content }}"
dest: /etc/yum.repos.d/delorean.repo
- name: Disable ubi host subscription-manager integration
file:
path: /etc/rhsm-host
@ -75,6 +64,22 @@
- ubi-9-baseos
- ubi-9-codeready-builder
- name: tripleo-repos Block
become: true
when:
- (ansible_facts['os_family'] | lower) == 'redhat'
block:
- name: Fetch latest repo version
uri:
url: https://trunk.rdoproject.org/centos{{ ansible_facts['distribution_major_version'] }}/current/delorean.repo
return_content: true
register: tripleo_packages
- name: Create default repo file
copy:
content: "{{ tripleo_packages.content }}"
dest: /etc/yum.repos.d/delorean.repo
- name: Install tripleo-repos package
become: true
package: