Skip to content

test: cover page_cache and log-handler error paths - #23819

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
test/coverage-gaps-2
Oct 27, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
test/coverage-gaps-2

Conversation

@RohanK6

@RohanK6 RohanK6 commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #23818

Problem / Motivation

Goal: The error paths of the boot page-cache prefetch and the append-only log handler are pinned by tests, and the two rollover-failure tests pass on every supported Python 3.12 release.

Branch coverage over the tests that import each module:

  • page_cache.py at 82%. read_now never runs in a test, nor does the per-file OSError skip in _read_through or the RuntimeError guard around the thread start in prefetch.
  • cli_log_files.py at 91%. _AppendOnlyLogFileHandler has no test for its RecursionError re-raise or for a close() that fails after the record was written.

Separately, TestRolloverFailureStopsFileLogging::test_eacces_on_reopen_stops_file_logging and ::test_retryable_errno_stops_at_streak_limit fail on every run under CPython 3.12.4 (requires-python = ">=3.12"). On that release RotatingFileHandler.shouldRollover has no empty-file check, so the first oversized record rolls the still-empty gateway.log over. doRollover then re-points the fds at gateway.log, and redirects reads [gateway.log, os.devnull] instead of the expected [os.devnull].

Why it matters

page_cache is a boot-time hint that must never raise: one unreadable file or a thread start during shutdown must not abort the gateway or skip the files after it. _AppendOnlyLogFileHandler exists so non-gateway processes hold no handle on gateway.log, because a held handle blocks every gateway rollover on Windows. A regression that kept the stream after a failed close would bring that back, and no current test would fail. The two rollover tests also fail for anyone running the suite on 3.12.4.

Not a goal

  • No source changes. Every test passes against main as it is.
  • No change to what the rollover tests check: they still require exactly one traceback, one "file logging stopped" line and one re-point to os.devnull after the denied reopen.

What changed (motivation → approach → change)

Untested branches found with per-module --cov-branch runs → one behaviour test per branch through the public entry points → two test files changed.

  • test/test_page_cache_prefetch.py: read_now reads on the calling thread and skips None; a file whose open raises PermissionError is skipped and the next file is still read; prefetch returns quietly when Thread.start raises RuntimeError (interpreter shutdown).
  • test/test_cli_logging.py, TestAppendOnlyLogFileHandler: a RecursionError from formatting reaches the caller, is not routed to handleError, and leaves no stream open; a close() that raises after the write is swallowed, the record is on disk and the stream is still released.
  • test/test_cli_logging.py, TestRolloverFailureStopsFileLogging: the two tests clear redirects after the priming emit, so only the re-points made after the denied reopen are asserted. A release that does not roll the empty file over records nothing on that emit, so the assertion is unchanged there.

Backwards compatibility

Compatible: tests only, nothing in src/ changes.

Removes nothing: the diff only adds tests and narrows when two tests start recording.

Tests

Proof: not provable -- test-only change

Branch coverage after this change, same measurement as above: page_cache.py 100%, cli_log_files.py 100%.

To check the new tests catch real regressions, four mutations were applied locally and reverted, and each failed exactly one new test: dropping the RecursionError re-raise, keeping the stream when close() fails, removing the RuntimeError guard in prefetch, and removing the OSError guard in _read_through. Both changed files pass 3/3 runs under the default xdist config (70 passed each run) on CPython 3.12.4, where the two rollover tests failed before. black, isort and flake8 are clean; mypy reports no new errors on the changed files.

Manual verification

N/A — test-only change; the tests are the verification.

Related Issues

Fixes #23818

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.

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 67b1d1955f180982263506bf561b2a9edc317527 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) — ⏭️ skipped

Revision 67b1d1955f180982263506bf561b2a9edc317527 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) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks. The PR only adds tests and narrows the window in which two existing tests record re-points. Every behaviour those tests check after the denied reopen stays asserted.

[DESIGN-REVIEWED] 67b1d19

Description read

[DESCRIPTION-READ] 391f6684a6978552427e07ce2781455f1ef01e59feab72c2eee230121bc92897

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 — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 67b1d19

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

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

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 67b1d19

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

@RohanK6 RohanK6 closed this Oct 24, 2026
@RohanK6 RohanK6 reopened this Oct 24, 2026
@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: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Oct 24, 2026
@RohanK6

RohanK6 commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

Status: Linux backend shards 1, 2 and 4 hit the 60-minute job timeout on hosted ubuntu-latest in both attempts of run 40131108602. Their logs have no FAILED or ERROR lines, and one shard was cut off at [100%]. Coverage Gate fails only because of those shards. All other shards, the Windows shards and the AI reviews pass.

This PR only adds 5 tests (test/test_cli_logging.py, test/test_page_cache_prefetch.py). Locally each one runs in under 0.02s, and none is in --durations=15 for those files. On hosted runners, other recent PRs' shards took 15–49 min (#23816, #23746, #23814), and this run's passing shards took 32–56 min. So the timeouts come from runner speed, not from the diff. I'm parking this PR and won't rerun it again myself.

@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 25, 2026
@RohanK6
RohanK6 force-pushed the test/coverage-gaps-2 branch from 0770a39 to 583092f Compare October 25, 2026 12:10
@RohanK6 RohanK6 closed this Oct 25, 2026
@RohanK6 RohanK6 reopened this Oct 25, 2026
@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 25, 2026
@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Oct 25, 2026
@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Oct 25, 2026
@RohanK6
RohanK6 force-pushed the test/coverage-gaps-2 branch from 583092f to bcf0486 Compare October 26, 2026 01:11
@RohanK6 RohanK6 closed this Oct 26, 2026
@RohanK6 RohanK6 reopened this Oct 26, 2026
@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 26, 2026
Add behaviour tests for the untested error paths of page_cache
(read_now, a per-file read error, thread start at interpreter
shutdown) and _AppendOnlyLogFileHandler (RecursionError re-raise, a
failed close after a write).

Make the two TestRolloverFailureStopsFileLogging tests assert only the
fd re-points made after the denied reopen. CPython 3.12.4 also rolls
an empty log over on the first oversized record, which added an extra
re-point and failed both tests on every run.

Fixes #23818
@RohanK6
RohanK6 force-pushed the test/coverage-gaps-2 branch from bcf0486 to 67b1d19 Compare October 26, 2026 20:50
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 26, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) October 27, 2026 23:08

@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 (2 files). 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: adds error-path tests for page_cache prefetch and the CLI log handler; test files only.

@KiroCrewCaptain
KiroCrewCaptain merged commit 81007ed into main Oct 27, 2026
206 of 276 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the test/coverage-gaps-2 branch October 27, 2026 23:09
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: page_cache and cli_log_files error paths untested; two rollover tests fail on CPython 3.12.4

2 participants