From 450b1f7f1adb546eccf05083cffc19e2f2679a2b Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Thu, 16 Nov 2023 16:58:15 -0500 Subject: [PATCH] WIP: Try to remove PG GC flakes --- .../postgres/postgres_shared_test.go | 30 ------------ internal/datastore/postgres/postgres_test.go | 48 +++++++++++++++++++ 2 files changed, 48 insertions(+), 30 deletions(-) diff --git a/internal/datastore/postgres/postgres_shared_test.go b/internal/datastore/postgres/postgres_shared_test.go index 6d66a48e38..e4affaceb6 100644 --- a/internal/datastore/postgres/postgres_shared_test.go +++ b/internal/datastore/postgres/postgres_shared_test.go @@ -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, @@ -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) }) diff --git a/internal/datastore/postgres/postgres_test.go b/internal/datastore/postgres/postgres_test.go index ab3057c1ef..1256972d33 100644 --- a/internal/datastore/postgres/postgres_test.go +++ b/internal/datastore/postgres/postgres_test.go @@ -4,7 +4,11 @@ package postgres import ( + "fmt" "testing" + "time" + + testdatastore "github.com/authzed/spicedb/internal/testserver/datastore" ) func TestPostgresDatastore(t *testing.T) { @@ -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), + )) + }) + } +}