Skip to content

tests: Assert ethernet profile and device state#793

Merged
martinpitt merged 2 commits intolinux-system-roles:mainfrom
martinpitt:fixes
Jul 8, 2025
Merged

tests: Assert ethernet profile and device state#793
martinpitt merged 2 commits intolinux-system-roles:mainfrom
martinpitt:fixes

Conversation

@martinpitt
Copy link
Copy Markdown
Contributor

@martinpitt martinpitt commented Jun 26, 2025

Implement the tests_ethernet FIXMEs for actually validating the nmcli state and generated on-disk profiles. Do the latter separately in anticipation of future support for offline (bootc build) mode.

This needs some conditionals, as NetworkManager before RHEL 9 uses the initscripts config backend.

Summary by Sourcery

Enhance the Ethernet test suite to assert actual NetworkManager and initscripts profile settings and interface status, and clean up the 802.1x capath test by pruning outdated NVR checks and streamlining its assertion logic

Tests:

  • Add assertions to tests_ethernet to validate on-disk NM connection profiles and interface state via nmcli
  • Introduce conditional handling for initscripts backend by slurping and asserting ifcfg files on RHEL <9
  • Remove obsolete NetworkManager NVR entries and simplify assertion logic in test_802.1x_capath to use direct failure equality

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Jun 26, 2025

Reviewer's Guide

This PR implements actual on-disk and runtime validation for Ethernet profiles in the tests_ethernet playbook—using conditional slurp and assert tasks for both NetworkManager and initscripts backends—and streamlines the 802.1x test by replacing a complex boolean assertion with a simple equality check and pruning outdated NM version entries.

File-Level Changes

Change Details Files
Add runtime and on-disk validation for Ethernet profiles
  • Slurp and assert NM connection file settings for NM on RHEL 9+
  • Assert NM connection status via nmcli output
  • Slurp and assert initscripts connection file settings for older distributions
tests/playbooks/tests_ethernet.yml
Simplify 802.1x test failure assertion and prune version list
  • Remove obsolete NetworkManager NVR entries from ignore list
  • Replace complex boolean expression with direct equality check
tests/tasks/test_802.1x_capath.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@martinpitt
Copy link
Copy Markdown
Contributor Author

[citest]

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 43.25%. Comparing base (1b57520) to head (b752620).
Report is 30 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #793      +/-   ##
==========================================
+ Coverage   43.11%   43.25%   +0.13%     
==========================================
  Files          12       12              
  Lines        3124     3121       -3     
==========================================
+ Hits         1347     1350       +3     
+ Misses       1777     1771       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@martinpitt
Copy link
Copy Markdown
Contributor Author

martinpitt commented Jun 26, 2025

My new test passes everywhere 🎉

The F42 failures are known, due to "Conditionals must have a boolean result" and other Ansible 2.19 problems. I'll go through and fix at least some of them.

The two C10 failures are the same as in #792. ("connection failed while waiting: connection not activated: no-secrets"). This is some OpenSSL problem:

Jun 26 03:37:27 localhost wpa_supplicant[6966]: OpenSSL: tls_connection_ca_cert - Failed to load root certificates error:80000002:system library::No such file or directory
Jun 26 03:37:27 localhost wpa_supplicant[6966]: OpenSSL: pending error: error:10000080:BIO routines::no such file
Jun 26 03:37:27 localhost wpa_supplicant[6966]: OpenSSL: pending error: error:05880020:x509 certificate routines::BIO lib
Jun 26 03:37:27 localhost wpa_supplicant[6966]: OpenSSL: tls_load_ca_der - Failed load CA in DER format error:80000002:system library::No such file or directory
Jun 26 03:37:27 localhost wpa_supplicant[6966]: OpenSSL: pending error: error:10080002:BIO routines::system lib
Jun 26 03:37:27 localhost wpa_supplicant[6966]: OpenSSL: pending error: error:05880020:x509 certificate routines::BIO lib

ansible-lint failures are due to the new "unique" check. I'll disable it for the time being, let's shave one yak at a time.

However, there is another type of Ansible 2.19 failure:

<<< caused by >>>

'interface' is undefined
Origin: /tmp/collections-Kb5/ansible_collections/fedora/linux_system_roles/tests/network/playbooks/tests_bridge.yml:39:14

37   import_playbook: run_tasks.yml
38   vars:
39     profile: "{{ interface }}"
                ^ column 14

The network tests are written in a really weird way where pretty much every step that should be a task is its own playbook. However, the top does

- name: Test configuring bridges
  hosts: all
  tasks:
    - name: Define vars
      set_fact:
        interface: "LSR-TST-br31"
        cloned_mac: "12:23:34:45:56:70"

so shouldn't that fact be available across playbooks, as documented? Maybe that's not true any more for jinja expansion? But then why does it only fail in line 57, and not already before, when it does the setup and role invocation (which also use {{ interface }}) ? Apparently that cannot be used any more with import_playbook:

@martinpitt martinpitt force-pushed the fixes branch 3 times, most recently from 0b9f5e9 to 2a07fb8 Compare June 26, 2025 08:45
@martinpitt
Copy link
Copy Markdown
Contributor Author

martinpitt commented Jun 26, 2025

This should now fix most of the Ansible 2.19 failures. I still get a failure of tests_default_nm.yml and tests_ethernet_nm.yml due to two unexpected warnings:

[WARNING]: Error loading plugin 'ansible.netcommon.network': No module named 'ansible_collections.ansible.netcommon'
[DEPRECATION WARNING]: Passing warnings to exit_json or fail_json is deprecated. This feature will be removed from ansible-core version 2.23. Use AnsibleModule.warn instead.

That's something else, and I'll ignore that for this round -- this needs an adult.

@martinpitt martinpitt changed the title tests: Assert ethernet profile and device state tests: Assert ethernet profile and device state; fix with Ansible 2.19; fix ansible-lint Jun 26, 2025
@martinpitt
Copy link
Copy Markdown
Contributor Author

[citest]

Comment thread .ansible-lint Outdated
@martinpitt

This comment was marked as resolved.

@richm

This comment was marked as resolved.

@richm
Copy link
Copy Markdown
Contributor

richm commented Jun 26, 2025

@martinpitt These ansible 2.19 issues look pretty difficult - I think I need to take a look at these in the next few days - for now, don't worry about them - just focus on the work required for bootc support

@martinpitt martinpitt marked this pull request as ready for review June 26, 2025 12:43
@martinpitt
Copy link
Copy Markdown
Contributor Author

Thanks, the restart helped. So this is ready for review now. It fixes most of the failures, the remaining ones are more difficult. I'll leave them to @richm as discussed. My original goal here was just to land the new integration test checks (they are useful for bootc validation), and then I couldn't resist 😁

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @martinpitt - I've reviewed your changes - here's some feedback:

  • The repeated when: network_provider == 'nm' and ansible_distribution_major_version|int >= 9 checks across tasks could be collapsed into a block with a single conditional or fact to reduce duplication.
  • The slurp + assert patterns for NM and initscripts backends are nearly identical—consider extracting them into a reusable task or role parameterized by backend to DRY up the playbook.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The repeated `when: network_provider == 'nm' and ansible_distribution_major_version|int >= 9` checks across tasks could be collapsed into a block with a single conditional or fact to reduce duplication.
- The slurp + assert patterns for NM and initscripts backends are nearly identical—consider extracting them into a reusable task or role parameterized by backend to DRY up the playbook.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

richm pushed a commit to linux-system-roles/.github that referenced this pull request Jun 26, 2025
@martinpitt
Copy link
Copy Markdown
Contributor Author

@richm: If you prefer, I can take out the big commit tests: Clean up profile cleanup helper playbooks and just submit the first four - they should be obvious. (Or submit them in a new PR)

@richm
Copy link
Copy Markdown
Contributor

richm commented Jun 26, 2025

@richm: If you prefer, I can take out the big commit tests: Clean up profile cleanup helper playbooks and just submit the first four - they should be obvious. (Or submit them in a new PR)

I think it would be better to take them out - some of those changes conflict with #794

@martinpitt martinpitt changed the title tests: Assert ethernet profile and device state; fix with Ansible 2.19; fix ansible-lint tests: Assert ethernet profile and device state; fix ansible-lint Jun 26, 2025
@martinpitt
Copy link
Copy Markdown
Contributor Author

@richm aye, done.

@martinpitt
Copy link
Copy Markdown
Contributor Author

@richm I removed the 'ignore unique ansible-lint' commit as well, as you fixed that differently in your PR.

@martinpitt martinpitt changed the title tests: Assert ethernet profile and device state; fix ansible-lint tests: Assert ethernet profile and device state Jun 26, 2025
@martinpitt
Copy link
Copy Markdown
Contributor Author

[citest]

@martinpitt
Copy link
Copy Markdown
Contributor Author

I rebased after #794. That already applied the same variable fix to test_802.1x_capath than this PR, but I still kept the cleanup.

@martinpitt
Copy link
Copy Markdown
Contributor Author

[citest]

@martinpitt martinpitt removed the request for review from richm July 2, 2025 21:02
@martinpitt martinpitt marked this pull request as draft July 2, 2025 21:02
Simplify the cumbersome assertion.

Drop the ancient Fedora releases from the __NM_capath_ignored_NVRs list.

Signed-off-by: Martin Pitt <mpitt@redhat.com>
Implement the tests_ethernet FIXMEs for actually validating the `nmcli`
state and generated on-disk profiles. Do the latter separately in
anticipation of future support for offline (bootc build) mode.

This needs some conditionals, as NetworkManager before RHEL 9 uses the
initscripts config backend.

Signed-off-by: Martin Pitt <mpitt@redhat.com>
@martinpitt
Copy link
Copy Markdown
Contributor Author

martinpitt commented Jul 3, 2025

Similar CentOS 10 failures as in the most recently landed PR #794, see log from that.

The wireless tests failed on F42 because of data center move outages:

2025-07-03 06:20:11,768 [ERROR] koji: HTTPError: 503 Server Error: Service Unavailable for url: https://koji.fedoraproject.org/kojihub
Updating and loading repositories:
Repositories loaded.
Failed to access RPM "kernel-modules*.rpm": No such file or directory

So I'll just wait for a few days, this PR isn't very urgent.

@martinpitt
Copy link
Copy Markdown
Contributor Author

[citest]

@martinpitt martinpitt marked this pull request as ready for review July 7, 2025 06:32
@martinpitt martinpitt requested review from richm and spetrosi July 7, 2025 06:32
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @martinpitt - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@martinpitt
Copy link
Copy Markdown
Contributor Author

@liangwen12year can you please have a look? Thanks!

when:
- network_provider == 'nm'
# RHEL up to 8 uses initscripts backend
- ansible_distribution_major_version | int >= 9
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary? Isn't when: network_provider == 'nm' sufficient?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No -- even with the NM backend, NM in RHEL < 9 is configured to store the connections in the old initscripts format; in 9 it moved to the NM-specific /etc/NetworkManager/system-connections/ ini files.

@martinpitt martinpitt merged commit 8babd71 into linux-system-roles:main Jul 8, 2025
44 of 49 checks passed
@martinpitt martinpitt deleted the fixes branch July 8, 2025 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants