Skip to content

Commit

Permalink
test: reduce max concurrent connections in check benchmarks (openfga#…
Browse files Browse the repository at this point in the history
  • Loading branch information
justincoh authored Oct 17, 2024
1 parent b6a531d commit 9f47326
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pkg/server/test/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import (
"github.com/openfga/openfga/pkg/typesystem"
)

// to prevent overwhelming server on expensive queries.
const maxConcurrentReads = 50

// Some of the benchmark tests require context blocks to be built
// but many do not. This noop method is a placeholder for the non-context test cases.
func noopContextGenerator() *structpb.Struct {
Expand Down Expand Up @@ -382,9 +385,9 @@ func BenchmarkCheck(b *testing.B, ds storage.OpenFGADatastore) {

checkQuery := commands.NewCheckCommand(
ds,
graph.NewLocalChecker(),
graph.NewLocalChecker(graph.WithOptimizations(true)),
typeSystem,
commands.WithCheckCommandMaxConcurrentReads(config.DefaultMaxConcurrentReadsForCheck),
commands.WithCheckCommandMaxConcurrentReads(maxConcurrentReads),
commands.WithCheckCommandResolveNodeLimit(config.DefaultResolveNodeLimit),
)

Expand All @@ -396,8 +399,8 @@ func BenchmarkCheck(b *testing.B, ds storage.OpenFGADatastore) {
Context: bm.contextGenerator(),
})

require.Equal(b, bm.expected, response.GetAllowed())
require.NoError(b, err)
require.Equal(b, bm.expected, response.GetAllowed())
}
})
}
Expand Down Expand Up @@ -475,9 +478,9 @@ func benchmarkCheckWithBypassUsersetReads(b *testing.B, ds storage.OpenFGADatast

checkQuery := commands.NewCheckCommand(
ds,
graph.NewLocalChecker(),
graph.NewLocalChecker(graph.WithOptimizations(true)),
typeSystemTwo,
commands.WithCheckCommandMaxConcurrentReads(config.DefaultMaxConcurrentReadsForCheck),
commands.WithCheckCommandMaxConcurrentReads(maxConcurrentReads),
commands.WithCheckCommandResolveNodeLimit(config.DefaultResolveNodeLimit),
)

Expand All @@ -488,8 +491,8 @@ func benchmarkCheckWithBypassUsersetReads(b *testing.B, ds storage.OpenFGADatast
TupleKey: tuple.NewCheckRequestTupleKey("document:budget", "viewer", "user:anne"),
})

require.False(b, response.GetAllowed())
require.NoError(b, err)
require.False(b, response.GetAllowed())
}
})
}

0 comments on commit 9f47326

Please sign in to comment.