Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: delete load files post successful upload #5050

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 0 additions & 127 deletions integration_test/warehouse/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ func TestUploads(t *testing.T) {
{A: "destination_id", B: destinationID},
{A: "status", B: succeeded},
}...)
requireLoadFileEventsCount(t, ctx, db, events, []lo.Tuple2[string, any]{
{A: "source_id", B: sourceID},
{A: "destination_id", B: destinationID},
}...)
requireTableUploadEventsCount(t, ctx, db, events, []lo.Tuple2[string, any]{
{A: "status", B: exportedData},
{A: "wh_uploads.source_id", B: sourceID},
Expand Down Expand Up @@ -174,10 +170,6 @@ func TestUploads(t *testing.T) {
{A: "destination_id", B: destinationID},
{A: "status", B: succeeded},
}...)
requireLoadFileEventsCount(t, ctx, db, events*2, []lo.Tuple2[string, any]{
{A: "source_id", B: sourceID},
{A: "destination_id", B: destinationID},
}...)
requireTableUploadEventsCount(t, ctx, db, events*2, []lo.Tuple2[string, any]{
{A: "status", B: exportedData},
{A: "wh_uploads.source_id", B: sourceID},
Expand Down Expand Up @@ -231,10 +223,6 @@ func TestUploads(t *testing.T) {
{A: "destination_id", B: destinationID},
{A: "status", B: succeeded},
}...)
requireLoadFileEventsCount(t, ctx, db, events, []lo.Tuple2[string, any]{
{A: "source_id", B: sourceID},
{A: "destination_id", B: destinationID},
}...)
requireTableUploadEventsCount(t, ctx, db, events, []lo.Tuple2[string, any]{
{A: "status", B: exportedData},
{A: "wh_uploads.source_id", B: sourceID},
Expand Down Expand Up @@ -283,10 +271,6 @@ func TestUploads(t *testing.T) {
{A: "destination_id", B: destinationID},
{A: "status", B: succeeded},
}...)
requireLoadFileEventsCount(t, ctx, db, events*2, []lo.Tuple2[string, any]{
{A: "source_id", B: sourceID},
{A: "destination_id", B: destinationID},
}...)
requireTableUploadEventsCount(t, ctx, db, events*2, []lo.Tuple2[string, any]{
{A: "status", B: exportedData},
{A: "wh_uploads.source_id", B: sourceID},
Expand Down Expand Up @@ -412,10 +396,6 @@ func TestUploads(t *testing.T) {
{A: "destination_id", B: destinationID},
{A: "status", B: succeeded},
}...)
requireLoadFileEventsCount(t, ctx, db, events, []lo.Tuple2[string, any]{
{A: "source_id", B: sourceID},
{A: "destination_id", B: destinationID},
}...)
requireTableUploadEventsCount(t, ctx, db, events, []lo.Tuple2[string, any]{
{A: "status", B: exportedData},
{A: "wh_uploads.source_id", B: sourceID},
Expand Down Expand Up @@ -526,10 +506,6 @@ func TestUploads(t *testing.T) {
{A: "destination_id", B: destinationID},
{A: "status", B: succeeded},
}...)
requireLoadFileEventsCount(t, ctx, db, events, []lo.Tuple2[string, any]{
{A: "source_id", B: sourceID},
{A: "destination_id", B: destinationID},
}...)
requireTableUploadEventsCount(t, ctx, db, events, []lo.Tuple2[string, any]{
{A: "status", B: exportedData},
{A: "wh_uploads.source_id", B: sourceID},
Expand Down Expand Up @@ -602,10 +578,6 @@ func TestUploads(t *testing.T) {
{A: "destination_id", B: destinationID},
{A: "status", B: succeeded},
}...)
requireLoadFileEventsCount(t, ctx, db, events, []lo.Tuple2[string, any]{
{A: "source_id", B: sourceID},
{A: "destination_id", B: destinationID},
}...)
requireTableUploadEventsCount(t, ctx, db, events, []lo.Tuple2[string, any]{
{A: "status", B: exportedData},
{A: "wh_uploads.source_id", B: sourceID},
Expand Down Expand Up @@ -803,10 +775,6 @@ func TestUploads(t *testing.T) {
{A: "destination_id", B: destinationID},
{A: "status", B: succeeded},
}...)
requireLoadFileEventsCount(t, ctx, db, events+(events/2), []lo.Tuple2[string, any]{
{A: "source_id", B: sourceID},
{A: "destination_id", B: destinationID},
}...)
requireTableUploadEventsCount(t, ctx, db, events+(events/2), []lo.Tuple2[string, any]{
{A: "status", B: exportedData},
{A: "wh_uploads.source_id", B: sourceID},
Expand Down Expand Up @@ -929,10 +897,6 @@ func TestUploads(t *testing.T) {
{A: "destination_id", B: destinationID},
{A: "status", B: succeeded},
}...)
requireLoadFileEventsCount(t, ctx, db, events, []lo.Tuple2[string, any]{
{A: "source_id", B: sourceID},
{A: "destination_id", B: destinationID},
}...)
requireTableUploadEventsCount(t, ctx, db, events, []lo.Tuple2[string, any]{
{A: "status", B: exportedData},
{A: "wh_uploads.source_id", B: sourceID},
Expand All @@ -954,10 +918,6 @@ func TestUploads(t *testing.T) {
{A: "destination_id", B: destinationID},
{A: "status", B: succeeded},
}...)
requireLoadFileEventsCount(t, ctx, db, events*2, []lo.Tuple2[string, any]{
{A: "source_id", B: sourceID},
{A: "destination_id", B: destinationID},
}...)
requireTableUploadEventsCount(t, ctx, db, events*2, []lo.Tuple2[string, any]{
{A: "status", B: exportedData},
{A: "wh_uploads.source_id", B: sourceID},
Expand Down Expand Up @@ -1018,10 +978,6 @@ func TestUploads(t *testing.T) {
{A: "destination_id", B: destinationID},
{A: "status", B: succeeded},
}...)
requireLoadFileEventsCount(t, ctx, db, events, []lo.Tuple2[string, any]{
{A: "source_id", B: sourceID},
{A: "destination_id", B: destinationID},
}...)
requireTableUploadEventsCount(t, ctx, db, events, []lo.Tuple2[string, any]{
{A: "status", B: exportedData},
{A: "wh_uploads.source_id", B: sourceID},
Expand All @@ -1043,10 +999,6 @@ func TestUploads(t *testing.T) {
{A: "destination_id", B: destinationID},
{A: "status", B: succeeded},
}...)
requireLoadFileEventsCount(t, ctx, db, events*2, []lo.Tuple2[string, any]{
{A: "source_id", B: sourceID},
{A: "destination_id", B: destinationID},
}...)
requireTableUploadEventsCount(t, ctx, db, events*2, []lo.Tuple2[string, any]{
{A: "status", B: exportedData},
{A: "wh_uploads.source_id", B: sourceID},
Expand Down Expand Up @@ -1107,10 +1059,6 @@ func TestUploads(t *testing.T) {
{A: "destination_id", B: destinationID},
{A: "status", B: succeeded},
}...)
requireLoadFileEventsCount(t, ctx, db, events, []lo.Tuple2[string, any]{
{A: "source_id", B: sourceID},
{A: "destination_id", B: destinationID},
}...)
requireTableUploadEventsCount(t, ctx, db, events, []lo.Tuple2[string, any]{
{A: "status", B: exportedData},
{A: "wh_uploads.source_id", B: sourceID},
Expand All @@ -1132,10 +1080,6 @@ func TestUploads(t *testing.T) {
{A: "destination_id", B: destinationID},
{A: "status", B: succeeded},
}...)
requireLoadFileEventsCount(t, ctx, db, events*2, []lo.Tuple2[string, any]{
{A: "source_id", B: sourceID},
{A: "destination_id", B: destinationID},
}...)
requireTableUploadEventsCount(t, ctx, db, events*2, []lo.Tuple2[string, any]{
{A: "status", B: exportedData},
{A: "wh_uploads.source_id", B: sourceID},
Expand Down Expand Up @@ -1196,10 +1140,6 @@ func TestUploads(t *testing.T) {
{A: "destination_id", B: destinationID},
{A: "status", B: succeeded},
}...)
requireLoadFileEventsCount(t, ctx, db, events, []lo.Tuple2[string, any]{
{A: "source_id", B: sourceID},
{A: "destination_id", B: destinationID},
}...)
requireTableUploadEventsCount(t, ctx, db, events, []lo.Tuple2[string, any]{
{A: "status", B: exportedData},
{A: "wh_uploads.source_id", B: sourceID},
Expand All @@ -1221,10 +1161,6 @@ func TestUploads(t *testing.T) {
{A: "destination_id", B: destinationID},
{A: "status", B: succeeded},
}...)
requireLoadFileEventsCount(t, ctx, db, events*2, []lo.Tuple2[string, any]{
{A: "source_id", B: sourceID},
{A: "destination_id", B: destinationID},
}...)
requireTableUploadEventsCount(t, ctx, db, events*2, []lo.Tuple2[string, any]{
{A: "status", B: exportedData},
{A: "wh_uploads.source_id", B: sourceID},
Expand Down Expand Up @@ -1288,10 +1224,6 @@ func TestUploads(t *testing.T) {
{A: "destination_id", B: destinationID},
{A: "status", B: succeeded},
}...)
requireLoadFileEventsCount(t, ctx, db, events, []lo.Tuple2[string, any]{
{A: "source_id", B: sourceID},
{A: "destination_id", B: destinationID},
}...)
requireTableUploadEventsCount(t, ctx, db, events, []lo.Tuple2[string, any]{
{A: "status", B: exportedData},
{A: "wh_uploads.source_id", B: sourceID},
Expand All @@ -1313,10 +1245,6 @@ func TestUploads(t *testing.T) {
{A: "destination_id", B: destinationID},
{A: "status", B: succeeded},
}...)
requireLoadFileEventsCount(t, ctx, db, events*2, []lo.Tuple2[string, any]{
{A: "source_id", B: sourceID},
{A: "destination_id", B: destinationID},
}...)
requireTableUploadEventsCount(t, ctx, db, events*2, []lo.Tuple2[string, any]{
{A: "status", B: exportedData},
{A: "wh_uploads.source_id", B: sourceID},
Expand Down Expand Up @@ -1380,10 +1308,6 @@ func TestUploads(t *testing.T) {
{A: "destination_id", B: destinationID},
{A: "status", B: succeeded},
}...)
requireLoadFileEventsCount(t, ctx, db, events, []lo.Tuple2[string, any]{
{A: "source_id", B: sourceID},
{A: "destination_id", B: destinationID},
}...)
requireTableUploadEventsCount(t, ctx, db, events, []lo.Tuple2[string, any]{
{A: "status", B: exportedData},
{A: "wh_uploads.source_id", B: sourceID},
Expand All @@ -1405,10 +1329,6 @@ func TestUploads(t *testing.T) {
{A: "destination_id", B: destinationID},
{A: "status", B: succeeded},
}...)
requireLoadFileEventsCount(t, ctx, db, events*2, []lo.Tuple2[string, any]{
{A: "source_id", B: sourceID},
{A: "destination_id", B: destinationID},
}...)
requireTableUploadEventsCount(t, ctx, db, events*2, []lo.Tuple2[string, any]{
{A: "status", B: exportedData},
{A: "wh_uploads.source_id", B: sourceID},
Expand Down Expand Up @@ -1472,10 +1392,6 @@ func TestUploads(t *testing.T) {
{A: "destination_id", B: destinationID},
{A: "status", B: succeeded},
}...)
requireLoadFileEventsCount(t, ctx, db, events, []lo.Tuple2[string, any]{
{A: "source_id", B: sourceID},
{A: "destination_id", B: destinationID},
}...)
requireTableUploadEventsCount(t, ctx, db, events, []lo.Tuple2[string, any]{
{A: "status", B: exportedData},
{A: "wh_uploads.source_id", B: sourceID},
Expand All @@ -1497,10 +1413,6 @@ func TestUploads(t *testing.T) {
{A: "destination_id", B: destinationID},
{A: "status", B: succeeded},
}...)
requireLoadFileEventsCount(t, ctx, db, events*2, []lo.Tuple2[string, any]{
{A: "source_id", B: sourceID},
{A: "destination_id", B: destinationID},
}...)
requireTableUploadEventsCount(t, ctx, db, events*2, []lo.Tuple2[string, any]{
{A: "status", B: exportedData},
{A: "wh_uploads.source_id", B: sourceID},
Expand Down Expand Up @@ -1574,10 +1486,6 @@ func TestUploads(t *testing.T) {
{A: "destination_id", B: destinationID},
{A: "status", B: succeeded},
}...)
requireLoadFileEventsCount(t, ctx, db, events*3, []lo.Tuple2[string, any]{
{A: "source_id", B: sourceID},
{A: "destination_id", B: destinationID},
}...)
requireTableUploadEventsCount(t, ctx, db, events*3, []lo.Tuple2[string, any]{
{A: "status", B: waiting},
{A: "wh_uploads.source_id", B: sourceID},
Expand Down Expand Up @@ -1787,41 +1695,6 @@ func requireStagingFileEventsCount(
)
}

// nolint:unparam
func requireLoadFileEventsCount(
t testing.TB,
ctx context.Context,
db *sqlmw.DB,
expectedCount int,
filters ...lo.Tuple2[string, any],
) {
t.Helper()

query := "SELECT COALESCE(sum(total_events), 0) FROM wh_load_files WHERE 1 = 1"
query += strings.Join(lo.Map(filters, func(t lo.Tuple2[string, any], index int) string {
return fmt.Sprintf(" AND %s = $%d", t.A, index+1)
}), "")
queryArgs := lo.Map(filters, func(t lo.Tuple2[string, any], _ int) any {
return t.B
})

require.Eventuallyf(t,
func() bool {
var eventsCount int
err := db.QueryRowContext(ctx, query, queryArgs...).Scan(&eventsCount)
if err != nil {
t.Logf("error getting load file events count: %v", err)
return false
}
t.Logf("Load file events count: %d", eventsCount)
return eventsCount == expectedCount
},
10*time.Second,
250*time.Millisecond,
"expected load file events count to be %d", expectedCount,
)
}

// nolint:unparam
func requireTableUploadEventsCount(
t testing.TB,
Expand Down
1 change: 0 additions & 1 deletion warehouse/integrations/testhelper/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ func (w *TestConfig) VerifyEvents(t testing.TB) {
createStagingFile(t, w)

verifyEventsInStagingFiles(t, w)
verifyEventsInLoadFiles(t, w)
verifyEventsInTableUploads(t, w)

if w.SourceJob {
Expand Down
50 changes: 0 additions & 50 deletions warehouse/integrations/testhelper/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,56 +69,6 @@ func verifyEventsInStagingFiles(t testing.TB, testConfig *TestConfig) {
t.Logf("Completed verifying events in staging files")
}

func verifyEventsInLoadFiles(t testing.TB, testConfig *TestConfig) {
t.Helper()

t.Logf("Started verifying events in load file")

for _, table := range testConfig.Tables {
sqlStatement := `
SELECT
SUM(total_events) AS sum
FROM
wh_load_files
WHERE
source_id = $1
AND destination_id = $2
AND created_at > $3
AND table_name = $4;`
t.Logf("Checking events in load files for SrcID: %s, DestID: %s, TimestampBeforeSendingEvents: %s, "+
"Table: %s, sqlStatement: %s",
testConfig.SourceID, testConfig.DestinationID, testConfig.TimestampBeforeSendingEvents,
whutils.ToProviderCase(testConfig.DestinationType, table), sqlStatement,
)

var err error
var count sql.NullInt64
expectedCount := int64(testConfig.LoadFilesEventsMap[table])

operation := func() bool {
err = testConfig.JobsDB.QueryRow(sqlStatement,
testConfig.SourceID, testConfig.DestinationID, testConfig.TimestampBeforeSendingEvents,
whutils.ToProviderCase(testConfig.DestinationType, table),
).Scan(&count)

if err == nil && count.Int64 != expectedCount {
t.Logf("Expected load files events count for table %q is %d, got %d",
table, expectedCount, count.Int64,
)
}

return err == nil && count.Int64 == expectedCount
}
// Expected load files events count for table _groups is 0, got 0: <nil>
require.Eventuallyf(t, operation, WaitFor10Minute, DefaultQueryFrequency,
"Expected load files events count for table %q is %d, got %d: %v",
table, expectedCount, count, err,
)
}

t.Logf("Completed verifying events in load files")
}

func verifyEventsInTableUploads(t testing.TB, testConfig *TestConfig) {
t.Helper()

Expand Down
Loading
Loading