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

Function TestDesc_getTokensByZone

ring/model_test.go:196–233  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

194}
195
196func TestDesc_getTokensByZone(t *testing.T) {
197 tests := map[string]struct {
198 desc *Desc
199 expected map[string][]uint32
200 }{
201 "empty ring": {
202 desc: &Desc{Ingesters: map[string]InstanceDesc{}},
203 expected: map[string][]uint32{},
204 },
205 "single zone": {
206 desc: &Desc{Ingesters: map[string]InstanceDesc{
207 "instance-1": {Addr: "127.0.0.1", Tokens: []uint32{1, 5}, Zone: ""},
208 "instance-2": {Addr: "127.0.0.1", Tokens: []uint32{2, 4}, Zone: ""},
209 "instance-3": {Addr: "127.0.0.1", Tokens: []uint32{3, 6}, Zone: ""},
210 }},
211 expected: map[string][]uint32{
212 "": {1, 2, 3, 4, 5, 6},
213 },
214 },
215 "multiple zones": {
216 desc: &Desc{Ingesters: map[string]InstanceDesc{
217 "instance-1": {Addr: "127.0.0.1", Tokens: []uint32{1, 5}, Zone: "zone-1"},
218 "instance-2": {Addr: "127.0.0.1", Tokens: []uint32{2, 4}, Zone: "zone-1"},
219 "instance-3": {Addr: "127.0.0.1", Tokens: []uint32{3, 6}, Zone: "zone-2"},
220 }},
221 expected: map[string][]uint32{
222 "zone-1": {1, 2, 4, 5},
223 "zone-2": {3, 6},
224 },
225 },
226 }
227
228 for testName, testData := range tests {
229 t.Run(testName, func(t *testing.T) {
230 assert.Equal(t, testData.expected, testData.desc.getTokensByZone())
231 })
232 }
233}
234
235func TestDesc_TokensFor(t *testing.T) {
236 tests := map[string]struct {

Callers

nothing calls this directly

Calls 3

RunMethod · 0.80
getTokensByZoneMethod · 0.80
EqualMethod · 0.45

Tested by

no test coverage detected