Fix flaky compactor tests due to timestamp race condition
The createClosedIssue helper was setting ClosedAt to time.Now(), but the eligibility check uses '<= datetime(now, -0 days)'. This created a race condition where if nanoseconds elapsed between issue creation and the query, the issue would fail eligibility checks. Changed to now.Add(-1*time.Second) to ensure issues are always eligible when compact_tier1_days is set to 0 for testing. Fixes bd-18 Amp-Thread-ID: https://ampcode.com/threads/T-bc303dd9-f0e7-4d52-8908-e433d429ac4a Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -35,6 +35,7 @@ func createClosedIssue(t *testing.T, store *sqlite.SQLiteStorage, id string) *ty
|
|||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
closedAt := now.Add(-1 * time.Second)
|
||||||
issue := &types.Issue{
|
issue := &types.Issue{
|
||||||
ID: id,
|
ID: id,
|
||||||
Title: "Test Issue",
|
Title: "Test Issue",
|
||||||
@@ -83,7 +84,7 @@ Testing strategy:
|
|||||||
IssueType: types.TypeTask,
|
IssueType: types.TypeTask,
|
||||||
CreatedAt: now.Add(-48 * time.Hour),
|
CreatedAt: now.Add(-48 * time.Hour),
|
||||||
UpdatedAt: now.Add(-24 * time.Hour),
|
UpdatedAt: now.Add(-24 * time.Hour),
|
||||||
ClosedAt: &now,
|
ClosedAt: &closedAt,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := store.CreateIssue(ctx, issue, "test"); err != nil {
|
if err := store.CreateIssue(ctx, issue, "test"); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user