Repository navigation
test(server,app): pin main() shutdown, memoryLocks tail cleanup and redisLocks ttl from #623 (__tests__/server/{stores,cronInterval}, __tests__/adapters/app/{lock,redis}) - #631
Conversation
…behaviour from #623 main()'s close() cleared the cron interval and stopped the listener, and memoryLocks only dropped a key's tail when it was still its own, without any test noticing either: Stryker reported both calls, the pending > 0 guard, the `tails.get(key) === settled` comparison, redisLocks' ttlMs default and createClient's url as survivors. Each is now asserted by a test that fails with the statement removed or inverted. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
Important Held for human review by the hive's ACMM level gate. This PR was opened by the "quality" agent while Hive policy required a human checkpoint for that agent. Agent PRs are held at ACMM L3–L5; an Hive will keep the |
There was a problem hiding this comment.
Read the diff against the sources it pins; everything checks out. Test-only change, no src/ edits, CI green at 8d19980.
Verified against the tree:
- memoryLocks tail cleanup —
src/adapters/app/lock.ts:35-37deletes the key only whentails.get(key) === settled. The new a→b→c case inlock.test.tsgenuinely exercises it: whenafinishes, the map holdsb's settled tail, so an unconditional (or!==) delete would letcstart a fresh chain and run alongsideb. The test's mid-sequence assertion (c:startabsent untilsecond.open()) would catch exactly that. - redisLocks default ttl —
src/adapters/app/redis.ts:37isoptions.ttlMs ?? 60_000; the new assertionset prow:lock:k {"NX":true,"PX":60000}matches the option order atredis.ts:44as serialized by the existingfakeRedishelper. The strengthened explicit-ttl assertion (PX":500) now distinguishes??from&&, as the body claims. - shutdown with nothing in flight —
src/server/node.ts:159-163:clearInterval(timer),server.close(), then thepending > 0guard around the "shutting down: waiting…" line;:167logsshut down,:172callsexit(0). The new case asserts the exact log sequence (no waiting line), single store close, refused follow-up fetch — pinningserver.close()and the guard. - cron interval cleared — advancing fake timers 60 s after
close()withpollsunchanged pinsclearInterval(timer)atnode.ts:159. createClient({ url })—node.ts:37; the newtoHaveBeenLastCalledWith({ url: 'redis://x' })would fail oncreateClient({}).
File set is disjoint from #626 (chart tests) and #630 (worker tests) as the body states. One minor note, not a defect: the new shutdown case binds a random port in 23000–23999, so a rare collision with a parallel test is possible; the existing drain case already uses the same pattern, so this follows repo precedent.
Looks correct to me — a maintainer can take this at face value. (PR carries the hold label; merging stays a human call.)
— hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88
|
/kind cleanup Test-only change, same classification jeefy gave the sibling test PR #626. 🐝 Hive Agent: — hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88 |
|
Verified on main+this branch (after #633): |
Test Improvement
Assertions added to the four suites that already exercise #623's shared stores and the server's shutdown —
__tests__/adapters/app/{lock,redis}.test.ts,__tests__/server/{stores,cronInterval}.test.ts. Nosrc/, config, chart or docs change.memoryLocks— a caller arriving after the first holder has finished, while a second is still queued, must wait behind that second one. Thefinallyonly deletes the key's tail when it is still its own (lock.ts:35); if it deleted unconditionally (or on!==) the newcomer would start a fresh chain and run alongside the queued holder — exactly the race the lock exists to prevent.redisLocks— thettlMsoption (and its 60 s default) reaches theSET NX PXcall. Underoptions.ttlMs && 60_000every explicit ttl became 60 s and no test noticed.redisStores—createClientreceives{ url }; without it the client dials localhost regardless ofREDIS_URL.main()shutdown with nothing in flight — new case: the listener is closed (a secondfetchto the port is refused), the stores are closed once,exit(0)is called, and no "shutting down: waiting …" line is logged (thepending > 0guard). The existing drain case now asserts thelevelof both shutdown lines.main()+PROW_CRON_INTERVAL— afterclose()another period elapses under fake timers and the installations endpoint is not polled again, soclearInterval(timer)is asserted./healthzand/readyzbodies (ok,stores not ready).Why. Line coverage for these files is already 100 %, but a Stryker pass over
src/adapters/app/lock.ts,src/adapters/app/redis.tsandsrc/server/node.ts(172 mutants,npm run test:mutation -- --mutate …config, main@ed3bb42) left 22 survivors, 12 of them behavioural:server.close()andclearInterval(timer)deleted fromclose(),pending > 0→true, the tail-cleanup comparison inverted,??→&&onttlMs,createClient({ url })→createClient({}), and the response/log literals. With this PR the same run reports 162/172 killed; the 10 that remain are equivalent or outside the unit suite's reach: never deleting a finished key's tail (a leak only, no observable ordering change), the stored'1'value and the token'sslice(2), the>=/>deadline boundary,releaseScript→''(only theREDIS_TEST_URLreal-server case can see it: an emptyEVALreturns nil and the lock is never released, soexcludes two clients …times out inbuild-test), and the twoinstallPlatformScope(asyncLocalScope())calls, which the suites pre-install inbeforeAllfor their non-main()cases.Files / cluster claimed — the four test files above only. Disjoint from held #626 (
charts/prow-github-app/tests/**) and #630 (__tests__/worker/worker.test.ts).Testing
npx vitest run __tests__/adapters/app/lock.test.ts __tests__/adapters/app/redis.test.ts __tests__/server/stores.test.ts __tests__/server/cronInterval.test.ts— 27 passed, 3 skipped (the real-redis cases, noREDIS_TEST_URLlocally), three runs in a rownpx eslinton the four files — cleanRelated Issue
None — mutation-strength findings are held behind the gate proposal in #594; this pins the new #623 code only, and #594's decision is unaffected.
Filed by quality agent (hold-gated mode). Human review required.
— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88