Skip to content

Commit e75b9de

Browse files
committed
asim: add TestEvenDistribution
1 parent 4e75f0d commit e75b9de

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

pkg/kv/kvserver/asim/state/state_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,29 @@ func TestSkewedDistribution(t *testing.T) {
438438
require.Equal(t, expectedStoreReplicas, stores)
439439
require.Equal(t, 6, len(stores))
440440
}
441+
func TestEvenDistribution(t *testing.T) {
442+
rangeInfo := RangesInfoEvenDistribution(
443+
6 /*stores*/, 100 /*ranges*/, 1 /*minKey*/, 10000 /*maxKey*/, 3 /*replicationFactor*/, 10000 /*rangeSize*/)
444+
expectedStoreReplicas := map[roachpb.StoreID]int{
445+
1: 50,
446+
2: 50,
447+
3: 50,
448+
4: 50,
449+
5: 50,
450+
6: 50,
451+
}
452+
totalReplicas := 0
453+
stores := map[roachpb.StoreID]int{}
454+
for _, rng := range rangeInfo {
455+
for _, repl := range rng.Descriptor.InternalReplicas {
456+
stores[repl.StoreID]++
457+
totalReplicas++
458+
}
459+
}
460+
require.Equal(t, 300, totalReplicas)
461+
require.Equal(t, expectedStoreReplicas, stores)
462+
require.Equal(t, 6, len(stores))
463+
}
441464

442465
// TestNewStateDeterministic asserts that the state returned from the new state
443466
// utility functions is deterministic.

0 commit comments

Comments
 (0)