Skip to content

Commit

Permalink
add longer backoff to postgres tests
Browse files Browse the repository at this point in the history
so they pass on limited compute in CI
  • Loading branch information
vroldanbet committed Oct 1, 2024
1 parent 55d31f8 commit a00bf58
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/testserver/datastore/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ func (b *postgresTester) NewDatabase(t testing.TB) string {
}

const (
retryCount = 3
timeBetweenRetries = 100 * time.Millisecond
retryCount = 4
timeBetweenRetries = 1 * time.Second
)

func (b *postgresTester) NewDatastore(t testing.TB, initFunc InitFunc) datastore.Datastore {
for i := 0; i < retryCount; i++ {
for i := 1; i <= retryCount; i++ {
connectStr := b.NewDatabase(t)

migrationDriver, err := pgmigrations.NewAlembicPostgresDriver(context.Background(), connectStr, datastore.NoCredentialsProvider)
Expand All @@ -144,11 +144,11 @@ func (b *postgresTester) NewDatastore(t testing.TB, initFunc InitFunc) datastore
return initFunc("postgres", connectStr)
}

if i == retryCount-1 {
if i == retryCount {
require.NoError(t, err, "got error when trying to create migration driver")
}

time.Sleep(timeBetweenRetries)
time.Sleep(time.Duration(i) * timeBetweenRetries)
}

require.Fail(t, "failed to create datastore for testing")
Expand Down

0 comments on commit a00bf58

Please sign in to comment.