diff --git a/pkg/scheduler/queue/queue.go b/pkg/scheduler/queue/queue.go index 27cc6f540cb..0931b25f3b6 100644 --- a/pkg/scheduler/queue/queue.go +++ b/pkg/scheduler/queue/queue.go @@ -2,7 +2,6 @@ package queue import ( "context" - "fmt" "sync" "time" @@ -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 diff --git a/pkg/scheduler/queue/queue_test.go b/pkg/scheduler/queue/queue_test.go index fca29e24df5..5e260323ecf 100644 --- a/pkg/scheduler/queue/queue_test.go +++ b/pkg/scheduler/queue/queue_test.go @@ -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}, @@ -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")) @@ -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}, @@ -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)