From e93253b92dd4adefcea79e8dbad686be36f9a973 Mon Sep 17 00:00:00 2001 From: Christian Haudum Date: Thu, 7 Dec 2023 18:28:47 +0100 Subject: [PATCH] fixup! Fix `serverAddressesWithTokenRanges` function Signed-off-by: Christian Haudum --- pkg/bloomgateway/client_test.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pkg/bloomgateway/client_test.go b/pkg/bloomgateway/client_test.go index ddb8d2fb529b1..6edd8fcb406ea 100644 --- a/pkg/bloomgateway/client_test.go +++ b/pkg/bloomgateway/client_test.go @@ -162,7 +162,20 @@ func TestBloomGatewayClient_ServerAddressesWithTokenRanges(t *testing.T) { instances []ring.InstanceDesc expected []addrsWithTokenRange }{ - "MinUint32 and MaxUint32 are actual tokens in the ring": { + "one token per instance": { + instances: []ring.InstanceDesc{ + {Id: "instance-1", Addr: "10.0.0.1", Tokens: []uint32{math.MaxUint32 / 6 * 1}}, + {Id: "instance-2", Addr: "10.0.0.2", Tokens: []uint32{math.MaxUint32 / 6 * 3}}, + {Id: "instance-3", Addr: "10.0.0.3", Tokens: []uint32{math.MaxUint32 / 6 * 5}}, + }, + expected: []addrsWithTokenRange{ + {id: "instance-1", addrs: []string{"10.0.0.1"}, minToken: 0, maxToken: math.MaxUint32 / 6 * 1}, + {id: "instance-2", addrs: []string{"10.0.0.2"}, minToken: math.MaxUint32/6*1 + 1, maxToken: math.MaxUint32 / 6 * 3}, + {id: "instance-3", addrs: []string{"10.0.0.3"}, minToken: math.MaxUint32/6*3 + 1, maxToken: math.MaxUint32 / 6 * 5}, + {id: "instance-1", addrs: []string{"10.0.0.1"}, minToken: math.MaxUint32/6*5 + 1, maxToken: math.MaxUint32}, + }, + }, + "MinUint32 and MaxUint32 are tokens in the ring": { instances: []ring.InstanceDesc{ {Id: "instance-1", Addr: "10.0.0.1", Tokens: []uint32{0, math.MaxUint32 / 3 * 2}}, {Id: "instance-2", Addr: "10.0.0.2", Tokens: []uint32{math.MaxUint32 / 3 * 1, math.MaxUint32}},