Repository navigation
test: isolate apparmor install tests from host linger state - #23616
lazarus-boop wants to merge 1 commit into
Conversation
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5, fork) — ⏭️ skippedRevision |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: this is a test-only stub of a host read, patched at the module attribute that [DESIGN-REVIEWED] e6bfa70 Description read[DESCRIPTION-READ] 07c8f0222039628db55f4b6a9704a7920cf80622ac0d1a6bafa1f2f996b82dd7 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 (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
|
The two red backend shards look unrelated to this change: |
f276d3c to
253d210
Compare
253d210 to
a261e54
Compare
|
@KiroCrewCaptain could you re-run the two red checks on this PR? Update on the head
If the bot can't do it, could a maintainer re-run those two? I can't re-run upstream jobs from a fork. |
a261e54 to
d0db47a
Compare
|
@chenmingwei23 the red checks on this PR are the leaf-mode corpus-gate timeout from #23450, not the diff. On head |
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.
d0db47a to
e6bfa70
Compare
|
@iamwhatever thanks for the rebase. The red checks on the new head
|
|
@bolichen97 thanks for the re-run. Attempt 3 is the same test-infrastructure issue, not this diff: shards 5, 7 and 8 now pass, and shards 1 and 4 were cancelled at the job time limit with no failing test in their logs (the #23450 timeout). Coverage Gate fails only because those two jobs did not finish. Could they get one more re-run? |
|
Thanks @lazarus-boop! Fork CI keeps hitting the job time limit (#23450), so I copied your commit unchanged to an in-repo branch so CI runs on the larger CodeBuild runners: #30819. Your authorship is kept, and this PR stays open until the copy merges. |
|
Thank you! Your change landed on main through the in-repo copy #30819 (your commit and authorship kept), which ran CI on the larger runners. Closing this one as merged-via-copy. |
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.