(t *testing.T)
| 194 | } |
| 195 | |
| 196 | func 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 | |
| 235 | func TestDesc_TokensFor(t *testing.T) { |
| 236 | tests := map[string]struct { |
nothing calls this directly
no test coverage detected