Skip to content

Commit

Permalink
Add an integration test for schema watch
Browse files Browse the repository at this point in the history
  • Loading branch information
josephschorr committed Dec 13, 2023
1 parent 8e677b2 commit d6ff98e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions cmd/spicedb/serve_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ func TestGracefulShutdownInMemory(t *testing.T) {
}

type watchingWriter struct {
c chan bool
c chan bool
expectedString string
}

func (ww *watchingWriter) Write(p []byte) (n int, err error) {
// Ensure GC ran.
if strings.Contains(string(p), "running garbage collection worker") {
if strings.Contains(string(p), ww.expectedString) {
ww.c <- true
}

Expand Down Expand Up @@ -218,7 +218,7 @@ func TestGracefulShutdown(t *testing.T) {
})

if awaitGC {
ww := &watchingWriter{make(chan bool, 1)}
ww := &watchingWriter{make(chan bool, 1), "running garbage collection worker"}

// Grab logs and ensure GC has run before starting a graceful shutdown.
opts := docker.LogsOptions{
Expand Down
4 changes: 2 additions & 2 deletions internal/datastore/proxy/schemacaching/caching.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ func NewCachingDatastoreProxy(delegate datastore.Datastore, c cache.Cache, gcWin
// Try to instantiate a schema cache that reads updates from the datastore's schema watch stream. If not possible,
// fallback to the just-in-time caching proxy.
if watchable := datastore.UnwrapAs[datastore.SchemaWatchableDatastore](delegate); watchable != nil {
log.Info().Type("datastore-type", watchable).Msg("enabled schema caching")
log.Info().Type("datastore-type", watchable).Msg("schema watch caching enabled")
return createWatchingCacheProxy(watchable, c, gcWindow)
}

log.Info().Type("datastore-type", delegate).Msg("schema watch was enabled but datastore does not support it; falling back to just-in-time caching")
log.Info().Type("datastore-type", delegate).Msg("schema watch caching was requested but datastore does not support it; falling back to just-in-time caching")
return &definitionCachingProxy{
Datastore: delegate,
c: c,
Expand Down

0 comments on commit d6ff98e

Please sign in to comment.