From cd7d6d16a1fe3391fba7753b3a770d3b0667656f Mon Sep 17 00:00:00 2001 From: vavallee Date: Wed, 30 Sep 2026 23:40:04 -0300 Subject: [PATCH] test(duplicates): scale the scan time budget under the race detector TestScanScale asserted Scan(500 books) under 100ms, which failed on a shared runner under -race (130ms) and turned main's race (non-api) shard red at 692376c6. The budget is ten times larger when the race detector is on; the normal budget is unchanged. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016fJcCVbNnKsmj2MAAMwWj9 Signed-off-by: vavallee --- changelog.d/duplicates-scan-race-budget.md | 2 ++ internal/duplicates/duplicates_test.go | 10 ++++++++-- internal/duplicates/race_off_test.go | 5 +++++ internal/duplicates/race_on_test.go | 7 +++++++ 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 changelog.d/duplicates-scan-race-budget.md create mode 100644 internal/duplicates/race_off_test.go create mode 100644 internal/duplicates/race_on_test.go diff --git a/changelog.d/duplicates-scan-race-budget.md b/changelog.d/duplicates-scan-race-budget.md new file mode 100644 index 000000000..c8710a5a7 --- /dev/null +++ b/changelog.d/duplicates-scan-race-budget.md @@ -0,0 +1,2 @@ +### Fixed +- **Duplicate review timing test no longer fails under the race detector**: its 100ms budget now scales when the race detector is on. No change to how Bindery behaves. diff --git a/internal/duplicates/duplicates_test.go b/internal/duplicates/duplicates_test.go index 85e35f9b0..a879f572b 100644 --- a/internal/duplicates/duplicates_test.go +++ b/internal/duplicates/duplicates_test.go @@ -581,8 +581,14 @@ func TestScanScale(t *testing.T) { groups := Scan(books, nil) elapsed := time.Since(start) - if elapsed > 100*time.Millisecond { - t.Errorf("Scan(500 books) took %s, budget 100ms", elapsed) + // The race detector slows Scan several fold, so the budget scales with it; + // a fixed 100ms failed on a shared CI runner under -race. + budget := 100 * time.Millisecond + if raceEnabled { + budget *= 10 + } + if elapsed > budget { + t.Errorf("Scan(500 books) took %s, budget %s", elapsed, budget) } if len(groups) != 2 { t.Fatalf("Scan = %d groups, want 2", len(groups)) diff --git a/internal/duplicates/race_off_test.go b/internal/duplicates/race_off_test.go new file mode 100644 index 000000000..3b742dd2b --- /dev/null +++ b/internal/duplicates/race_off_test.go @@ -0,0 +1,5 @@ +//go:build !race + +package duplicates + +const raceEnabled = false diff --git a/internal/duplicates/race_on_test.go b/internal/duplicates/race_on_test.go new file mode 100644 index 000000000..8892d29f5 --- /dev/null +++ b/internal/duplicates/race_on_test.go @@ -0,0 +1,7 @@ +//go:build race + +package duplicates + +// raceEnabled reports whether the race detector is on. It slows Scan several +// fold, so wall clock budgets scale with it. +const raceEnabled = true