Skip to content

test: isolate apparmor install tests from host linger state - #30819

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
greener/pr-23616
Nov 6, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
greener/pr-23616

Conversation

@iamwhatever

Copy link
Copy Markdown
Contributor

CI-runner copy of #23616 by @lazarus-boop, opened so CI runs on the in-repo CodeBuild runners. Fork CI keeps hitting the job time limit (#23450). The commit is unchanged and keeps @lazarus-boop's authorship. All credit goes to the original author. The original PR stays open until this one merges.

Problem / Motivation

Goal: The AppArmor install tests pass on any Linux host, whether or not systemd linger is on for the account running the suite.

  • install_service() prints the service account's real linger warning (it reads loginctl), and that warning starts with a warning sign.
  • Two tests in TestAppArmorNeverFailsTheInstall assert there is no warning sign in the output, but only fake the platform and the AppArmor outcome.
  • On a host with linger off, test_install_reports_the_profile_on_success and test_a_silent_skip_prints_nothing_extra fail even though the AppArmor step they check succeeded.

Why it matters

Anyone running the backend suite on a Linux machine with linger off (the default for most accounts) gets two red tests that say nothing about their change. CI runners have linger on, so the failure only shows up locally, where it costs time to rule out.

Not a goal

  • No change to the linger warning itself or to install_service().
  • No change to other tests that call install_service(); they already fake the linger check or do not assert on warning signs (see the sibling sweep).

What changed (motivation → approach → change)

How the tests are isolated now: the class's _patched helper, which already fakes controller.current_platform and controller.linux.install, also replaces controller.linux.linger_warning_for_service_account with a stub returning None. Each install test then sees the AppArmor outcome alone.

  1. install_service() looks the function up on the linux module each time it runs, so a monkeypatch.setattr on controller.linux takes effect.
  2. The patch uses the per-test monkeypatch fixture, so it is undone after each test and cannot reach other tests.
  3. test_install_still_succeeds_when_the_profile_fails gets stricter as a side effect: its "warning sign is present" assertion can no longer be satisfied by the linger warning, only by the AppArmor failure message.

One commit, touching test/test_service_apparmor.py only (+4 lines: the patch and a comment saying why).

Backwards compatibility

Compatible: test-only change; no production code, config or public surface changes.

Removes nothing: the stub replaces a host read inside one test class; the linger warning keeps its own tests in test/test_service_controller.py and test/test_service.py.

Tests

  • test/test_service_apparmor.py::TestAppArmorNeverFailsTheInstall: on a Linux host with Linger=no, before this change 2 failed and 2 passed; after it, all 4 pass. The whole file passes.
  • The linger warning tests in test/test_service_controller.py and test/test_service.py still pass, so its coverage is unchanged.

Proof: not provable -- test-only change

Manual verification

N/A — unit coverage sufficient: the change is a test fixture, checked by running the class on a host with linger off.

Related Issues

Fixes #23594

Sibling sweep

Swept: git grep -n "install_service()" -- test/
Sibling: test/test_service_controller.py:50 -- not affected -- asserts only the exit code and that install ran
Sibling: test/test_service_controller.py:70 -- not affected -- fakes the linger warning and asserts on it
Sibling: test/test_service_controller.py:86 -- not affected -- already patches the linger check to return None
Sibling: test/test_service_headless_api_key.py:315 -- not affected -- asserts only that its own note is printed

Pattern harvest

Not generalizable: one helper faked the platform and the unit install but not the linger read beside them; the other callers of the same path already fake that read or do not assert on its output.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@iamwhatever
iamwhatever requested review from a team and KiroCrewCaptain as code owners November 5, 2026 22:51
@iamwhatever
iamwhatever requested a review from buluoray November 5, 2026 22:51
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision eac5587404de479914eabd8e81f9f808bdc8a415 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ⏭️ skipped

Revision eac5587404de479914eabd8e81f9f808bdc8a415 ships no reviewable capability (docs, tests or generated files only), so there is nothing to inventory. Does not block merge.

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of eac5587404de479914eabd8e81f9f808bdc8a415 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing to check. This is a test-only change that stubs out the host linger read in the one helper that missed it, and it takes nothing away.

[DESIGN-REVIEWED] eac5587

Description read

[DESCRIPTION-READ] 418781cea8173594dafa213eaf516d3a3465ba158327a2617113d8e92393fd12

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed eac5587404de479914eabd8e81f9f808bdc8a415 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] eac5587

Verdict parsed from the review's SHA-scoped output markers for commit eac5587404de479914eabd8e81f9f808bdc8a415.

False positive or not applicable? A repository writer can comment:
/ai-review override fable eac5587404de479914eabd8e81f9f808bdc8a415 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of eac5587404de479914eabd8e81f9f808bdc8a415 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] eac5587

False positive or not applicable? A repository writer can comment:
/ai-review override gpt eac5587404de479914eabd8e81f9f808bdc8a415 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 6, 2026
install_service() also prints the service account's real linger warning, read from loginctl, so the AppArmor install tests that assert no warning sign failed on any host with linger off. Stub that warning in the class's _patched helper so the tests depend only on the AppArmor outcome they fake.
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running labels Nov 6, 2026
@iamwhatever iamwhatever self-assigned this Nov 6, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) November 6, 2026 02:05

@KiroCrewCaptain KiroCrewCaptain 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.

Tier 1 auto-approve: test (1 file). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: test-only; stubs the service-account linger warning so the AppArmor install assertions do not depend on the host.

@KiroCrewCaptain
KiroCrewCaptain merged commit 9b5d776 into main Nov 6, 2026
96 of 97 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the greener/pr-23616 branch November 6, 2026 02:05
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 6, 2026
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.

test: AppArmor install tests fail on hosts with systemd linger off

3 participants