Skip to content

Commit

Permalink
More test fix
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Jung <[email protected]>
  • Loading branch information
justinjung04 committed Oct 17, 2023
1 parent 509b87c commit 5a57717
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 0 additions & 2 deletions pkg/scheduler/queue/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package queue

import (
"context"
"fmt"
"sync"
"time"

Expand Down Expand Up @@ -109,7 +108,6 @@ func (q *RequestQueue) EnqueueRequest(userID string, req Request, maxQueriers fl

q.totalRequests.WithLabelValues(userID).Inc()

fmt.Println("EnqueueRequest", q.queues.getTotalQueueSize(userID), maxOutstandingRequests)
if q.queues.getTotalQueueSize(userID) >= maxOutstandingRequests {
q.discardedRequests.WithLabelValues(userID).Inc()
return ErrTooManyRequests
Expand Down
14 changes: 7 additions & 7 deletions pkg/scheduler/queue/queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func TestRequestQueue_GetNextRequestForQuerier_ShouldGetRequestAfterReshardingBe
}

func TestRequestQueue_QueriersShouldGetHighPriorityQueryFirst(t *testing.T) {
queue := NewRequestQueue(100, 0,
queue := NewRequestQueue(0, 0,
prometheus.NewGaugeVec(prometheus.GaugeOpts{}, []string{"user"}),
prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"user"}),
MockLimits{MaxOutstanding: 3},
Expand All @@ -182,9 +182,9 @@ func TestRequestQueue_QueriersShouldGetHighPriorityQueryFirst(t *testing.T) {
isHighPriority: true,
}

assert.Nil(t, queue.EnqueueRequest("userID", normalRequest1, 1, func() {}))
assert.Nil(t, queue.EnqueueRequest("userID", normalRequest2, 1, func() {}))
assert.Nil(t, queue.EnqueueRequest("userID", highPriorityRequest, 1, func() {}))
assert.NoError(t, queue.EnqueueRequest("userID", normalRequest1, 1, func() {}))
assert.NoError(t, queue.EnqueueRequest("userID", normalRequest2, 1, func() {}))
assert.NoError(t, queue.EnqueueRequest("userID", highPriorityRequest, 1, func() {}))

assert.Error(t, queue.EnqueueRequest("userID", highPriorityRequest, 1, func() {})) // should fail due to maxOutstandingPerTenant = 3
assert.Equal(t, 3, queue.queues.getTotalQueueSize("userID"))
Expand All @@ -197,7 +197,7 @@ func TestRequestQueue_QueriersShouldGetHighPriorityQueryFirst(t *testing.T) {
}

func TestRequestQueue_ReservedQueriersShouldOnlyGetHighPriorityQueries(t *testing.T) {
queue := NewRequestQueue(100, 0,
queue := NewRequestQueue(0, 0,
prometheus.NewGaugeVec(prometheus.GaugeOpts{}, []string{"user"}),
prometheus.NewCounterVec(prometheus.CounterOpts{}, []string{"user"}),
MockLimits{MaxOutstanding: 3, ReservedQueriers: 1},
Expand All @@ -216,8 +216,8 @@ func TestRequestQueue_ReservedQueriersShouldOnlyGetHighPriorityQueries(t *testin
isHighPriority: true,
}

assert.NotNil(t, queue.EnqueueRequest("userID", normalRequest, 1, func() {}))
assert.NotNil(t, queue.EnqueueRequest("userID", highPriorityRequest, 1, func() {}))
assert.NoError(t, queue.EnqueueRequest("userID", normalRequest, 1, func() {}))
assert.NoError(t, queue.EnqueueRequest("userID", highPriorityRequest, 1, func() {}))

nextRequest, _, _ := queue.GetNextRequestForQuerier(ctx, FirstUser(), "querier-1")
assert.Equal(t, highPriorityRequest, nextRequest)
Expand Down

0 comments on commit 5a57717

Please sign in to comment.