Seed the retention tests 50 rows per insert, not 500 (closes #198)
check / check (push) Successful in 3m25s

internal/database was the slowest test package, and three retention tests were nearly all of it. Most of their time went to seeding thousands of rows 500 per INSERT: the SQLite driver finds each parameter's value by scanning all of the statement's arguments, so binding grows with the square of the parameter count, and a 500-row insert carries several thousand. Seeding 50 rows per insert stores the same rows. No test case or assertion changes. The header of script/test records the new figures; its 90s timeout stays.

Model: opus-5-5
This commit is contained in:
2026-10-02 13:15:30 +00:00
parent c706199389
commit 8bd751d022
2 changed files with 15 additions and 5 deletions
+10 -4
View File
@@ -102,6 +102,12 @@ func TestWebhookDBManager_TotalsSurviveReopen(t *testing.T) {
// seedExpiredEvents stores count events created at the given time,
// each with a delivered delivery to one target and a failed delivery
// to the other, and one attempt for each delivery.
//
// It and seedBareEvents insert 50 rows per statement, not more. The
// SQLite driver looks up each parameter's value by scanning all of the
// statement's arguments, so the time to bind a statement grows with the
// square of its parameter count: at 500 rows, several thousand
// parameters, the seeding took most of these tests' time under -race.
func seedExpiredEvents(
t *testing.T,
db *gorm.DB,
@@ -138,8 +144,8 @@ func seedExpiredEvents(
)
}
require.NoError(t, db.CreateInBatches(events, 500).Error)
require.NoError(t, db.CreateInBatches(deliveries, 500).Error)
require.NoError(t, db.CreateInBatches(events, 50).Error)
require.NoError(t, db.CreateInBatches(deliveries, 50).Error)
results := make([]database.DeliveryResult, len(deliveries))
for i := range deliveries {
@@ -148,7 +154,7 @@ func seedExpiredEvents(
}
}
require.NoError(t, db.CreateInBatches(results, 500).Error)
require.NoError(t, db.CreateInBatches(results, 50).Error)
}
// seedBareEvents stores count events created at the given time, with
@@ -172,7 +178,7 @@ func seedBareEvents(
events[i].CreatedAt = createdAt
}
require.NoError(t, db.CreateInBatches(events, 500).Error)
require.NoError(t, db.CreateInBatches(events, 50).Error)
}
// TestRetentionReaper_PrunesMoreThanOneBatch verifies that a prune