Skip to content

Commit 53cf835

Browse files
committed
allocatorimpl: fixes TestBestRebalanceTarget
This commit fixes a test that previously panic because `nil` was passed for `allocatorSync` in `bestRebalanceTarget`.
1 parent 583ca66 commit 53cf835

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pkg/kv/kvserver/allocator/allocatorimpl/allocator_scorer_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/allocator"
1919
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/allocator/storepool"
2020
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/constraint"
21+
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/mmaintegration"
2122
"github.com/cockroachdb/cockroach/pkg/roachpb"
2223
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
2324
"github.com/cockroachdb/cockroach/pkg/util/log"
@@ -436,10 +437,18 @@ func TestBestRebalanceTarget(t *testing.T) {
436437
expectedTargets := []roachpb.StoreID{13, 13, 11, 12}
437438
expectedExistingRepls := []roachpb.StoreID{3, 2, 1, 1}
438439
allocRand := makeAllocatorRand(rand.NewSource(0))
440+
ctx := context.Background()
441+
stopper, _, _, a, _ := CreateTestAllocatorWithKnobs(ctx, 10, false, /* deterministic */
442+
nil /* allocator.TestingKnobs */, &mmaintegration.TestingKnobs{
443+
OverrideIsInConflictWithMMA: func(cand roachpb.StoreID) bool {
444+
return false
445+
},
446+
} /* mmaintegration.TestingKnobs */)
447+
defer stopper.Stop(ctx)
439448
var i int
440449
for {
441450
i++
442-
target, existing, _ := bestRebalanceTarget(allocRand, candidates, nil, nil)
451+
target, existing, _ := bestRebalanceTarget(allocRand, candidates, a.as)
443452
if len(expectedTargets) == 0 {
444453
if target == nil {
445454
break

0 commit comments

Comments
 (0)