Skip to content

Commit

Permalink
datasore: test that all datastores serialize revisions compatible wit…
Browse files Browse the repository at this point in the history
…h dispatch
  • Loading branch information
jakedt committed Oct 24, 2022
1 parent 6de017f commit 93ede83
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/datastore/test/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func All(t *testing.T, tester DatastoreTester) {
t.Run("TestConcurrentWriteSerialization", func(t *testing.T) { ConcurrentWriteSerializationTest(t, tester) })

t.Run("TestRevisionQuantization", func(t *testing.T) { RevisionQuantizationTest(t, tester) })
t.Run("TestRevisionSerialization", func(t *testing.T) { RevisionSerializationTest(t, tester) })

t.Run("TestWatch", func(t *testing.T) { WatchTest(t, tester) })
t.Run("TestWatchCancel", func(t *testing.T) { WatchCancelTest(t, tester) })
Expand Down
23 changes: 23 additions & 0 deletions pkg/datastore/test/revisions.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/authzed/spicedb/internal/datastore/common"
"github.com/authzed/spicedb/pkg/datastore"
core "github.com/authzed/spicedb/pkg/proto/core/v1"
dispatch "github.com/authzed/spicedb/pkg/proto/dispatch/v1"
)

// RevisionQuantizationTest tests whether or not the requirements for revisions hold
Expand Down Expand Up @@ -65,3 +66,25 @@ func RevisionQuantizationTest(t *testing.T, tester DatastoreTester) {
})
}
}

// RevisionSerializationTest tests whether the revisions generated by this datastore can
// be serialized and sent through the dispatch layer.
func RevisionSerializationTest(t *testing.T, tester DatastoreTester) {
require := require.New(t)

ds, err := tester.New(0, veryLargeGCWindow, 1)
require.NoError(err)

ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
revToTest, err := ds.ReadWriteTx(ctx, func(ctx context.Context, rwt datastore.ReadWriteTransaction) error {
return rwt.WriteNamespaces(testNamespace)
})
require.NoError(err)

meta := dispatch.ResolverMeta{
AtRevision: revToTest.String(),
DepthRemaining: 50,
}
require.NoError(meta.Validate())
}

0 comments on commit 93ede83

Please sign in to comment.