Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions acceleration/internal/store/budget_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ func (s *StoreSuite) countQueries(run func()) int {
return int(s.queries.sent.Load() - before)
}

// countSettledReads is countQueries for a read one shard's answer settles (answeringShards).
// The reads that answer cut off are not waited for and finish after run returns, so it waits,
// up to a deadline, until every shard's statement is in before it counts.
func (s *StoreSuite) countSettledReads(run func()) int {
before := s.queries.sent.Load()
run()
shards := int64(len(s.store.shards()))
s.Eventually(func() bool { return s.queries.sent.Load()-before >= shards }, 5*time.Second, time.Millisecond,
"a statement from every shard")
return int(s.queries.sent.Load() - before)
}

// countEveryQuery hooks the suite's counter into every database the store holds.
func (s *StoreSuite) countEveryQuery() {
databases := append([]*bun.DB{s.store.global}, s.store.peers...)
Expand Down
2 changes: 1 addition & 1 deletion acceleration/internal/store/call_bridge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func (s *StoreSuite) TestABridgeIsClaimedOnceFromAnyShardAndSweptOnceExpired() {

var claimed CallBridge
var err error
s.Equal(len(s.store.shards()), s.countQueries(func() {
s.Equal(len(s.store.shards()), s.countSettledReads(func() {
claimed, err = s.store.CallBridges.Claim(s.ctx, waiting.Token)
}), "Claim asks every shard once")
s.Require().NoError(err)
Expand Down
2 changes: 1 addition & 1 deletion acceleration/internal/store/call_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (s *StoreSuite) TestCallResourceQueryBudgets() {
first = resource
}
}
s.Equal(shards, s.countQueries(func() {
s.Equal(shards, s.countSettledReads(func() {
resources, err := s.store.CallResources.Select(s.ctx, AppScope{Unpinned: true}, "default", "call-1")
s.Require().NoError(err)
s.Len(resources, 3)
Expand Down
Loading