Skip to content

[quality] test: unit coverage for offline_boot_steps.py, sudo_rs_steps.py, bctl_steps.py, update_failure_steps.py - #768

Merged
castrojo merged 1 commit into
mainfrom
quality/test-uncovered-behave-step-modules
Sep 6, 2026
Merged

castrojo merged 1 commit into
mainfrom
quality/test-uncovered-behave-step-modules

Conversation

@kubestellar-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds pytest unit coverage for the four behave step modules in this repo that had no tests/unit/ counterpart. Claimed ground, exactly:

New test file Module under test Functions covered
tests/unit/test_offline_boot_steps.py tests/smoke/features/steps/offline_boot_steps.py _run_host, nm_wait_online_not_before_graphical, uupd_timer_enabled_or_absent, no_uupd_error_journal_entries, drop_default_route, restore_default_route, boot_with_interfaces_down
tests/unit/test_sudo_rs_steps.py tests/smoke/features/steps/sudo_rs_steps.py sudo_is_setuid_root_4755, sudo_n_id_u_returns_0, sudo_preserve_env_check, sudo_pam_includes_system_auth, sudoedit_binary_check
tests/unit/test_bctl_steps.py tests/developer/features/steps/bctl_steps.py _terminal_widget, _terminal_delta, _wait_for_command_result, run_bctl_command_in_ptyxis, bctl_command_output_includes, bctl_command_exits_with_status_zero, bctl_update_check_exits_with_status_zero_or_one
tests/unit/test_update_failure_steps.py tests/lifecycle/features/steps/update_failure_steps.py _parse_bootc_status, _skip, bootc_rollback_matches_original, force_bootc_rollback_and_reboot, and the four @pending greenboot/corrupted-digest stubs

83 new tests. Line coverage for those four modules: 0% -> 99% (only the reboot-disconnect except body is unreached).

Each test file stubs behave, dogtail.rawinput, qecore.common_steps and tests.shared.ssh_steps in sys.modules, following the existing tests/unit/test_xwayland_steps.py and tests/unit/test_lifecycle_steps.py import-helper pattern. No VM, SSH transport or desktop session is required.

Scope / disjointness

Test-only change. Adds four new files, modifies nothing. No Justfile, workflow or production-code edits — pytest already auto-discovers tests/unit/.

Verified disjoint from every open testsuite PR:

Verification

python3 -m pytest tests/unit/ -q
1407 passed in 140.92s

Full existing suite still green — the sys.modules stubbing does not leak into other unit tests.

Related Issue

Refs #767 (CI gate script coverage tracker) — this PR covers behave step modules, not the CI gate scripts, so the tracker stays open.


Filed by quality agent (hold-gated mode). Human review required. Do not merge without review; hold label must stay.

— hive: agent=quality backend=copilot model=claude-opus-5

Adds pytest unit coverage for the four behave step modules in this repo
that had no corresponding tests/unit/ file:

- tests/smoke/features/steps/offline_boot_steps.py
- tests/smoke/features/steps/sudo_rs_steps.py
- tests/developer/features/steps/bctl_steps.py
- tests/lifecycle/features/steps/update_failure_steps.py

Each new test file stubs behave, dogtail, qecore and the SSH transport in
sys.modules so no VM or desktop session is required, following the existing
tests/unit/test_xwayland_steps.py and test_lifecycle_steps.py pattern.

Line coverage for the four modules goes from 0% to 99%.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: sec-check[bot] <sec-check[bot]@users.noreply.github.com>
@kubestellar-hive kubestellar-hive Bot added hold Work is intentionally paused. quality Code quality or test-coverage work. testing Test authoring or test infrastructure. agent/quality Filed or owned by the quality agent. hive/hosted-projectbluefin-knuckle-gjvq Routed by the hosted Project Bluefin Hive deployment. labels Aug 29, 2026
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@hanthor hanthor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

83 tests across 4 new files for previously-uncovered step modules; spot-checked against real assertion text, exercises real branches. CI green (1407 passed).


Generated by Claude Code

@castrojo castrojo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved by @castrojo for Hive auto-merge on green CI.

@castrojo
castrojo added this pull request to the merge queue Sep 6, 2026
@castrojo castrojo added the lgtm This PR has been approved by a maintainer label Sep 6, 2026
Merged via the queue into main with commit a87b4d4 Sep 6, 2026
6 of 7 checks passed
pull Bot pushed a commit to joshyorko/testsuite that referenced this pull request Sep 6, 2026
…h_argv (projectbluefin#773)

tests/shared/ssh_config.py documents itself as the one source of truth for
SSH connection details, resolving them via context attrs -> behave userdata
-> environment -> defaults. Eight modules in the smoke suite and
tests/shared/gnome_shell_steps.py bypassed it, each rebuilding the ssh argv
inline from direct os.environ reads. tests/smoke/features/environment.py
already calls populate_ssh_context(), so a run driven by behave userdata
sent the shared steps to one host and the smoke-local steps to another.

Add ssh_config.ssh_argv() as the single place the transport policy lives and
migrate those nine modules onto it. The emitted argv is byte-identical to
what each module built before, so behaviour is unchanged; the modules now
inherit the documented precedence chain instead of reading env vars directly.

resolve_ssh_details() now tolerates a missing/None context, which suite-local
helpers need since they have no behave context to hand.

tests/unit/test_ssh_transport_contract.py pins ssh_argv() and fails if any
migrated module regrows a private copy of the argv.

offline_boot_steps.py is left alone: PR projectbluefin#772 territory is disjoint from
PR projectbluefin#768, which is adding unit coverage for that module.

Refs projectbluefin#772

Signed-off-by: sec-check[bot] <sec-check[bot]@users.noreply.github.com>
Co-authored-by: sec-check[bot] <sec-check[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mrbobbytables added a commit to mrbobbytables/testsuite that referenced this pull request Sep 15, 2026
… image_cache, screenshot, and run_ssh onto ssh_config.ssh_argv()

Phase 2 of projectbluefin#772: extract the remaining raw ssh argv builders onto the
single transport policy in tests/shared/ssh_config.py.

- Add ssh_argv(quiet=...) so callers that need LogLevel=ERROR (previously
  hand-rolled at each site) opt in explicitly instead of restating it.
- Fold ssh_steps.run_ssh onto ssh_argv(quiet=True); it now always resolves
  the port through the shared precedence chain (context > userdata > env >
  default), so unset ssh_port emits an explicit '-p 22' instead of silently
  relying on ssh's own default.
- Migrate tests/dx and tests/flatcar's raw ssh argv (both gain the -p flag,
  fixing silent port loss under port-forwarded lanes).
- Fix tests/kde-smoke/features/steps/steps.py:_run_host, which read a
  context.kde['ssh'] dict that before_all never populated — it always fell
  through to raw os.environ reads and silently ignored userdata-driven
  runs. It now resolves through ssh_argv(context), honouring the context
  attributes before_all does set.
- Migrate tests/software's _flatpak/_run_in_session/_has_bazaar, which
  already used resolve_ssh_details, onto ssh_argv() for a single argv
  builder instead of two.
- Migrate tests/shared/image_cache.py and tests/shared/screenshot.py.
  screenshot._ssh_run previously read only os.environ; it now resolves via
  the behave context bound by configure_screenshot_context.
- Fix tests/vanilla-gnome/features/steps/steps.py, which passed the
  command's own timeout as ssh's ConnectTimeout, conflating the connect
  deadline with the command deadline (a 900s long-command timeout became a
  900s connect timeout). It now uses ssh_argv()'s fixed 10s connect timeout
  and threads context through so future context-based resolution works.
- Widen tests/unit/test_ssh_transport_contract.py's MIGRATED_MODULES to
  cover all of the above, so any of them re-growing a private ssh argv
  copy fails CI.

tests/smoke/features/steps/offline_boot_steps.py remains unmigrated per
the issue's Phase 1 exclusion (PR projectbluefin#768 covers its unit tests).

Fixes projectbluefin#772

Signed-off-by: mrbobbytables <mrbobbytables@users.noreply.github.com>
castrojo pushed a commit to mrbobbytables/testsuite that referenced this pull request Sep 18, 2026
… image_cache, screenshot, and run_ssh onto ssh_config.ssh_argv()

Phase 2 of projectbluefin#772: extract the remaining raw ssh argv builders onto the
single transport policy in tests/shared/ssh_config.py.

- Add ssh_argv(quiet=...) so callers that need LogLevel=ERROR (previously
  hand-rolled at each site) opt in explicitly instead of restating it.
- Fold ssh_steps.run_ssh onto ssh_argv(quiet=True); it now always resolves
  the port through the shared precedence chain (context > userdata > env >
  default), so unset ssh_port emits an explicit '-p 22' instead of silently
  relying on ssh's own default.
- Migrate tests/dx and tests/flatcar's raw ssh argv (both gain the -p flag,
  fixing silent port loss under port-forwarded lanes).
- Fix tests/kde-smoke/features/steps/steps.py:_run_host, which read a
  context.kde['ssh'] dict that before_all never populated — it always fell
  through to raw os.environ reads and silently ignored userdata-driven
  runs. It now resolves through ssh_argv(context), honouring the context
  attributes before_all does set.
- Migrate tests/software's _flatpak/_run_in_session/_has_bazaar, which
  already used resolve_ssh_details, onto ssh_argv() for a single argv
  builder instead of two.
- Migrate tests/shared/image_cache.py and tests/shared/screenshot.py.
  screenshot._ssh_run previously read only os.environ; it now resolves via
  the behave context bound by configure_screenshot_context.
- Fix tests/vanilla-gnome/features/steps/steps.py, which passed the
  command's own timeout as ssh's ConnectTimeout, conflating the connect
  deadline with the command deadline (a 900s long-command timeout became a
  900s connect timeout). It now uses ssh_argv()'s fixed 10s connect timeout
  and threads context through so future context-based resolution works.
- Widen tests/unit/test_ssh_transport_contract.py's MIGRATED_MODULES to
  cover all of the above, so any of them re-growing a private ssh argv
  copy fails CI.

tests/smoke/features/steps/offline_boot_steps.py remains unmigrated per
the issue's Phase 1 exclusion (PR projectbluefin#768 covers its unit tests).

Fixes projectbluefin#772

Signed-off-by: mrbobbytables <mrbobbytables@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent/quality Filed or owned by the quality agent. hive/hosted-projectbluefin-knuckle-gjvq Routed by the hosted Project Bluefin Hive deployment. hold Work is intentionally paused. lgtm This PR has been approved by a maintainer quality Code quality or test-coverage work. testing Test authoring or test infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants