From ae303b9aaec4054bb05e5fb2f071b61b79b0156e Mon Sep 17 00:00:00 2001 From: Jiri Podivin Date: Wed, 12 Jan 2022 12:31:20 +0100 Subject: [PATCH] Molecule test restoration Setting molecule to use centos8 stream instead of UBI8. Changing nodeset of the CI jobs to centos8 stream. Also reenables the end-of-file-fixer and simplifies testenvs Signed-off-by: Jiri Podivin Change-Id: I9da5b306d59e1aab3b9fd9d9db7294b1c69655be --- .config/molecule/Dockerfile | 12 ++++++----- .config/molecule/config.yml | 18 ++++++++-------- .zuul.yaml | 6 +++--- LICENSE | 1 - playbooks/molecule/pre.yml | 7 +++++++ scripts/bindep-install | 2 +- test-requirements.txt | 1 + tests/hosts.ini | 2 +- tox.ini | 21 +++++++++++++------ .../molecule/default/molecule.yml | 8 +++---- .../molecule/docker/molecule.yml | 8 +++---- .../molecule/systemd/molecule.yml | 8 +++---- 12 files changed, 56 insertions(+), 38 deletions(-) diff --git a/.config/molecule/Dockerfile b/.config/molecule/Dockerfile index 5986f3b..a25d5e0 100644 --- a/.config/molecule/Dockerfile +++ b/.config/molecule/Dockerfile @@ -21,15 +21,17 @@ FROM {{ item.registry.url }}/{{ item.image }} FROM {{ item.image }} {% endif %} -RUN dnf makecache && dnf install -y sudo python*-devel python*-dnf bash {{ item.pkg_extras | default('') }} -# TODO(gchamoul): find a better to get always the latest version of those rpms -# below from the centos mirror -RUN dnf install -y http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/centos-gpg-keys-8-2.el8.noarch.rpm -RUN dnf install -y http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/centos-linux-repos-8-2.el8.noarch.rpm && dnf install -y epel-release && dnf clean all +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 sudo python*-devel python*-dnf bash epel-release {{ 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"] diff --git a/.config/molecule/config.yml b/.config/molecule/config.yml index 388fa26..5909f45 100644 --- a/.config/molecule/config.yml +++ b/.config/molecule/config.yml @@ -12,9 +12,9 @@ # you will have to redefine them completely in your molecule.yml (at the role # level) and add your extra configuration! # -# For instance, if you need to add an extra package in your ubi8 container, you -# will have to add the entire "platforms" key into your molecule.yml file and -# add your package name in the pkg_extras key. +# For instance, if you need to add an extra package in your CentOS 8 Stream +# container, you will have to add the entire "platforms" key into your +# molecule.yml file and add your package name in the pkg_extras key. # # No merge will happen between your molecule.yml and this config.yml # files. That's why you will have to redefine them completely. @@ -25,11 +25,11 @@ driver: log: true platforms: - - name: ubi8 - hostname: ubi8 - image: ubi8/ubi-init + - name: centos + hostname: centos + image: centos/centos:stream8 registry: - url: registry.access.redhat.com + url: quay.io dockerfile: ../../../../../.config/molecule/Dockerfile pkg_extras: python*-setuptools python*-pyyaml volumes: @@ -47,7 +47,7 @@ provisioner: hosts: all: hosts: - ubi8: + centos: ansible_python_interpreter: /usr/bin/python3 log: true options: @@ -67,4 +67,4 @@ scenario: - destroy verifier: - name: testinfra + name: ansible diff --git a/.zuul.yaml b/.zuul.yaml index a28e97a..8908a80 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -19,7 +19,7 @@ - job: name: validations-common-reqcheck - nodeset: centos-8 + nodeset: centos-8-stream parent: base run: playbooks/reqcheck.yaml timeout: 1600 @@ -30,7 +30,7 @@ - ^requirements.txt$ - job: name: validations-common-coverchange - nodeset: centos-8 + nodeset: centos-8-stream parent: base run: playbooks/coverchange.yaml timeout: 1600 @@ -43,7 +43,7 @@ - job: description: Base validations-common job name: validations-common-centos-8-base - nodeset: centos-8 + nodeset: centos-8-stream parent: base success-url: "reports.html" failure-url: "reports.html" diff --git a/LICENSE b/LICENSE index 68c771a..67db858 100644 --- a/LICENSE +++ b/LICENSE @@ -173,4 +173,3 @@ defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. - diff --git a/playbooks/molecule/pre.yml b/playbooks/molecule/pre.yml index bf9a57e..152fbc8 100644 --- a/playbooks/molecule/pre.yml +++ b/playbooks/molecule/pre.yml @@ -25,6 +25,13 @@ virtualenv_command: "{{ ensure_pip_virtualenv_command }}" virtualenv_site_packages: true + - name: Set containers module to 3.0 + become: true + shell: | + dnf module disable container-tools:rhel8 -y + dnf module enable container-tools:3.0 -y + dnf clean metadata + - name: Run bindep shell: |- . {{ ansible_user_dir }}/test-python/bin/activate diff --git a/scripts/bindep-install b/scripts/bindep-install index 5cc239a..b9f1233 100755 --- a/scripts/bindep-install +++ b/scripts/bindep-install @@ -42,4 +42,4 @@ if [[ ${#BINDEP_PKGS} > 0 ]]; then sudo "${RHT_PKG_MGR}" install -y ${BINDEP_PKGS} ;; esac -fi \ No newline at end of file +fi diff --git a/test-requirements.txt b/test-requirements.txt index 4826c4d..53b91e5 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,6 +2,7 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. +ansible-core<2.12 # GPLv3+ coverage!=4.4,>=4.0 # Apache-2.0 oslotest>=3.2.0 # Apache-2.0 stestr>=3.0.1 # Apache-2.0 diff --git a/tests/hosts.ini b/tests/hosts.ini index 8365a58..2828052 100644 --- a/tests/hosts.ini +++ b/tests/hosts.ini @@ -1 +1 @@ -test ansible_connection=local ansible_host=localhost \ No newline at end of file +test ansible_connection=local ansible_host=localhost diff --git a/tox.ini b/tox.ini index b5d1fe3..9f9efcb 100644 --- a/tox.ini +++ b/tox.ini @@ -39,7 +39,6 @@ deps = -r {toxinidir}/requirements.txt -r {toxinidir}/test-requirements.txt -r {toxinidir}/doc/requirements.txt - ansible-core<2.12 # GPLv3+ whitelist_externals = bash ansible-galaxy @@ -59,7 +58,6 @@ deps = -c {env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/train} -r {toxinidir}/requirements.txt -r {toxinidir}/test-requirements.txt - ansible-core<2.12 whitelist_externals = bash cp @@ -90,7 +88,6 @@ deps = commands = bash -c "ANSIBLE_ROLES_PATH='{toxinidir}/validations_common/roles'" bash -c "ANSIBLE_LIBRARY='{toxinidir}/validations_common/library'" - ansible-galaxy install -fr {toxinidir}/ansible-collections-requirements.yml python -m pre_commit run ansible-lint -a [testenv:yamllint] @@ -117,12 +114,19 @@ deps = {[testenv:linters]deps} commands = python -m pre_commit run check-executables-have-shebangs -a +[testenv:end-of-file] +envdir = {toxworkdir}/linters +deps = {[testenv:linters]deps} +commands = + python -m pre_commit run end-of-file-fixer -a + [testenv:linters] +commands_pre = + ansible-galaxy install -fr {toxinidir}/ansible-collections-requirements.yml deps = -c {env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} -r {toxinidir}/requirements.txt -r {toxinidir}/test-requirements.txt - ansible-core<2.12 # GPLv3+ commands = python '{toxinidir}/tools/validate-files.py' . {[testenv:ansible-lint]commands} @@ -130,6 +134,7 @@ commands = {[testenv:bashate]commands} {[testenv:whitespace]commands} {[testenv:shebangs]commands} + {[testenv:end-of-file]commands} [testenv:releasenotes] deps = -r {toxinidir}/doc/requirements.txt @@ -160,12 +165,12 @@ commands= sphinx-build -a -E -W -d doc/build/doctrees --keep-going -b html doc/source doc/build/html -T doc8 doc -[testenv:pdf-docs] +[pdf-docs] whitelist_externals = make description = Build PDF documentation. envdir = {toxworkdir}/docs -deps = {[testenv:docs]deps} +deps = {[docs]deps} commands = sphinx-build -b latex doc/source doc/build/pdf make -C doc/build/pdf @@ -178,5 +183,9 @@ ignore = D001 [ansible] description = Used as base for all tox-ansible environments scenario_format = $parent-$nondefault_name +deps = + -c {env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} + -r {toxinidir}/requirements.txt + -r {toxinidir}/test-requirements.txt molecule_opts = --debug diff --git a/validations_common/roles/service_status/molecule/default/molecule.yml b/validations_common/roles/service_status/molecule/default/molecule.yml index 0af5cd2..59e2729 100644 --- a/validations_common/roles/service_status/molecule/default/molecule.yml +++ b/validations_common/roles/service_status/molecule/default/molecule.yml @@ -3,11 +3,11 @@ # To override default values, please take a look at the config.yml. platforms: - - name: ubi8 - hostname: ubi8 - image: ubi8/ubi-init + - name: centos8 + hostname: centos8 + image: centos/centos:stream8 registry: - url: registry.access.redhat.com + url: quay.io dockerfile: ../../../../../.config/molecule/Dockerfile command: /sbin/init pkg_extras: python*-setuptools python*-pyyaml diff --git a/validations_common/roles/service_status/molecule/docker/molecule.yml b/validations_common/roles/service_status/molecule/docker/molecule.yml index 5887b30..f3ed0ec 100644 --- a/validations_common/roles/service_status/molecule/docker/molecule.yml +++ b/validations_common/roles/service_status/molecule/docker/molecule.yml @@ -6,11 +6,11 @@ driver: name: docker platforms: - - name: ubi8 - hostname: ubi8 - image: ubi8/ubi-init + - name: centos8 + hostname: centos8 + image: centos/centos:stream8 registry: - url: registry.access.redhat.com + url: quay.io dockerfile: ../../../../../.config/molecule/Dockerfile pkg_extras: python*-setuptools python*-pyyaml python*-libselinux command: /sbin/init diff --git a/validations_common/roles/service_status/molecule/systemd/molecule.yml b/validations_common/roles/service_status/molecule/systemd/molecule.yml index 1a42615..537c9e5 100644 --- a/validations_common/roles/service_status/molecule/systemd/molecule.yml +++ b/validations_common/roles/service_status/molecule/systemd/molecule.yml @@ -3,11 +3,11 @@ # To override default values, please take a look at the config.yml. platforms: - - name: ubi8 - hostname: ubi8 - image: ubi8/ubi-init + - name: centos8 + hostname: centos8 + image: centos/centos:stream8 registry: - url: registry.access.redhat.com + url: quay.io dockerfile: ../../../../../.config/molecule/Dockerfile pkg_extras: python*-setuptools python*-pyyaml volumes: