diff --git a/internal/dispatch/graph/check_test.go b/internal/dispatch/graph/check_test.go index 0414c42a2b..fe85bd1263 100644 --- a/internal/dispatch/graph/check_test.go +++ b/internal/dispatch/graph/check_test.go @@ -5,9 +5,8 @@ import ( "fmt" "testing" - log "github.com/authzed/spicedb/internal/logging" - "github.com/stretchr/testify/require" + "go.uber.org/goleak" "github.com/authzed/spicedb/internal/datastore/common" "github.com/authzed/spicedb/internal/datastore/memdb" @@ -15,6 +14,7 @@ import ( "github.com/authzed/spicedb/internal/dispatch/caching" "github.com/authzed/spicedb/internal/dispatch/keys" "github.com/authzed/spicedb/internal/graph" + log "github.com/authzed/spicedb/internal/logging" datastoremw "github.com/authzed/spicedb/internal/middleware/datastore" "github.com/authzed/spicedb/internal/testfixtures" "github.com/authzed/spicedb/pkg/datastore" @@ -25,7 +25,16 @@ import ( var ONR = tuple.ObjectAndRelation +var goleakIgnores = []goleak.Option{ + goleak.IgnoreTopFunction("github.com/golang/glog.(*loggingT).flushDaemon"), + goleak.IgnoreTopFunction("github.com/dgraph-io/ristretto.(*lfuPolicy).processItems"), + goleak.IgnoreTopFunction("github.com/dgraph-io/ristretto.(*Cache).processItems"), + goleak.IgnoreCurrent(), +} + func TestSimpleCheck(t *testing.T) { + defer goleak.VerifyNone(t, goleakIgnores...) + type expected struct { relation string isMember bool diff --git a/internal/dispatch/graph/expand_test.go b/internal/dispatch/graph/expand_test.go index af2be44ced..8e8683cd3a 100644 --- a/internal/dispatch/graph/expand_test.go +++ b/internal/dispatch/graph/expand_test.go @@ -11,6 +11,7 @@ import ( "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/require" + "go.uber.org/goleak" "google.golang.org/protobuf/testing/protocmp" "github.com/authzed/spicedb/internal/datastore/common" @@ -129,6 +130,8 @@ var ( ) func TestExpand(t *testing.T) { + defer goleak.VerifyNone(t, goleakIgnores...) + testCases := []struct { start *core.ObjectAndRelation expansionMode v1.DispatchExpandRequest_ExpansionMode @@ -264,6 +267,8 @@ func onrExpr(onr *core.ObjectAndRelation) ast.Expr { } func TestMaxDepthExpand(t *testing.T) { + defer goleak.VerifyNone(t, goleakIgnores...) + require := require.New(t) rawDS, err := memdb.NewMemdbDatastore(0, 0, memdb.DisableGC) diff --git a/internal/dispatch/graph/lookup_test.go b/internal/dispatch/graph/lookup_test.go index abb30b4665..ef6c1a3264 100644 --- a/internal/dispatch/graph/lookup_test.go +++ b/internal/dispatch/graph/lookup_test.go @@ -8,12 +8,12 @@ import ( "time" "github.com/stretchr/testify/require" - - core "github.com/authzed/spicedb/pkg/proto/core/v1" + "go.uber.org/goleak" "github.com/authzed/spicedb/internal/datastore/memdb" datastoremw "github.com/authzed/spicedb/internal/middleware/datastore" "github.com/authzed/spicedb/internal/testfixtures" + core "github.com/authzed/spicedb/pkg/proto/core/v1" v1 "github.com/authzed/spicedb/pkg/proto/dispatch/v1" "github.com/authzed/spicedb/pkg/tuple" ) @@ -26,6 +26,8 @@ func RR(namespaceName string, relationName string) *core.RelationReference { } func TestSimpleLookup(t *testing.T) { + defer goleak.VerifyNone(t, goleakIgnores...) + testCases := []struct { start *core.RelationReference target *core.ObjectAndRelation diff --git a/internal/dispatch/graph/lookupsubjects_test.go b/internal/dispatch/graph/lookupsubjects_test.go index 873d35539a..4a7bbed6d6 100644 --- a/internal/dispatch/graph/lookupsubjects_test.go +++ b/internal/dispatch/graph/lookupsubjects_test.go @@ -6,13 +6,13 @@ import ( "sort" "testing" - log "github.com/authzed/spicedb/internal/logging" - "github.com/stretchr/testify/require" + "go.uber.org/goleak" "github.com/authzed/spicedb/internal/datastore/common" "github.com/authzed/spicedb/internal/datastore/memdb" "github.com/authzed/spicedb/internal/dispatch" + log "github.com/authzed/spicedb/internal/logging" datastoremw "github.com/authzed/spicedb/internal/middleware/datastore" "github.com/authzed/spicedb/internal/testfixtures" "github.com/authzed/spicedb/pkg/datastore" @@ -22,6 +22,8 @@ import ( ) func TestSimpleLookupSubjects(t *testing.T) { + defer goleak.VerifyNone(t, goleakIgnores...) + testCases := []struct { resourceType string resourceID string diff --git a/internal/dispatch/graph/reachableresources_test.go b/internal/dispatch/graph/reachableresources_test.go index 77d14f4f12..641a0dc165 100644 --- a/internal/dispatch/graph/reachableresources_test.go +++ b/internal/dispatch/graph/reachableresources_test.go @@ -8,13 +8,13 @@ import ( "testing" "github.com/stretchr/testify/require" - - core "github.com/authzed/spicedb/pkg/proto/core/v1" + "go.uber.org/goleak" "github.com/authzed/spicedb/internal/datastore/memdb" "github.com/authzed/spicedb/internal/dispatch" datastoremw "github.com/authzed/spicedb/internal/middleware/datastore" "github.com/authzed/spicedb/internal/testfixtures" + core "github.com/authzed/spicedb/pkg/proto/core/v1" v1 "github.com/authzed/spicedb/pkg/proto/dispatch/v1" "github.com/authzed/spicedb/pkg/tuple" ) @@ -31,6 +31,8 @@ func reachable(onr *core.ObjectAndRelation, hasPermission bool) reachableResourc } func TestSimpleReachableResources(t *testing.T) { + defer goleak.VerifyNone(t, goleakIgnores...) + testCases := []struct { start *core.RelationReference target *core.ObjectAndRelation diff --git a/internal/graph/expand.go b/internal/graph/expand.go index ee64d77dd2..96919d4c45 100644 --- a/internal/graph/expand.go +++ b/internal/graph/expand.go @@ -284,7 +284,7 @@ func expandSetOperation( resultChans := make([]chan ExpandResult, 0, len(requests)) for _, req := range requests { - resultChan := make(chan ExpandResult) + resultChan := make(chan ExpandResult, 1) resultChans = append(resultChans, resultChan) go req(childCtx, resultChan) }