Skip to content

Commit

Permalink
nit(nvidia/xid-sxid-state): make purge tests less flaky
Browse files Browse the repository at this point in the history
Signed-off-by: Gyuho Lee <[email protected]>
  • Loading branch information
gyuho committed Jan 6, 2025
1 parent 7b87ba8 commit 76af8d1
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ func TestCreateDeleteStatementAndArgs(t *testing.T) {
func TestPurgeXidSxid(t *testing.T) {
t.Parallel()

nowUTC := time.Now().UTC()

tests := []struct {
name string
setup []Event
Expand Down Expand Up @@ -430,7 +432,7 @@ func TestPurgeXidSxid(t *testing.T) {
name: "delete events with large dataset",
setup: func() []Event {
events := make([]Event, 100)
baseTime := time.Now().Unix()
baseTime := nowUTC.Unix()
for i := 0; i < 100; i++ {
events[i] = Event{
UnixSeconds: baseTime + int64(i*60), // Events 1 minute apart
Expand All @@ -442,14 +444,14 @@ func TestPurgeXidSxid(t *testing.T) {
}
return events
}(),
opts: []OpOption{WithBefore(time.Now().Add(30 * time.Minute))},
opts: []OpOption{WithBefore(nowUTC.Add(30 * time.Minute))},
wantPurged: 30,
wantCount: 70,
validate: func(t *testing.T, events []Event) {
if len(events) != 70 {
t.Errorf("expected 70 events, got %d", len(events))
}
cutoff := time.Now().Add(30 * time.Minute).Unix()
cutoff := nowUTC.Add(30 * time.Minute).Unix()
for _, e := range events {
if e.UnixSeconds < cutoff {
t.Errorf("found event with timestamp %d, which is before cutoff %d",
Expand Down

0 comments on commit 76af8d1

Please sign in to comment.