Skip to content

Commit

Permalink
Merge pull request #1655 from josephschorr/postgres-gc-test-window
Browse files Browse the repository at this point in the history
Fix flaky Postgres GC tests
  • Loading branch information
vroldanbet authored Jan 30, 2024
2 parents 395f2c9 + 450b1f7 commit 04c7255
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 30 deletions.
30 changes: 0 additions & 30 deletions internal/datastore/postgres/postgres_shared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,6 @@ func testPostgresDatastore(t *testing.T, pc []postgresConfig) {
return ds, nil
}))

t.Run("GarbageCollection", createDatastoreTest(
b,
GarbageCollectionTest,
RevisionQuantization(0),
GCWindow(1*time.Millisecond),
GCInterval(veryLargeGCInterval),
WatchBufferLength(1),
MigrationPhase(config.migrationPhase),
))

t.Run("TransactionTimestamps", createDatastoreTest(
b,
TransactionTimestampsTest,
Expand All @@ -122,26 +112,6 @@ func testPostgresDatastore(t *testing.T, pc []postgresConfig) {
MigrationPhase(config.migrationPhase),
))

t.Run("GarbageCollectionByTime", createDatastoreTest(
b,
GarbageCollectionByTimeTest,
RevisionQuantization(0),
GCWindow(1*time.Millisecond),
GCInterval(veryLargeGCInterval),
WatchBufferLength(1),
MigrationPhase(config.migrationPhase),
))

t.Run("ChunkedGarbageCollection", createDatastoreTest(
b,
ChunkedGarbageCollectionTest,
RevisionQuantization(0),
GCWindow(1*time.Millisecond),
GCInterval(veryLargeGCInterval),
WatchBufferLength(1),
MigrationPhase(config.migrationPhase),
))

t.Run("QuantizedRevisions", func(t *testing.T) {
QuantizedRevisionTest(t, b)
})
Expand Down
48 changes: 48 additions & 0 deletions internal/datastore/postgres/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
package postgres

import (
"fmt"
"testing"
"time"

testdatastore "github.com/authzed/spicedb/internal/testserver/datastore"
)

func TestPostgresDatastore(t *testing.T) {
Expand All @@ -18,3 +22,47 @@ func TestPostgresDatastoreWithoutCommitTimestamps(t *testing.T) {

testPostgresDatastoreWithoutCommitTimestamps(t, postgresConfigs)
}

func TestPostgresDatastoreGC(t *testing.T) {
for _, config := range postgresConfigs {
pgbouncerStr := ""
if config.pgbouncer {
pgbouncerStr = "pgbouncer-"
}
t.Run(fmt.Sprintf("%spostgres-gc-%s-%s-%s", pgbouncerStr, config.pgVersion, config.targetMigration, config.migrationPhase), func(t *testing.T) {
t.Parallel()

b := testdatastore.RunPostgresForTesting(t, "", config.targetMigration, config.pgVersion, config.pgbouncer)

t.Run("GarbageCollection", createDatastoreTest(
b,
GarbageCollectionTest,
RevisionQuantization(0),
GCWindow(1*time.Millisecond),
GCInterval(veryLargeGCInterval),
WatchBufferLength(1),
MigrationPhase(config.migrationPhase),
))

t.Run("GarbageCollectionByTime", createDatastoreTest(
b,
GarbageCollectionByTimeTest,
RevisionQuantization(0),
GCWindow(1*time.Millisecond),
GCInterval(veryLargeGCInterval),
WatchBufferLength(1),
MigrationPhase(config.migrationPhase),
))

t.Run("ChunkedGarbageCollection", createDatastoreTest(
b,
ChunkedGarbageCollectionTest,
RevisionQuantization(0),
GCWindow(1*time.Millisecond),
GCInterval(veryLargeGCInterval),
WatchBufferLength(1),
MigrationPhase(config.migrationPhase),
))
})
}
}

0 comments on commit 04c7255

Please sign in to comment.