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

Function TestPartitionRingDesc_partitionByToken

ring/partition_ring_model_test.go:30–43  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

28}
29
30func TestPartitionRingDesc_partitionByToken(t *testing.T) {
31 desc := &PartitionRingDesc{
32 Partitions: map[int32]PartitionDesc{
33 1: {Tokens: []uint32{1, 5, 8}, State: PartitionActive, StateTimestamp: 10},
34 2: {Tokens: []uint32{3, 4, 9}, State: PartitionActive, StateTimestamp: 20},
35 },
36 Owners: map[string]OwnerDesc{
37 "ingester-zone-a-0": {OwnedPartition: 1, State: OwnerActive, UpdatedTimestamp: 10},
38 "ingester-zone-b-0": {OwnedPartition: 1, State: OwnerActive, UpdatedTimestamp: 15},
39 },
40 }
41
42 assert.Equal(t, map[Token]int32{1: 1, 5: 1, 8: 1, 3: 2, 4: 2, 9: 2}, desc.partitionByToken())
43}
44
45func TestPartitionRingDesc_countPartitionsByState(t *testing.T) {
46 t.Run("empty ring should return all states with 0 partitions each", func(t *testing.T) {

Callers

nothing calls this directly

Calls 2

partitionByTokenMethod · 0.95
EqualMethod · 0.45

Tested by

no test coverage detected