From ef9d92b31d635ee1fa48278a31a4e8acb4f7715c Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Thu, 19 Jun 2025 08:19:32 +0200 Subject: [PATCH] Test both original and latest dnf versions (#85342) Co-authored-by: Matt Clay --- .azure-pipelines/azure-pipelines.yml | 8 ++++++++ test/integration/targets/dnf-latest/aliases | 4 ++++ .../targets/dnf-latest/tasks/main.yml | 16 ++++++++++++++++ test/integration/targets/dnf-oldest/aliases | 4 ++++ .../targets/dnf-oldest/tasks/main.yml | 13 +++++++++++++ test/integration/targets/dnf/tasks/dnf.yml | 7 +++++++ test/integration/targets/dnf/tasks/main.yml | 9 ++++----- test/integration/targets/dnf/tasks/repo.yml | 3 ++- .../commands/sanity/integration_aliases.py | 11 +++++++++++ 9 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 test/integration/targets/dnf-latest/aliases create mode 100644 test/integration/targets/dnf-latest/tasks/main.yml create mode 100644 test/integration/targets/dnf-oldest/aliases create mode 100644 test/integration/targets/dnf-oldest/tasks/main.yml diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml index 56fa471e75b..056dfbeb68b 100644 --- a/.azure-pipelines/azure-pipelines.yml +++ b/.azure-pipelines/azure-pipelines.yml @@ -167,6 +167,14 @@ stages: - 3 - 4 - 5 + - template: templates/matrix.yml # context/target (dnf-oldest, dnf-latest) + parameters: + testFormat: linux/{0} + targets: + - name: Fedora 41 + test: fedora41 + groups: + - 7 - stage: Galaxy dependsOn: [] jobs: diff --git a/test/integration/targets/dnf-latest/aliases b/test/integration/targets/dnf-latest/aliases new file mode 100644 index 00000000000..4375ade0181 --- /dev/null +++ b/test/integration/targets/dnf-latest/aliases @@ -0,0 +1,4 @@ +context/target +destructive +shippable/posix/group7 +needs/target/dnf diff --git a/test/integration/targets/dnf-latest/tasks/main.yml b/test/integration/targets/dnf-latest/tasks/main.yml new file mode 100644 index 00000000000..8cc85e78316 --- /dev/null +++ b/test/integration/targets/dnf-latest/tasks/main.yml @@ -0,0 +1,16 @@ +- when: ansible_distribution == "Fedora" + block: + - command: "dnf install -y 'dnf-command(copr)'" + + - name: Test against dnf5 nightly build to detect any issues early + command: dnf copr enable -y rpmsoftwaremanagement/dnf-nightly + + - name: Run DNF tests + include_role: + name: dnf + vars: + # Since dnf-latest is the only dnf target that installs the latest version + # test the 'auto_install_module_deps' feature here. + test_auto_install: true + always: + - command: dnf copr disable -y rpmsoftwaremanagement/dnf-nightly diff --git a/test/integration/targets/dnf-oldest/aliases b/test/integration/targets/dnf-oldest/aliases new file mode 100644 index 00000000000..4375ade0181 --- /dev/null +++ b/test/integration/targets/dnf-oldest/aliases @@ -0,0 +1,4 @@ +context/target +destructive +shippable/posix/group7 +needs/target/dnf diff --git a/test/integration/targets/dnf-oldest/tasks/main.yml b/test/integration/targets/dnf-oldest/tasks/main.yml new file mode 100644 index 00000000000..5a2eb8f6fae --- /dev/null +++ b/test/integration/targets/dnf-oldest/tasks/main.yml @@ -0,0 +1,13 @@ +- when: ansible_distribution == "Fedora" + block: + - name: Ensure libdnf is not installed + command: dnf remove -y python3-libdnf5 + + - name: Downgrade dnf to the original version + command: dnf install -y --disable-repo=* --enable-repo=fedora python3-libdnf5 + + - name: Run DNF tests + include_role: + name: dnf + vars: + test_auto_install: false diff --git a/test/integration/targets/dnf/tasks/dnf.yml b/test/integration/targets/dnf/tasks/dnf.yml index 77cd0c3720d..6855709f016 100644 --- a/test/integration/targets/dnf/tasks/dnf.yml +++ b/test/integration/targets/dnf/tasks/dnf.yml @@ -16,6 +16,13 @@ - "not dnf_result.failed | default(False)" - "rpm_result.rc == 1" +# NOTE Now that the dnf module executed, libdnf is installed even for the case +# when testing 'auto_install_module_deps: false' for dnf5 +# and we can print libdnf version we test against for debugging purposes. +- name: libdnf version being tested + debug: + msg: "{{ lookup('pipe', 'rpm -q ' ~ ('python3-libdnf5' if dnf5 else 'python3-libdnf')) }}" + # UNINSTALL AGAIN - name: uninstall sos dnf: diff --git a/test/integration/targets/dnf/tasks/main.yml b/test/integration/targets/dnf/tasks/main.yml index 37f597242df..e965706bff1 100644 --- a/test/integration/targets/dnf/tasks/main.yml +++ b/test/integration/targets/dnf/tasks/main.yml @@ -1,15 +1,14 @@ # (c) 2014, James Tanner +# Copyright: Contributors to the Ansible project # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) - set_fact: dnf5: "{{ (ansible_distribution == 'RedHat' and ansible_distribution_major_version | int > 10) or ansible_distribution == 'Fedora' }}" -- when: dnf5 +- when: + - dnf5 + - test_auto_install | default(false) # NOTE ensure one of dnf, dnf-oldest or dnf-latest sets test_auto_install block: - - command: "dnf install -y 'dnf-command(copr)'" - - name: Test against dnf5 nightly build to detect any issues early - command: dnf copr enable -y rpmsoftwaremanagement/dnf-nightly - - name: Ensure module deps are not installed command: dnf remove -y python3-libdnf5 diff --git a/test/integration/targets/dnf/tasks/repo.yml b/test/integration/targets/dnf/tasks/repo.yml index 302b01eee92..8240b580f38 100644 --- a/test/integration/targets/dnf/tasks/repo.yml +++ b/test/integration/targets/dnf/tasks/repo.yml @@ -651,7 +651,8 @@ - assert: that: - r is failed - - r.msg is contains("Couldn't open file") + # account for two different messages depending on the libdnf version + - r.msg is contains("Couldn't open file") or r.msg is contains("Failed to download metadata") always: - file: name: /etc/yum.repos.d/{{ repo_name }}.repo diff --git a/test/lib/ansible_test/_internal/commands/sanity/integration_aliases.py b/test/lib/ansible_test/_internal/commands/sanity/integration_aliases.py index 96381280f9e..f6543733574 100644 --- a/test/lib/ansible_test/_internal/commands/sanity/integration_aliases.py +++ b/test/lib/ansible_test/_internal/commands/sanity/integration_aliases.py @@ -181,6 +181,8 @@ class IntegrationAliasesTest(SanitySingleVersion): group_numbers = self.ci_test_groups.get(name, None) if group_numbers: + group_numbers = [num for num in group_numbers if num not in (6, 7)] # HACK: ignore special groups 6 and 7 + if min(group_numbers) != 1: display.warning('Min test group "%s" in %s is %d instead of 1.' % (name, self.CI_YML, min(group_numbers)), unique=True) @@ -291,6 +293,9 @@ class IntegrationAliasesTest(SanitySingleVersion): if target.name == 'ansible-test-container': continue # special test target which uses group 6 -- nothing else should be in that group + if target.name in ('dnf-oldest', 'dnf-latest'): + continue # special test targets which use group 7 -- nothing else should be in that group + if f'{self.TEST_ALIAS_PREFIX}/posix/' not in target.aliases: continue @@ -351,6 +356,12 @@ class IntegrationAliasesTest(SanitySingleVersion): if path == 'test/integration/targets/ansible-test-container': continue # special test target which uses group 6 -- nothing else should be in that group + if path in ( + 'test/integration/targets/dnf-oldest', + 'test/integration/targets/dnf-latest', + ): + continue # special test targets which use group 7 -- nothing else should be in that group + messages.append(SanityMessage(unassigned_message, '%s/aliases' % path)) for path in conflicting_paths: