Skip to content

Commit d98a293

Browse files
authored
fix: Add time delay in DeleteStaleAll test for destinations (#2191)
This fixes a problem that we have in the `DeleteStaleAll` test for destinations which leads to flakey tests due to a lack of time difference between the insert and delete operations. We have already fixed this in the `DeleteStaleBasic` test here: https://github.com/cloudquery/plugin-sdk/blob/main/plugin/testing_write_delete.go#L58
1 parent 2e3c192 commit d98a293

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

plugin/testing_write_delete.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ func (s *WriterTestSuite) testDeleteStaleBasic(ctx context.Context, t *testing.T
5353
r.EqualValuesf(1, TotalRows(records), "unexpected amount of items after delete stale")
5454
r.Emptyf(RecordsDiff(table.ToArrowSchema(), records, []arrow.Record{record1}), "record differs after delete stale")
5555

56+
syncTime = syncTime.Add(time.Second)
5657
bldr.Field(0).(*array.Int64Builder).Append(1)
5758
bldr.Field(1).(*array.StringBuilder).Append(sourceName)
58-
bldr.Field(2).(*array.TimestampBuilder).AppendTime(syncTime.Add(time.Second))
59+
bldr.Field(2).(*array.TimestampBuilder).AppendTime(syncTime)
5960
record2 := bldr.NewRecord()
6061

6162
r.NoErrorf(s.plugin.writeOne(ctx, &message.WriteInsert{Record: record2}), "failed to insert second record")
@@ -70,7 +71,7 @@ func (s *WriterTestSuite) testDeleteStaleBasic(ctx context.Context, t *testing.T
7071
r.NoErrorf(s.plugin.writeOne(ctx, &message.WriteDeleteStale{
7172
TableName: table.Name,
7273
SourceName: sourceName,
73-
SyncTime: syncTime.Add(time.Second),
74+
SyncTime: syncTime,
7475
}), "failed to delete stale records second time")
7576

7677
records, err = s.plugin.readAll(ctx, table)
@@ -117,7 +118,7 @@ func (s *WriterTestSuite) testDeleteStaleAll(ctx context.Context, t *testing.T)
117118
r.EqualValuesf(rowsPerRecord, TotalRows(readRecords), "unexpected amount of items after delete stale")
118119

119120
// https://github.com/golang/go/issues/41087
120-
syncTime = time.Now().UTC().Truncate(time.Microsecond)
121+
syncTime = syncTime.Add(time.Second)
121122
nullRecord := tg.Generate(table, schema.GenTestDataOptions{
122123
MaxRows: rowsPerRecord,
123124
TimePrecision: s.genDatOptions.TimePrecision,
@@ -144,6 +145,7 @@ func (s *WriterTestSuite) testDeleteStaleAll(ctx context.Context, t *testing.T)
144145
readRecords, err = s.plugin.readAll(ctx, table)
145146
r.NoErrorf(err, "failed to read after second delete stale")
146147
sortRecords(table, readRecords, "id")
148+
147149
r.EqualValuesf(rowsPerRecord, TotalRows(readRecords), "unexpected amount of items after second delete stale")
148150
r.Emptyf(RecordsDiff(table.ToArrowSchema(), readRecords, []arrow.Record{nullRecord}), "record differs")
149151
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy