Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Haudum <[email protected]>
  • Loading branch information
chaudum committed Feb 15, 2024
1 parent 7d2ef77 commit c030ec9
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions pkg/bloomutils/ring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (

"github.com/grafana/dskit/ring"
"github.com/stretchr/testify/require"

v1 "github.com/grafana/loki/pkg/storage/bloom/v1"
)

func TestBloomGatewayClient_InstanceSortMergeIterator(t *testing.T) {
Expand All @@ -33,11 +31,15 @@ func TestBloomGatewayClient_InstanceSortMergeIterator(t *testing.T) {
}
}

func uint64Range(min, max uint64) Range[uint64] {
return Range[uint64]{min, max}
}

func TestBloomGatewayClient_KeyRangeForInstance(t *testing.T) {
for name, tc := range map[string]struct {
id string
input []ring.InstanceDesc
expected v1.FingerprintBounds
expected Range[uint64]
}{
"first instance includes 0 token": {
id: "3",
Expand All @@ -46,7 +48,7 @@ func TestBloomGatewayClient_KeyRangeForInstance(t *testing.T) {
{Id: "2", Tokens: []uint32{5}},
{Id: "3", Tokens: []uint32{1}},
},
expected: v1.NewBounds(0, math.MaxUint64/3-1),
expected: uint64Range(0, math.MaxUint64/3-1),
},
"middle instance": {
id: "1",
Expand All @@ -55,7 +57,7 @@ func TestBloomGatewayClient_KeyRangeForInstance(t *testing.T) {
{Id: "2", Tokens: []uint32{5}},
{Id: "3", Tokens: []uint32{1}},
},
expected: v1.NewBounds(math.MaxUint64/3, math.MaxUint64/3*2-1),
expected: uint64Range(math.MaxUint64/3, math.MaxUint64/3*2-1),
},
"last instance includes MaxUint32 token": {
id: "2",
Expand All @@ -64,12 +66,12 @@ func TestBloomGatewayClient_KeyRangeForInstance(t *testing.T) {
{Id: "2", Tokens: []uint32{5}},
{Id: "3", Tokens: []uint32{1}},
},
expected: v1.NewBounds(math.MaxUint64/3*2, math.MaxUint64),
expected: uint64Range(math.MaxUint64/3*2, math.MaxUint64),
},
} {
tc := tc
t.Run(name, func(t *testing.T) {
result, err := KeyRangeForInstance(tc.id, tc.input, Uint32Range)
result, err := KeyRangeForInstance(tc.id, tc.input, Uint64Range)
require.NoError(t, err)
require.Equal(t, tc.expected, result)
})
Expand Down

0 comments on commit c030ec9

Please sign in to comment.