test: date-independent collector suite + de-flaked client idle-conn test
What
Two test-robustness fixes that were threatening the CI gate. Both are test-only -- no production code changed.
Problem 1: collector test date rot (gate-blocking)
go test ./internal/collector/ was failing on clean main (e.g. expected 3 events, got 6). The collector derives its window from time.Now() and splits it into calendar-month chunks. Several per-resource tests used WindowDays: 1 with date-blind mock servers that replayed the same fixture for every chunk; once the real calendar advanced so the 1-day window straddled a month boundary, the fixture was served twice and counts doubled.
Fix: Stamp fixtures relative to now (inWindow(seq) helper) and make the affected mocks honor the request's chunk-window query params (after/before for events, created_after/created_before for MRs/issues) -- replaying each record only in the chunk that contains its created_at. Each record is now in-window and served exactly once for any "now", so counts are stable regardless of the calendar date. The MR pagination mock now keys on the page query param and carries the chunk window through the Link header so page 2 is filtered too.
Pure unit tests (monthlyChunks, watermark, stream) already used fixed dates not compared to time.Now() and were left untouched. Integration/orchestrator/incremental tests already used lower-bound or ID-dedup assertions and were already date-independent.
Date-independence argument: every converted fixture is stamped at start-of-current-day + 6h (per inWindow). For any "now", that timestamp is inside the window [midnight(now)-WindowDays, now+24h), and because it sits on a single calendar day it falls inside exactly one monthly chunk -- so the window-honoring mock serves it once. Verified by simulating 400 consecutive "now" values across WindowDays {1,30,90} (covering every month boundary): each record matched exactly one chunk in all cases.
Problem 2: client idle-connection flake
TestTunedTransport_ReusesIdleConnections asserted an exact bound on newly-dialed connections, which flaked on CI runner timing. Replaced with two timing-tolerant invariants that assert the behavior under test (idle connections are reused):
- total dials across both bursts are strictly fewer than total requests;
- the second burst dials fewer than
concurrencyfresh connections.
Both still fail if reuse regresses -- verified by temporarily disabling keep-alives locally (every request re-dialed; both invariants fired), then reverting.
Validation
make check(go vet +go test ./..., no -race): all packages green.go test ./internal/collector/ ./internal/client/ -race -count=2: clean.go test ./internal/collector/ ./internal/client/ -count=3: stable.
Do not auto-merge.