Repository navigation
test: isolate apparmor install tests from host linger state - #30819
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of 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 |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
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.
e6bfa70 to
eac5587
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
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.
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 readsloginctl), and that warning starts with a warning sign.TestAppArmorNeverFailsTheInstallassert there is no warning sign in the output, but only fake the platform and the AppArmor outcome.test_install_reports_the_profile_on_successandtest_a_silent_skip_prints_nothing_extrafail 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
install_service().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
_patchedhelper, which already fakescontroller.current_platformandcontroller.linux.install, also replacescontroller.linux.linger_warning_for_service_accountwith a stub returningNone. Each install test then sees the AppArmor outcome alone.install_service()looks the function up on thelinuxmodule each time it runs, so amonkeypatch.setattroncontroller.linuxtakes effect.monkeypatchfixture, so it is undone after each test and cannot reach other tests.test_install_still_succeeds_when_the_profile_failsgets 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.pyonly (+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.pyandtest/test_service.py.Tests
test/test_service_apparmor.py::TestAppArmorNeverFailsTheInstall: on a Linux host withLinger=no, before this change 2 failed and 2 passed; after it, all 4 pass. The whole file passes.test/test_service_controller.pyandtest/test_service.pystill 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
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.