Repository navigation
π fix(test): bypass the shared PR-detail cache in repo-item decision tests - #15462
Conversation
β¦em decision mock TestRepoItemDecisionMergeDecisionsGuard failed intermittently: the own-PR guard in handlePullRequestMergeDecision reads the PR author through GetPRAuthor, which consults the process-global PR-detail cache keyed by repo+number. A "testorg/testrepo" PR hivecommons#8 cached by an earlier test in the same binary (hive[bot] author, 30 min TTL) answered instead of this test's mock, so the "someone" caller was no longer the author and merge-now went through to GitHub (code=200, one PUT /merge). newRepoItemDecisionServer now sets a zero PR-detail TTL on its client so every read goes to the mock. Test-only; no production change. Hive-Run: hivecommons#15461 Hive-Plan: fix flaky test (isolate PR-detail cache in test mock) Hive-Spec: ci-flake#TestRepoItemDecisionMergeDecisionsGuard Signed-off-by: SACHIN NAIK <sachin.naik@ibm.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
There was a problem hiding this comment.
Read this against the cache in the tree, not just the diff: SetPRDetailTTLFunc (src/pkg/github/client.go:1434) feeds effectivePRDetailTTL, and every read path GetPRAuthor/GetPRState take β cachedPRDetailAny β getAny β getLocked β misses unconditionally when ttl <= 0 (src/pkg/github/prdetailcache.go:89). The cache really is one process-global sharedPRDetailCache (prdetailcache.go:44), so the cross-test bleed the comment describes is real, and a zero TTL closes it for this client only. The one path that ignores TTL, getMergedBy, is reached from prclaims.go:1131, not from these handlers.
time is already imported in the test file. Looks correct to me; the failing check (Sign-off survives the squash: CANCELLED) is a runner cancellation, not this diff.
β hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
There was a problem hiding this comment.
Read the cache path this relies on, not just the diff. Looks correct to me.
src/pkg/github/client.go:1449-1455βeffectivePRDetailTTLreturns the injected TTL whenever it is>= 0, so0is honoured rather than falling back to the config default.src/pkg/github/prdetailcache.go:89βgetLockedmisses outright whenttl <= 0, andGetPRAuthor(client.go:2894) /GetPRStatego throughcachedPRDetailAnyβgetLocked, so a stale#8cached by another test in the same process can no longer answer here.getMergedBy(prdetailcache.go:68) ignores the TTL, but nothing on the repo-item decision path reads it.- Same
SetPRDetailTTLFuncseam the package's own tests already use (close_on_merge_test.go:164,prdetailcache_test.go:121), just with0instead oftime.Hour.
Test-only, five lines, no behaviour change outside the test.
β hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
stage 080-awaiting-merge-admission β 060-reviewed: contributor-lane:claim-tier-untrusted |
|
Ready for a human merge: verdict approved @f6e8fe0, 58/58 checks green, DCO yes, soak 30m0s elapsed. Blocked only by The hive never approves on your behalf: |
Why
TestRepoItemDecisionMergeDecisionsGuardfailed onv5in run 40932791908 (jobsdashboard 4/4anddashboard shuffle 1/3; the gotestsum rerun passed). The log shows:The own-PR guard in
handlePullRequestMergeDecisionreads the author throughGetPRAuthor, which first consults the process-global PR-detail cache (sharedPRDetailCache, keyed by repo+number, 30 min default TTL). Every decision test usestestorg/testrepo#8, so when another test in the same binary had already cached #8 (authorhive[bot]), the cache answered instead of this test's mock. "someone" then was not the author andmerge-nowwent through to GitHub. Which test ran first depends on test order and sharding, hence the flake (and why the shuffle shard hit it too).What changed
newRepoItemDecisionServersets a zero PR-detail TTL on its client (SetPRDetailTTLFunc), so every PR read goes to the mock. This is the same knob thepkg/githubcache tests use. Test-only; no production code touched, so nochangelog.d/fragment (*_test.gois exempt).Per AGENTS.md I did not run the suite locally; CI is the verdict.
Closes #15461
β hive: backend=bob model=premium