Skip to content

test: fix four flaky tests that keep CI failing - #1819

Merged
Quick104 merged 1 commit into
mainfrom
t3code/remove-custom-ci-runners
Oct 2, 2026
Merged

Quick104 merged 1 commit into
mainfrom
t3code/remove-custom-ci-runners

Conversation

@Quick104

@Quick104 Quick104 commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: none

CI on main has failed on every push today, so no Docker image has been published since. Four tests fail intermittently on both GitHub-hosted and self-hosted runners, and PRs pick up the same failures without touching the code involved. This change fixes the races in the tests. No product code changes.

  • librarymonitor TestFailedBackendIsReplaced waited for a new status report after the backend was replaced. The status loop only reports rows that changed, and a replacement fast enough to skip the intermediate "starting" state leaves the rows exactly as they were, so no report comes and the test times out after 10s. With GOMAXPROCS=1 it failed on every run.
  • librarymonitor TestStalledWalkStopsHoldingOthersBack blocked the walk after the monitor had already started, so the walk could finish first and the hung library reported monitoring. TestRemovingARootCancelsItsWalk has the same setup.
  • adminjob TestImageCacheCleanupProgressResetsStalledClaims depends on prefix 1's first stall sharing a claim with prefix 0's success. On a loaded runner the progress write can run past the 150ms slice, Execute stops before prefix 1, and the job records 12 stalled claims instead of 11.
  • ItemGrid.scroll.test.tsx passes every assertion, but each scroll arms the virtualizer's 150ms is-scrolling reset timer, and unmounting does not clear it. When the file finishes first, the timer fires against a torn-down DOM and vitest fails the run on the unhandled ReferenceError: window is not defined.

This supersedes #1737 by @Tobechukwu-Njoku, which fixes TestFailedBackendIsReplaced the same way. This PR carries that fix along with the other three so main turns green in one merge.

Approach

  • TestFailedBackendIsReplaced waits on the afterAttempt hook until the root is recorded again, then reads the rows directly, as other tests in the file already do.
  • The two walk tests create the fake backend with its block in place before the monitor starts, matching TestWalksRunOneAtATimeInSortOrder.
  • Prefix 1 now stalls most times instead of most+1. Neither prefix can reach the limit alone however the claims line up, but the two together still exceed it, so the test still fails if progress stops resetting the count.
  • The scroll test fakes setTimeout/clearTimeout and clears pending timers after unmount.

Validation

  • librarymonitor under -race on Linux: the whole package passes; the changed tests pass 150 runs each at -cpu 1, 2 and 8. The original TestFailedBackendIsReplaced failed 59 of 59 runs at -cpu=1.
  • adminjob image cache cleanup tests against a fresh pgvector PG18 database: pass, and the changed test passes 30 runs at -cpu 1 and 4 under -race.
  • ItemGrid.scroll.test.tsx: passes 5 runs; a check during the fix confirmed one pending virtualizer timer per test is now captured and discarded.
  • gofmt, prettier, eslint, and golangci-lint on the changed lines: clean.

Risks

None identified. Test-only change.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.

AI Disclosure

  • Harness: Claude Code (in T3 Code)
  • Tool(s): Claude Code
  • Model(s): claude-opus-5-5
  • Involvement: Fully AI-generated; the maintainer set scope. Human review of the diff is pending.
  • Adversarial review: n/a

🤖 Generated with Claude Code

Note

Fix flaky image cache, library monitor, and ItemGrid scroll tests

  • Fixes TestImageCacheCleanupProgressResetsStalledClaims by making the second stalled range end at twice the max stalled-claim count, so neither prefix alone hits the failure threshold in image_cache_cleanup_runner_test.go
  • Reworks three tests in monitor_linux_test.go to inject a pre-blocked fake backend before monitor startup and to wait on backend-attempt state transitions, removing races around blocked walks and status-row coalescing
  • Configures fake timers in ItemGrid.scroll.test.tsx so virtualizer reset timers cannot fire after the test DOM is torn down

Macroscope summarized 2f0cd5f.

- librarymonitor: TestFailedBackendIsReplaced waited for a status report
  the status loop may skip, since a fast backend swap leaves the rows
  unchanged. Wait for the re-attach attempt and read the rows instead.
- librarymonitor: block the walk before the monitor starts in
  TestStalledWalkStopsHoldingOthersBack and TestRemovingARootCancelsItsWalk,
  so the walk cannot finish first.
- adminjob: a slow progress write can push the second prefix's first
  stall into its own claim; stall it one fewer time so the count stays
  below the limit either way.
- web: fake setTimeout in ItemGrid.scroll.test.tsx so the virtualizer's
  scroll-reset timer cannot fire after the DOM is torn down.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@silo-kody

silo-kody Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104
Quick104 merged commit 218af0d into main Oct 2, 2026
4 of 13 checks passed
@Quick104
Quick104 deleted the t3code/remove-custom-ci-runners branch October 2, 2026 19:46
@coderabbitai

coderabbitai Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 3ded2648-6dbd-4a66-87e5-f0a0581427aa

📥 Commits

Reviewing files that changed from the base of the PR and between 7100d4f and 2f0cd5f.

📒 Files selected for processing (3)
  • internal/adminjob/image_cache_cleanup_runner_test.go
  • internal/librarymonitor/monitor_linux_test.go
  • web/src/components/ItemGrid.scroll.test.tsx
 __________________________________________
< Fight fire with fire. Review AI with AI. >
 ------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant