Skip to content

test: refactor wireless tests into single setup and cleanup#877

Merged
richm merged 1 commit into
linux-system-roles:mainfrom
richm:test-refactor-wireless-tests
Jun 9, 2026
Merged

test: refactor wireless tests into single setup and cleanup#877
richm merged 1 commit into
linux-system-roles:mainfrom
richm:test-refactor-wireless-tests

Conversation

@richm

@richm richm commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

The wireless test setup/cleanup had a lot of duplicated code scattered
among a few task files. This unifies the setup and cleanup code and
gets rid of redundant files.

Signed-off-by: Rich Megginson rmeggins@redhat.com

Summary by CodeRabbit

  • Tests

    • Consolidated wireless and 802.1x test setup into a single mock Wi‑Fi workflow, removed legacy per-mode setup flows, and expanded cleanup to remove additional network, hostapd, and certificate artifacts.
    • Updated test plays to skip hostapd-based scenarios on RHEL7.
  • Chores

    • Simplified test gating logic to allow wireless and 802.1x tests on non-RHEL systems or on RHEL when major version > 7.

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Consolidates mock Wi‑Fi setup into a parameterized setup_mock_wifi.yml, expands cleanup in cleanup_mock_wifi.yml, rewires playbooks to use these tasks, removes legacy mode-specific task files, and simplifies NM-only test gating conditions.

Changes

Mock WiFi Test Infrastructure Consolidation

Layer / File(s) Summary
Parameterized Mock WiFi Setup Task
tests/tasks/setup_mock_wifi.yml
setup_mock_wifi.yml is refactored to accept __mock_wifi_mode and conditionally handle default, OWE, SAE, and wired 802.1x environments: computes cert dirs, gates hostapd install, handles distro-specific mac80211_hwsim install/load, writes per-mode hostapd configs, creates wired veth/ns1 for 802.1x, and splits startup paths.
Expanded Mock WiFi Cleanup Task
tests/tasks/cleanup_mock_wifi.yml
cleanup_mock_wifi.yml is extended to remove wired 802.1x namespace/interfaces, unload mac80211_hwsim, kill hostapd, remove hostapd config files, delete server certificate directory, and purge test certificate files; many tasks suppress failures.
Playbook Wiring to Parameterized Setup
tests/playbooks/tests_802_1x.yml, tests/playbooks/tests_wireless.yml, tests/playbooks/tests_wireless_wpa3_owe.yml, tests/playbooks/tests_wireless_wpa3_sae.yml
Playbooks now include tasks/setup_mock_wifi.yml with appropriate __mock_wifi_mode values, remove inline cert-copy steps, and switch cleanup includes to tasks/cleanup_mock_wifi.yml. SAE play now forces connection state: up.
Remove Legacy Task Files
tests/tasks/setup_mock_wifi_wpa3_sae.yml, tests/tasks/setup_mock_wifi_wpa3_owe.yml, tests/tasks/setup_802.1x.yml, tests/tasks/setup_802_1x_server.yml, tests/tasks/cleanup_802_1x_server.yml, tests/tasks/start_mock_wifi.yml
Legacy, mode-specific setup/start/cleanup task files were removed; their functionality is consolidated into the parameterized setup and cleanup tasks.
Simplify NM-only Test Gating Conditions
tests/ensure_provider_tests.py, tests/tests_802_1x_nm.yml, tests/tests_802_1x_updated_nm.yml, tests/tests_wireless_nm.yml, tests/tests_wireless_wpa3_owe_nm.yml, tests/tests_wireless_wpa3_sae_nm.yml
Generated and hand-authored when conditions for importing wireless and 802.1x playbooks were simplified to `not __network_is_rhel or (__network_distro_major_version
🚥 Pre-merge checks | ✅ 4 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is incomplete and does not follow the required template structure with Enhancement, Reason, Result, and Issue Tracker Tickets sections. Restructure the description to match the template format with clear Enhancement, Reason, Result, and Issue Tracker Tickets sections.
Description Format ⚠️ Warning PR description lacks required template sections: missing "Enhancement:", "Reason:", and "Result:" headers as specified in .github/pull_request_template.md. Reformat description to include the required sections: Enhancement:, Reason:, and Result: (with optional Issue Tracker Tickets).
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title follows Conventional Commits format with the correct type and descriptive message.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 43.19%. Comparing base (1b57520) to head (2cf86d5).
⚠️ Report is 103 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #877      +/-   ##
==========================================
+ Coverage   43.11%   43.19%   +0.07%     
==========================================
  Files          12       13       +1     
  Lines        3124     3172      +48     
==========================================
+ Hits         1347     1370      +23     
- Misses       1777     1802      +25     

☔ View full report in Codecov by Harness.
📢 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/tasks/setup_mock_wifi.yml`:
- Around line 40-44: The CentOS-specific bootstrap tasks named "Check if can
test on CentOS and setup if possible" (and the later similar block around lines
65-71) should skip when the test harness is in wired 802.1x mode; add a
condition to each block to require "__mock_wifi_mode != '802_1x'" (e.g., include
it in the when: list alongside the existing ansible_facts checks) so the
mac80211_hwsim/mac80211 package bootstrap is not executed for wired tests.
- Around line 244-247: In tests/tasks/setup_mock_wifi.yml update the shell task
that calls "modprobe mac80211_hwsim" to pass the correct module parameter name:
change the conditional that currently emits "radio=2" to "radios=2" (the
conditional tied to __mock_wifi_mode in the same shell line), so the module gets
the simulated radio count properly when __mock_wifi_mode is 'owe' or 'sae'.

In `@tests/tests_802_1x_nm.yml`:
- Around line 35-36: The change was made to the generated YAML
(tests/tests_802_1x_nm.yml) but the generator source still uses the old
conditional for playbooks/tests_802_1x.yml; update the generator rule (not just
the rendered file) so the canonical condition matches the new form
(__network_distro_major_version | int >= 7) in the generator that produces
tests/tests_802_1x_nm.yml — find and modify the rule/templating logic referenced
by tests/ensure_provider_tests.py (the check that expects
playbooks/tests_802_1x.yml) so it emits the updated condition consistently and
regenerate the YAML.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f09a002c-ed91-4014-8441-de29f5f35764

📥 Commits

Reviewing files that changed from the base of the PR and between 3c4717c and 81c4045.

📒 Files selected for processing (16)
  • tests/ensure_provider_tests.py
  • tests/playbooks/tests_802_1x.yml
  • tests/playbooks/tests_wireless.yml
  • tests/playbooks/tests_wireless_wpa3_owe.yml
  • tests/playbooks/tests_wireless_wpa3_sae.yml
  • tests/tasks/cleanup_802_1x_server.yml
  • tests/tasks/cleanup_mock_wifi.yml
  • tests/tasks/setup_802.1x.yml
  • tests/tasks/setup_802_1x_server.yml
  • tests/tasks/setup_mock_wifi.yml
  • tests/tasks/setup_mock_wifi_wpa3_owe.yml
  • tests/tasks/setup_mock_wifi_wpa3_sae.yml
  • tests/tasks/start_mock_wifi.yml
  • tests/tests_802_1x_nm.yml
  • tests/tests_wireless_nm.yml
  • tests/tests_wireless_wpa3_owe_nm.yml
💤 Files with no reviewable changes (7)
  • tests/tasks/start_mock_wifi.yml
  • tests/tasks/setup_mock_wifi_wpa3_sae.yml
  • tests/tasks/setup_802_1x_server.yml
  • tests/tasks/cleanup_802_1x_server.yml
  • tests/tasks/setup_802.1x.yml
  • tests/tasks/setup_mock_wifi_wpa3_owe.yml
  • tests/playbooks/tests_wireless.yml

Comment thread tests/tasks/setup_mock_wifi.yml Outdated
Comment thread tests/tasks/setup_mock_wifi.yml Outdated
Comment thread tests/tests_802_1x_nm.yml Outdated
@richm richm force-pushed the test-refactor-wireless-tests branch from 81c4045 to 8da0a85 Compare June 5, 2026 22:52
@richm

richm commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

[citest]

@richm richm force-pushed the test-refactor-wireless-tests branch from 8da0a85 to f2d6a96 Compare June 6, 2026 00:06
@richm

richm commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

[citest]

The wireless test setup/cleanup had a lot of duplicated code scattered
among a few task files.  This unifies the setup and cleanup code and
gets rid of redundant files.

This also enables all of the wireless tests on CentOS 7 and later,
and RHEL 8 and later.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
@richm richm force-pushed the test-refactor-wireless-tests branch from f2d6a96 to 2cf86d5 Compare June 7, 2026 14:28
@richm

richm commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

[citest]

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/ensure_provider_tests.py (1)

1-11: ⚠️ Potential issue | 🟠 Major

Fix formatting/lint for tests/ensure_provider_tests.py (Black/flake8 don’t pass as requested).

  • python -m black --check fails in this environment: No module named black (use tox -e black,flake8 for the actual check).
  • flake8 fails with multiple E501 line too long violations (e.g., lines 33, 57-61, 92-96, 154-161, 166-175, 180, 184, 204, 208, 210, 217, 242, 261, 292, 306, 321).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/ensure_provider_tests.py` around lines 1 - 11, The test module has
multiple flake8 E501 (line too long) violations and needs formatting; run the
project formatter/linter via the established dev command (tox -e black,flake8)
and fix violations by wrapping long lines to the configured line length (use
implicit string concatenation, parentheses, or split long strings/expressions
into variables), break long list/dict literals across lines, and refactor overly
long assertions or error messages into shorter parts; also ensure imports and
the module docstring remain within line length and re-run the checks until
clean.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@tests/ensure_provider_tests.py`:
- Around line 1-11: The test module has multiple flake8 E501 (line too long)
violations and needs formatting; run the project formatter/linter via the
established dev command (tox -e black,flake8) and fix violations by wrapping
long lines to the configured line length (use implicit string concatenation,
parentheses, or split long strings/expressions into variables), break long
list/dict literals across lines, and refactor overly long assertions or error
messages into shorter parts; also ensure imports and the module docstring remain
within line length and re-run the checks until clean.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1fc9b8a6-1345-44d6-8097-86043d2ce393

📥 Commits

Reviewing files that changed from the base of the PR and between f2d6a96 and 2cf86d5.

📒 Files selected for processing (18)
  • tests/ensure_provider_tests.py
  • tests/playbooks/tests_802_1x.yml
  • tests/playbooks/tests_wireless.yml
  • tests/playbooks/tests_wireless_wpa3_owe.yml
  • tests/playbooks/tests_wireless_wpa3_sae.yml
  • tests/tasks/cleanup_802_1x_server.yml
  • tests/tasks/cleanup_mock_wifi.yml
  • tests/tasks/setup_802.1x.yml
  • tests/tasks/setup_802_1x_server.yml
  • tests/tasks/setup_mock_wifi.yml
  • tests/tasks/setup_mock_wifi_wpa3_owe.yml
  • tests/tasks/setup_mock_wifi_wpa3_sae.yml
  • tests/tasks/start_mock_wifi.yml
  • tests/tests_802_1x_nm.yml
  • tests/tests_802_1x_updated_nm.yml
  • tests/tests_wireless_nm.yml
  • tests/tests_wireless_wpa3_owe_nm.yml
  • tests/tests_wireless_wpa3_sae_nm.yml
💤 Files with no reviewable changes (7)
  • tests/playbooks/tests_wireless.yml
  • tests/tasks/start_mock_wifi.yml
  • tests/tasks/setup_802.1x.yml
  • tests/tasks/setup_mock_wifi_wpa3_sae.yml
  • tests/tasks/setup_802_1x_server.yml
  • tests/tasks/cleanup_802_1x_server.yml
  • tests/tasks/setup_mock_wifi_wpa3_owe.yml
🚧 Files skipped from review as they are similar to previous changes (7)
  • tests/playbooks/tests_wireless_wpa3_owe.yml
  • tests/playbooks/tests_wireless_wpa3_sae.yml
  • tests/tests_wireless_wpa3_sae_nm.yml
  • tests/playbooks/tests_802_1x.yml
  • tests/tests_wireless_wpa3_owe_nm.yml
  • tests/tasks/cleanup_mock_wifi.yml
  • tests/tasks/setup_mock_wifi.yml

@richm

richm commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

[citest_bad]

@richm richm requested a review from spetrosi June 8, 2026 13:10
@richm richm merged commit 87b9e46 into linux-system-roles:main Jun 9, 2026
48 of 49 checks passed
@richm richm deleted the test-refactor-wireless-tests branch June 9, 2026 12:38
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.

2 participants