@@ -45,9 +45,12 @@ import (
4545 "github.com/authzed/spicedb/pkg/tuple"
4646)
4747
48+ // Plain time.Duration spellings of the shared test constants, for the option
49+ // constructors in this package. See test.RetainAllRevisions and
50+ // test.DisableBackgroundGC for what they mean.
4851const (
49- veryLargeGCWindow = 90000 * time .Second
50- veryLargeGCInterval = 90000 * time .Second
52+ retainAllRevisions = time .Duration ( test . RetainAllRevisions )
53+ disableBackgroundGC = time .Duration ( test . DisableBackgroundGC )
5154)
5255
5356var crdbFactory = test .NewTesterFactory (& pgconn.PgError {Code : pool .CrdbRetryErrCode })
@@ -64,14 +67,14 @@ func crdbTestVersion() string {
6467func TestCRDBDatastoreWithoutIntegrity (t * testing.T ) {
6568 t .Parallel ()
6669 b := testdatastore .RunCRDBForTesting (t , crdbTestVersion ())
67- test .All (t , crdbFactory .NewTester (test .DatastoreTesterFunc (func (t testing.TB , revisionQuantization , gcInterval , gcWindow time. Duration , watchBufferLength uint16 ) (datastore.Datastore , error ) {
70+ test .All (t , crdbFactory .NewTester (test .DatastoreTesterFunc (func (t testing.TB , revisionParameters test. RevisionParameters , watchBufferLength uint16 ) (datastore.Datastore , error ) {
6871 ctx := t .Context ()
6972 ds := b .NewDatastore (t , func (engine , uri string ) datastore.Datastore {
7073 ds , err := NewCRDBDatastore (
7174 ctx ,
7275 uri ,
73- GCWindow (gcWindow ),
74- RevisionQuantization (revisionQuantization ),
76+ GCWindow (time . Duration ( revisionParameters . GCRetentionWindow ) ),
77+ RevisionQuantization (revisionParameters . Quantization ),
7578 WatchBufferLength (watchBufferLength ),
7679 OverlapStrategy (overlapStrategyPrefix ),
7780 DebugAnalyzeBeforeStatistics (),
@@ -91,31 +94,31 @@ func TestCRDBDatastoreWithoutIntegrity(t *testing.T) {
9194 b ,
9295 StreamingWatchTest ,
9396 RevisionQuantization (0 ),
94- GCWindow (veryLargeGCWindow ),
97+ GCWindow (retainAllRevisions ),
9598 WithAcquireTimeout (5 * time .Second ),
9699 ))
97100
98101 t .Run ("TestTransactionMetadataMarking" , createDatastoreTest (
99102 b ,
100103 TransactionMetadataMarkingTest ,
101104 RevisionQuantization (0 ),
102- GCWindow (veryLargeGCWindow ),
105+ GCWindow (retainAllRevisions ),
103106 WithAcquireTimeout (5 * time .Second ),
104107 ))
105108
106109 t .Run ("TestTTLChangefeedSuppressionParam" , createDatastoreTest (
107110 b ,
108111 TTLChangefeedSuppressionParamTest ,
109112 RevisionQuantization (0 ),
110- GCWindow (veryLargeGCWindow ),
113+ GCWindow (retainAllRevisions ),
111114 WithAcquireTimeout (5 * time .Second ),
112115 ))
113116
114117 t .Run ("TestTTLChangefeedSuppressionWatch" , createDatastoreTest (
115118 b ,
116119 TTLChangefeedSuppressionWatchTest ,
117120 RevisionQuantization (0 ),
118- GCWindow (veryLargeGCWindow ),
121+ GCWindow (retainAllRevisions ),
119122 WithAcquireTimeout (5 * time .Second ),
120123 ))
121124}
@@ -206,14 +209,14 @@ func TestCRDBDatastoreWithIntegrity(t *testing.T) { //nolint:tparallel
206209 t .Parallel ()
207210 b := testdatastore .RunCRDBForTesting (t , crdbTestVersion ())
208211
209- test .All (t , crdbFactory .NewTester (test .DatastoreTesterFunc (func (_ testing.TB , revisionQuantization , gcInterval , gcWindow time. Duration , watchBufferLength uint16 ) (datastore.Datastore , error ) {
212+ test .All (t , crdbFactory .NewTester (test .DatastoreTesterFunc (func (t testing.TB , revisionParameters test. RevisionParameters , watchBufferLength uint16 ) (datastore.Datastore , error ) {
210213 ctx := t .Context ()
211214 ds := b .NewDatastore (t , func (engine , uri string ) datastore.Datastore {
212215 ds , err := NewCRDBDatastore (
213216 ctx ,
214217 uri ,
215- GCWindow (gcWindow ),
216- RevisionQuantization (revisionQuantization ),
218+ GCWindow (time . Duration ( revisionParameters . GCRetentionWindow ) ),
219+ RevisionQuantization (revisionParameters . Quantization ),
217220 WatchBufferLength (watchBufferLength ),
218221 OverlapStrategy (overlapStrategyPrefix ),
219222 DebugAnalyzeBeforeStatistics (),
@@ -233,14 +236,14 @@ func TestCRDBDatastoreWithIntegrity(t *testing.T) { //nolint:tparallel
233236 return ds , nil
234237 })))
235238
236- unwrappedTester := test .DatastoreTesterFunc (func (_ testing.TB , revisionQuantization , gcInterval , gcWindow time. Duration , watchBufferLength uint16 ) (datastore.Datastore , error ) {
239+ unwrappedTester := test .DatastoreTesterFunc (func (t testing.TB , revisionParameters test. RevisionParameters , watchBufferLength uint16 ) (datastore.Datastore , error ) {
237240 ctx := t .Context ()
238241 ds := b .NewDatastore (t , func (engine , uri string ) datastore.Datastore {
239242 ds , err := NewCRDBDatastore (
240243 ctx ,
241244 uri ,
242- GCWindow (gcWindow ),
243- RevisionQuantization (revisionQuantization ),
245+ GCWindow (time . Duration ( revisionParameters . GCRetentionWindow ) ),
246+ RevisionQuantization (revisionParameters . Quantization ),
244247 WatchBufferLength (watchBufferLength ),
245248 OverlapStrategy (overlapStrategyPrefix ),
246249 DebugAnalyzeBeforeStatistics (),
@@ -391,7 +394,7 @@ func newCRDBWithUser(t *testing.T) (adminConn *pgx.Conn, connStrings map[provisi
391394func RelationshipIntegrityInfoTest (t * testing.T , tester test.DatastoreTester ) {
392395 require := require .New (t )
393396
394- rawDS , err := tester .New (t , 0 , veryLargeGCInterval , veryLargeGCWindow , 1 )
397+ rawDS , err := tester .New (t , test . DefaultRevisionParameters () , 1 )
395398 require .NoError (err )
396399
397400 ds , _ := testfixtures .StandardDatastoreWithSchema (t , rawDS )
@@ -455,7 +458,7 @@ func (f *fakeSource) Next(ctx context.Context) (*tuple.Relationship, error) {
455458func BulkRelationshipIntegrityInfoTest (t * testing.T , tester test.DatastoreTester ) {
456459 require := require .New (t )
457460
458- rawDS , err := tester .New (t , 0 , veryLargeGCInterval , veryLargeGCWindow , 1 )
461+ rawDS , err := tester .New (t , test . DefaultRevisionParameters () , 1 )
459462 require .NoError (err )
460463
461464 ds , _ := testfixtures .StandardDatastoreWithSchema (t , rawDS )
@@ -505,7 +508,7 @@ func BulkRelationshipIntegrityInfoTest(t *testing.T, tester test.DatastoreTester
505508func RelationshipIntegrityWatchTest (t * testing.T , tester test.DatastoreTester ) {
506509 require := require .New (t )
507510
508- rawDS , err := tester .New (t , 0 , veryLargeGCInterval , veryLargeGCWindow , 1 )
511+ rawDS , err := tester .New (t , test . DefaultRevisionParameters () , 1 )
509512 require .NoError (err )
510513
511514 ds , rev := testfixtures .StandardDatastoreWithSchema (t , rawDS )
0 commit comments