Skip to content

Commit

Permalink
chore: review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
achettyiitr committed Jul 13, 2023
1 parent 0ac4a4b commit c8d815b
Showing 1 changed file with 50 additions and 14 deletions.
64 changes: 50 additions & 14 deletions warehouse/integrations/datalake/datalake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import (
"fmt"
"os"
"strconv"
"strings"
"testing"
"time"

"github.com/minio/minio-go/v7"

"cloud.google.com/go/storage"

"google.golang.org/api/option"
Expand Down Expand Up @@ -361,19 +364,29 @@ func TestIntegration(t *testing.T) {
require.NoError(t, err)

require.Eventually(t, func() bool {
_, err := db.ExecContext(ctx, "SELECT 1")
_, err := db.ExecContext(ctx, `SELECT 1`)
return err == nil
}, 60*time.Second, 1*time.Second)
},
60*time.Second,
100*time.Millisecond,
)

require.NoError(t, testhelper.WithConstantRetries(func() error {
require.Eventually(t, func() bool {
_, err = db.ExecContext(ctx, `
CREATE SCHEMA IF NOT EXISTS minio.rudderstack WITH (
location = 's3a://`+s3BucketName+`/')
`)
return err
}))
if err != nil {
t.Log("create schema: ", err)
return false
}
return true
},
60*time.Second,
1*time.Second,
)

require.NoError(t, testhelper.WithConstantRetries(func() error {
require.Eventually(t, func() bool {
_, err = db.ExecContext(ctx, `
CREATE TABLE IF NOT EXISTS minio.rudderstack.tracks (
"_timestamp" TIMESTAMP,
Expand All @@ -400,31 +413,54 @@ func TestIntegration(t *testing.T) {
format = 'PARQUET'
)
`)
return err
}))
if err != nil {
t.Log("create table: ", err)
return false
}
return true
},
60*time.Second,
1*time.Second,
)

var count int64

require.NoError(t, testhelper.WithConstantRetries(func() error {
return db.QueryRowContext(ctx, `
require.Eventually(t, func() bool {
err := db.QueryRowContext(ctx, `
select
count(*)
from
minio.rudderstack.tracks
`).Scan(&count)
}))
if err != nil {
t.Log("select count: ", err)
return false
}
return true
},
60*time.Second,
1*time.Second,
)
require.Equal(t, int64(8), count)

require.NoError(t, testhelper.WithConstantRetries(func() error {
return db.QueryRowContext(ctx, `
require.Eventually(t, func() bool {
err := db.QueryRowContext(ctx, `
select
count(*)
from
minio.rudderstack.tracks
where
context_destination_id = '`+s3DestinationID+`'
`).Scan(&count)
}))
if err != nil {
t.Log("select count with where clause: ", err)
return false
}
return true
},
60*time.Second,
1*time.Second,
)
require.Equal(t, int64(8), count)
})

Expand Down

0 comments on commit c8d815b

Please sign in to comment.