Skip to content

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

Closed
lazarus-boop wants to merge 1 commit into
kirodotdev:mainfrom
lazarus-boop:fix/23594-apparmor-linger-isolation
Closed

lazarus-boop wants to merge 1 commit into
kirodotdev:mainfrom
lazarus-boop:fix/23594-apparmor-linger-isolation

Conversation

@lazarus-boop

Copy link
Copy Markdown
Contributor

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.

@lazarus-boop
lazarus-boop requested review from a team and KiroCrewCaptain as code owners October 24, 2026 01:19
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 24, 2026
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ⏭️ skipped

Revision e6bfa7018457b67bda4ae99f36eae0c3a5ccfe4e 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 Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ⏭️ skipped

Revision e6bfa7018457b67bda4ae99f36eae0c3a5ccfe4e 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 Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of e6bfa7018457b67bda4ae99f36eae0c3a5ccfe4e via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: this is a test-only stub of a host read, patched at the module attribute that controller.py:148 looks up on every call, and the per-test monkeypatch undoes it after each test.

[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 .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 Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed e6bfa7018457b67bda4ae99f36eae0c3a5ccfe4e via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] e6bfa70

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed e6bfa7018457b67bda4ae99f36eae0c3a5ccfe4e via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] e6bfa70

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 24, 2026
@lazarus-boop

Copy link
Copy Markdown
Contributor Author

The two red backend shards look unrelated to this change: Backend Tests (3.12, 1) and (3.12, 2) were cancelled at the job's 1h0m0s limit with no failing test in their logs, and Coverage Gate then failed closed on backend-test=cancelled. In both, collection alone took about 33 minutes (the workers started at 01:47 and reported worker_collected at 02:20), so the tests had under half an hour left; in other PRs started in the same window the whole shard took 15 to 30 minutes. The diff is four lines in one test helper. Could a maintainer re-run the failed jobs? I can't re-run upstream jobs from a fork.

@lazarus-boop
lazarus-boop force-pushed the fix/23594-apparmor-linger-isolation branch from f276d3c to 253d210 Compare October 24, 2026 21:27
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 24, 2026
@lazarus-boop
lazarus-boop force-pushed the fix/23594-apparmor-linger-isolation branch from 253d210 to a261e54 Compare October 26, 2026 22:40
@lazarus-boop

Copy link
Copy Markdown
Contributor Author

@KiroCrewCaptain could you re-run the two red checks on this PR?

Update on the head a261e54c6: the backend shards and Coverage Gate pass now, so my earlier comment is out of date (those timeouts were the leaf-mode corpus gates, #23450, not slow runners). Two checks are still red, and neither looks related to the diff:

  • GPT 6.1 Review is "review incomplete": the model call returned 429 Too Many Requests after retries, so the lane had no verdict and failed closed.
  • Cross-Platform Portability was cancelled at its 5-minute job limit with no failing check.

If the bot can't do it, could a maintainer re-run those two? I can't re-run upstream jobs from a fork.

@lazarus-boop
lazarus-boop force-pushed the fix/23594-apparmor-linger-isolation branch from a261e54 to d0db47a Compare October 30, 2026 01:11
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 30, 2026
@lazarus-boop

Copy link
Copy Markdown
Contributor Author

@chenmingwei23 the red checks on this PR are the leaf-mode corpus-gate timeout from #23450, not the diff. On head d0db47a71 (run https://github.com/kirodotdev/KiroCrew/actions/runs/40984317415), 4 of the 8 Backend Tests (3.12) jobs (shards 1, 5, 6 and 7) were cancelled at the 60-minute limit inside leaf corpus gates (710 file(s), once), with no failed test, and never reached the changed file; Coverage Gate then failed closed on the cancellations. The other four shards, Fast Gate, Cross-Platform Portability and every AI review lane passed. Across this PR's four runs, 2, 2, 0 and 4 shards were cancelled, so another push or re-run is a coin toss until #23461 lands. Since every test-only pull request runs in leaf mode, this hits all of them the same way, so landing #23461 would unblock a whole class of open PRs, flake fixes included. I'll rebase once it does. This supersedes my two earlier re-run requests.

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.
@iamwhatever
iamwhatever force-pushed the fix/23594-apparmor-linger-isolation branch from d0db47a to e6bfa70 Compare November 4, 2026 15:30
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 4, 2026
@lazarus-boop

Copy link
Copy Markdown
Contributor Author

@iamwhatever thanks for the rebase. The red checks on the new head e6bfa7018 are not from this diff, which only adds one stub inside TestAppArmorNeverFailsTheInstall. Each shard ran test/test_service_apparmor.py as its leaf target, and nothing failed in that file. Could you re-run the failed jobs in run 41858540711?

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 5, 2026
@lazarus-boop

Copy link
Copy Markdown
Contributor Author

@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?

@iamwhatever

Copy link
Copy Markdown
Contributor

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.

@iamwhatever

Copy link
Copy Markdown
Contributor

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.

@iamwhatever iamwhatever closed this Nov 6, 2026
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Nov 6, 2026
@lazarus-boop
lazarus-boop deleted the fix/23594-apparmor-linger-isolation branch November 6, 2026 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants