From be873a116c53dab2aa3582515987e48cf371a8dc Mon Sep 17 00:00:00 2001 From: "Gael Chamoulaud (Strider)" Date: Mon, 20 Dec 2021 16:17:30 +0100 Subject: [PATCH] fix(molecule): Add ability to run molecule on Fedora This patch adds the support for running the molecule tests on Fedora through the molecule command. This patch also updates the developer's guide with all the instructions to do so. JIRA: #VALFRWK-703 Signed-off-by: Gael Chamoulaud (Strider) Change-Id: I6852fe440c62348fcf795dda44403a3ec68a7e19 (cherry picked from commit 17c3c907b7c4d605a1022491ee0a52c1b3c55734) --- bindep.txt | 27 ++++------ doc/source/contributing/developer_guide.rst | 59 ++++++++++++++++----- 2 files changed, 58 insertions(+), 28 deletions(-) diff --git a/bindep.txt b/bindep.txt index b54bdf974..aaaaad96f 100644 --- a/bindep.txt +++ b/bindep.txt @@ -18,27 +18,22 @@ gcc-c++ [platform:rpm] git [platform:rpm] libffi-devel [platform:rpm] openssl-devel [platform:rpm] - -libxml2-dev [platform:dpkg] -libxml2-devel [platform:rpm] -libxslt-devel [platform:rpm] -libxslt1-dev [platform:dpkg] - -# RH Mechanisms -python-rhsm-certificates [platform: redhat] - podman [platform:rpm] -python-devel [platform:rpm !platform:rhel-8 !platform:centos-8] +python-devel [platform:rpm !platform:rhel-8 !platform:centos-8 !platform:fedora] python3-devel [platform:rpm !platform:rhel-7 !platform:centos-7] -PyYAML [platform:rpm !platform:rhel-8 !platform:centos-8] +PyYAML [platform:rpm !platform:rhel-8 !platform:centos-8 !platform:fedora] python3-pyyaml [platform:rpm !platform:rhel-7 !platform:centos-7] python3-dnf [platform:rpm !platform:rhel-7 !platform:centos-7] -# For SELinux -libselinux-python [platform:rpm !platform:rhel-8 !platform:centos-8] -libsemanage-python [platform:redhat !platform:rhel-8 !platform:centos-8] -libselinux-python3 [platform:rpm !platform:rhel-7 !platform:centos-7] -libsemanage-python3 [platform:redhat !platform:rhel-7 !platform:centos-7] +# RH Mechanisms +python-rhsm-certificates [platform:redhat] + +# SELinux cent7 +libselinux-python3 [platform:rpm !platform:rhel-8 !platform:centos-8] +libsemanage-python3 [platform:redhat !platform:rhel-8 !platform:centos-8] +# SELinux cent8 +python3-libselinux [platform:rpm !platform:rhel-7 !platform:centos-7] +python3-libsemanage [platform:redhat !platform:rhel-7 !platform:centos-7] # Required for compressing collected log files in CI gzip diff --git a/doc/source/contributing/developer_guide.rst b/doc/source/contributing/developer_guide.rst index 25b5010c1..d5e934855 100644 --- a/doc/source/contributing/developer_guide.rst +++ b/doc/source/contributing/developer_guide.rst @@ -761,6 +761,10 @@ a role with tags. $ export TRIPLEO_JOB_ANSIBLE_ARGS="--skip-tags tag_one,tag_two" $ ./scripts/run-local-test ${ROLENAME} + +Running molecule tests manually +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Role based testing with molecule can be executed directly from within the role directory. @@ -779,9 +783,26 @@ the role directory. .. note:: - Some roles depend on some packages which are available only through the EPEL - repositories. So, please ensure you have installed them on your CentOS 8 host - before running molecule tests. + Each molecule tests are configured to bind mount a read-only volume on the + container where the tests are running: + + .. code-block:: yaml + + volumes: + - /etc/ci/mirror_info.sh:/etc/ci/mirror_info.sh:ro + + It is an OpenStack Zuul requirement for detecting if we are on a CI node. Of + course, when running your molecule test on your workstation, it is going + to fail because you don't have the empty `mirror_info.sh` script in the + `/etc/ci/` directory. You can workaround this by creating it in your + workstation or removing the volume key in the global configuration file for + molecule. + + .. code-block:: console + + $ sudo mkdir -p /etc/ci + $ sudo touch /etc/ci/mirror_info.sh + Before running basic molecule tests, it is recommended to install all @@ -789,22 +810,35 @@ of the python dependencies in a virtual environment. .. code-block:: console - $ python -m virtualenv --system-site-packages "${HOME}/test-python" - $ ${HOME}/test-python/bin/pip install -r requirements.txt \ - -r test-requirements.txt \ - -r molecule-requirements.txt - $ source ${HOME}/test-python/bin/activate + $ sudo dnf install python3 python3-virtualenv + $ python3 -m virtualenv --system-site-packages "${HOME}/test-python" + $ source "${HOME}/test-python/bin/activate" + (test-python) $ python3 -m pip install "pip>=19.1.1" setuptools bindep --upgrade + (test-python) $ scripts/./bindep-install + (test-python) $ python3 -m pip install -r requirements.txt \ + -r test-requirements.txt \ + -r molecule-requirements.txt + (test-python) $ ansible-galaxy install -fr ansible-collections-requirements.txt Now, it is important to install validations-common and tripleo-ansible as dependencies. +.. note:: + + `validation-common` contains Ansible Custom modules needed by + `tripleo-validations` roles. That's the reason why we will need to clone it + beforehand. + + Cloning `tripleo-ansible` project is only necessary in order to + run the `molecule` test(s) for the `image_serve` role. Otherwise, you won't + probably need it. + + .. code-block:: console $ cd tripleo-validations/ - $ for REPO in validations-common tripleo-ansible; do - git clone https://opendev.org/openstack/${REPO} roles/roles.galaxy/${REPO} - done + $ for REPO in validations-common tripleo-ansible; do git clone https://opendev.org/openstack/${REPO} roles/roles.galaxy/${REPO}; done To run a basic molecule test, simply source the `ansible-test-env.rc` @@ -812,6 +846,7 @@ file from the project root, and then execute the following commands. .. code-block:: console + (test-python) $ source ansible-test-env.rc (test-python) $ cd roles/${NEWROLENAME}/ (test-python) $ molecule test --all @@ -823,7 +858,7 @@ the `--scenario-name` flag with the name of the desired scenario. .. code-block:: console - (test-python) $ cd tripleo-validations/roles/${NEWROLENAME}/ + (test-python) $ cd roles/${NEWROLENAME}/ (test-python) $ molecule test --scenario-name ${EXTRA_SCENARIO_NAME}