MCPcopy
hub / github.com/grafana/dskit / TestCountTokensSingleZone

Function TestCountTokensSingleZone

ring/ring_test.go:4445–4495  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

4443}
4444
4445func TestCountTokensSingleZone(t *testing.T) {
4446 tests := map[string]struct {
4447 ring *Desc
4448 expected map[string]int64
4449 }{
4450 "empty ring": {
4451 ring: &Desc{},
4452 expected: map[string]int64{},
4453 },
4454 "1 instance with 1 token in the ring": {
4455 ring: &Desc{
4456 Ingesters: map[string]InstanceDesc{
4457 "ingester-1": {Tokens: []uint32{1000000}},
4458 },
4459 },
4460 expected: map[string]int64{
4461 "ingester-1": math.MaxUint32 + 1,
4462 },
4463 },
4464 "1 instance with multiple tokens in the ring": {
4465 ring: &Desc{
4466 Ingesters: map[string]InstanceDesc{
4467 "ingester-1": {Tokens: []uint32{1000000, 2000000, 3000000}},
4468 },
4469 },
4470 expected: map[string]int64{
4471 "ingester-1": math.MaxUint32 + 1,
4472 },
4473 },
4474 "multiple instances with multiple tokens in the ring": {
4475 ring: &Desc{
4476 Ingesters: map[string]InstanceDesc{
4477 "ingester-1": {Tokens: []uint32{1000000, 3000000, 6000000}},
4478 "ingester-2": {Tokens: []uint32{2000000, 4000000, 8000000}},
4479 "ingester-3": {Tokens: []uint32{5000000, 9000000}},
4480 },
4481 },
4482 expected: map[string]int64{
4483 "ingester-1": 3000000 + (int64(math.MaxUint32) + 1 - 9000000),
4484 "ingester-2": 4000000,
4485 "ingester-3": 2000000,
4486 },
4487 },
4488 }
4489
4490 for testName, testData := range tests {
4491 t.Run(testName, func(t *testing.T) {
4492 assert.Equal(t, testData.expected, testData.ring.CountTokens())
4493 })
4494 }
4495}
4496
4497func TestCountTokensMultiZones(t *testing.T) {
4498 tests := map[string]struct {

Callers

nothing calls this directly

Calls 3

RunMethod · 0.80
CountTokensMethod · 0.80
EqualMethod · 0.45

Tested by

no test coverage detected