Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Jung <jungjust@amazon.com>
  • Loading branch information
justinjung04 committed Jul 10, 2024
1 parent 68e47e8 commit e58b288
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions pkg/scheduler/queue/user_queues.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,13 +433,17 @@ type MockLimits struct {
MaxOutstanding int
MaxQueriersPerUserVal float64
QueryPriorityVal validation.QueryPriority
RandomMaxOutstanding bool
}

func (l MockLimits) MaxQueriersPerUser(_ string) float64 {
return l.MaxQueriersPerUserVal
}

func (l MockLimits) MaxOutstandingPerTenant(_ string) int {
if l.RandomMaxOutstanding {
return rand.Intn(100)
}
return l.MaxOutstanding
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/scheduler/queue/user_queues_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,10 @@ func TestGetOrAddQueueShouldUpdateProperties(t *testing.T) {

func TestGetOrAddQueueConcurrency(t *testing.T) {
const numGoRoutines = 100
q := newUserQueues(0, 0, MockLimits{}, nil)
limits := MockLimits{
RandomMaxOutstanding: true,
}
q := newUserQueues(0, 0, limits, nil)
q.addQuerierConnection("q-1")
q.addQuerierConnection("q-2")
q.addQuerierConnection("q-3")
Expand All @@ -473,9 +476,6 @@ func TestGetOrAddQueueConcurrency(t *testing.T) {
for i := 0; i < numGoRoutines; i++ {
go func(cnt int) {
defer wg.Done()
q.limits = MockLimits{
MaxOutstanding: cnt + 50,
}
queue := q.getOrAddQueue("userID", 2)
if cnt%2 == 0 {
queue.enqueueRequest(MockRequest{})
Expand Down

0 comments on commit e58b288

Please sign in to comment.