Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
chencs committed Jun 10, 2024
1 parent 2efe392 commit ccfadcf
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion pkg/scheduler/queue/queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"context"
"errors"
"fmt"
promtest "github.com/prometheus/client_golang/prometheus/testutil"
"math/rand"
"strconv"
"strings"
Expand All @@ -22,6 +21,7 @@ import (
"github.com/grafana/dskit/services"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
promtest "github.com/prometheus/client_golang/prometheus/testutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/sync/errgroup"
Expand Down
8 changes: 0 additions & 8 deletions pkg/scheduler/queue/tenant_querier_assignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,6 @@ type tenantQuerierAssignments struct {
currentQuerier *QuerierID
}

func (tqa *tenantQuerierAssignments) getTenant(tenantID TenantID) (*queueTenant, error) {
if tenantID == emptyTenantID {
return nil, ErrInvalidTenantID
}
tenant := tqa.tenantsByID[tenantID]
return tenant, nil
}

// createOrUpdateTenant creates or updates a tenant into the tenant-querier assignment state.
//
// New tenants are added to the tenant order list and tenant-querier shards are shuffled if needed.
Expand Down
11 changes: 6 additions & 5 deletions pkg/scheduler/queue/tenant_queues_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ package queue
import (
"context"
"fmt"
"github.com/grafana/dskit/httpgrpc"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"math"
"math/rand"
"testing"
"time"

"github.com/grafana/dskit/httpgrpc"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func (qb *queueBroker) enqueueObjectsForTests(tenantID TenantID, numObjects int) error {
Expand Down Expand Up @@ -111,7 +112,7 @@ func TestQueues(t *testing.T) {
{buildExpectedObject(tenantTwo.tenantID, 2), tenantTwo},
{buildExpectedObject(tenantOne.tenantID, 5), tenantOne},
}
lastTenantIndex = assertExpectedValuesOnDequeue(t, qb, -1, "querier-2", expectedDequeueVals)
_ = assertExpectedValuesOnDequeue(t, qb, -1, "querier-2", expectedDequeueVals)

//[one two three]
// confirm fifo by adding a third tenant queue and iterating to it
Expand Down Expand Up @@ -310,7 +311,7 @@ func TestQueuesOnTerminatingQuerier(t *testing.T) {

// After disconnecting querier-2, it's expected to own no queue.
qb.tenantQuerierAssignments.removeQuerier("querier-2")
req, tenant, qTwolastTenantIndex, err = qb.dequeueRequestForQuerier(qTwolastTenantIndex, "querier-2")
req, tenant, _, _ = qb.dequeueRequestForQuerier(qTwolastTenantIndex, "querier-2")
assert.Nil(t, req)
assert.Nil(t, tenant)
assert.Equal(t, ErrQuerierShuttingDown, err)
Expand Down
4 changes: 1 addition & 3 deletions pkg/scheduler/queue/tree_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ func newNode(name string, depth int, da DequeueAlgorithm) (*Node, error) {
if da == nil {
return nil, fmt.Errorf("cannot create a node without a defined DequeueAlgorithm")
}
switch da.(type) {
case *tenantQuerierAssignments:
tqa := da.(*tenantQuerierAssignments)
if tqa, ok := da.(*tenantQuerierAssignments); ok {
tqa.tenantOrderIndex = localQueueIndex - 1 // start from -2 so that we first check local queue
if tqa.tenantNodes == nil {
tqa.tenantNodes = map[string][]*Node{}
Expand Down
27 changes: 18 additions & 9 deletions pkg/scheduler/queue/tree_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ package queue
import (
"fmt"
"strings"

//"fmt"
"github.com/stretchr/testify/require"
"testing"

"github.com/stretchr/testify/require"
)

func newTenantQuerierAssignments() *tenantQuerierAssignments {
Expand Down Expand Up @@ -620,12 +619,22 @@ func Test_ChangeTenantQuerierAssignments(t *testing.T) {
tree, err := NewTree(state, &roundRobinState{}, &roundRobinState{})
require.NoError(t, err)

err = tree.EnqueueBackByPath(QueuePath{"tenant-1", "query-component-1"}, "query-1")
err = tree.EnqueueBackByPath(QueuePath{"tenant-2", "query-component-1"}, "query-2")
err = tree.EnqueueBackByPath(QueuePath{"tenant-2", "query-component-1"}, "query-3")
err = tree.EnqueueBackByPath(QueuePath{"tenant-2", "query-component-1"}, "query-4")
err = tree.EnqueueBackByPath(QueuePath{"tenant-3", "query-component-1"}, "query-5")
require.NoError(t, err)
type enqueueObj struct {
obj any
path QueuePath
}
enqueueObjs := []enqueueObj{
{"query-1", QueuePath{"tenant-1", "query-component-1"}},
{"query-2", QueuePath{"tenant-2", "query-component-1"}},
{"query-3", QueuePath{"tenant-2", "query-component-1"}},
{"query-4", QueuePath{"tenant-2", "query-component-1"}},
{"query-5", QueuePath{"tenant-3", "query-component-1"}},
}

for _, eo := range enqueueObjs {
err = tree.EnqueueBackByPath(eo.path, eo.obj)
require.NoError(t, err)
}

querier1 := QuerierID("querier-1")
querier2 := QuerierID("querier-2")
Expand Down

0 comments on commit ccfadcf

Please sign in to comment.