Repository navigation
test: cover page_cache and log-handler error paths - #23819
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 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 |
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: |
|
Status: Linux backend shards 1, 2 and 4 hit the 60-minute job timeout on hosted This PR only adds 5 tests ( |
0770a39 to
583092f
Compare
583092f to
bcf0486
Compare
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
bcf0486 to
67b1d19
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
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.
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.pyat 82%.read_nownever runs in a test, nor does the per-fileOSErrorskip in_read_throughor theRuntimeErrorguard around the thread start inprefetch.cli_log_files.pyat 91%._AppendOnlyLogFileHandlerhas no test for itsRecursionErrorre-raise or for aclose()that fails after the record was written.Separately,
TestRolloverFailureStopsFileLogging::test_eacces_on_reopen_stops_file_loggingand::test_retryable_errno_stops_at_streak_limitfail on every run under CPython 3.12.4 (requires-python = ">=3.12"). On that releaseRotatingFileHandler.shouldRolloverhas no empty-file check, so the first oversized record rolls the still-emptygateway.logover.doRolloverthen re-points the fds atgateway.log, andredirectsreads[gateway.log, os.devnull]instead of the expected[os.devnull].Why it matters
page_cacheis 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._AppendOnlyLogFileHandlerexists so non-gateway processes hold no handle ongateway.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
os.devnullafter the denied reopen.What changed (motivation → approach → change)
Untested branches found with per-module
--cov-branchruns → one behaviour test per branch through the public entry points → two test files changed.test/test_page_cache_prefetch.py:read_nowreads on the calling thread and skipsNone; a file whose open raisesPermissionErroris skipped and the next file is still read;prefetchreturns quietly whenThread.startraisesRuntimeError(interpreter shutdown).test/test_cli_logging.py,TestAppendOnlyLogFileHandler: aRecursionErrorfrom formatting reaches the caller, is not routed tohandleError, and leaves no stream open; aclose()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 clearredirectsafter 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.py100%,cli_log_files.py100%.To check the new tests catch real regressions, four mutations were applied locally and reverted, and each failed exactly one new test: dropping the
RecursionErrorre-raise, keeping the stream whenclose()fails, removing theRuntimeErrorguard inprefetch, and removing theOSErrorguard 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
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.