Skip to content

Commit

Permalink
Fix linter warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Haudum <[email protected]>
  • Loading branch information
chaudum committed Jan 31, 2024
1 parent 5d81712 commit 1404477
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
20 changes: 10 additions & 10 deletions pkg/storage/stores/shipper/bloomshipper/fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,23 @@ func TestMetasFetcher(t *testing.T) {
{
name: "all metas found in cache",
store: []Meta{},
start: makeMetas(t, schemaCfg, now, []v1.FingerprintBounds{{0x0000, 0xffff}}),
end: makeMetas(t, schemaCfg, now, []v1.FingerprintBounds{{0x0000, 0xffff}}),
fetch: makeMetas(t, schemaCfg, now, []v1.FingerprintBounds{{0x0000, 0xffff}}),
start: makeMetas(t, schemaCfg, now, []v1.FingerprintBounds{{Min: 0x0000, Max: 0xffff}}),
end: makeMetas(t, schemaCfg, now, []v1.FingerprintBounds{{Min: 0x0000, Max: 0xffff}}),
fetch: makeMetas(t, schemaCfg, now, []v1.FingerprintBounds{{Min: 0x0000, Max: 0xffff}}),
},
{
name: "no metas found in cache",
store: makeMetas(t, schemaCfg, now, []v1.FingerprintBounds{{0x0000, 0xffff}}),
store: makeMetas(t, schemaCfg, now, []v1.FingerprintBounds{{Min: 0x0000, Max: 0xffff}}),
start: []Meta{},
end: makeMetas(t, schemaCfg, now, []v1.FingerprintBounds{{0x0000, 0xffff}}),
fetch: makeMetas(t, schemaCfg, now, []v1.FingerprintBounds{{0x0000, 0xffff}}),
end: makeMetas(t, schemaCfg, now, []v1.FingerprintBounds{{Min: 0x0000, Max: 0xffff}}),
fetch: makeMetas(t, schemaCfg, now, []v1.FingerprintBounds{{Min: 0x0000, Max: 0xffff}}),
},
{
name: "some metas found in cache",
store: makeMetas(t, schemaCfg, now, []v1.FingerprintBounds{{0x0000, 0xffff}, {0x10000, 0x1ffff}}),
start: makeMetas(t, schemaCfg, now, []v1.FingerprintBounds{{0x0000, 0xffff}}),
end: makeMetas(t, schemaCfg, now, []v1.FingerprintBounds{{0x0000, 0xffff}, {0x10000, 0x1ffff}}),
fetch: makeMetas(t, schemaCfg, now, []v1.FingerprintBounds{{0x0000, 0xffff}, {0x10000, 0x1ffff}}),
store: makeMetas(t, schemaCfg, now, []v1.FingerprintBounds{{Min: 0x0000, Max: 0xffff}, {Min: 0x10000, Max: 0x1ffff}}),
start: makeMetas(t, schemaCfg, now, []v1.FingerprintBounds{{Min: 0x0000, Max: 0xffff}}),
end: makeMetas(t, schemaCfg, now, []v1.FingerprintBounds{{Min: 0x0000, Max: 0xffff}, {Min: 0x10000, Max: 0x1ffff}}),
fetch: makeMetas(t, schemaCfg, now, []v1.FingerprintBounds{{Min: 0x0000, Max: 0xffff}, {Min: 0x10000, Max: 0x1ffff}}),
},
}

Expand Down
19 changes: 10 additions & 9 deletions pkg/storage/stores/shipper/bloomshipper/shipper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"testing"
"time"

v1 "github.com/grafana/loki/pkg/storage/bloom/v1"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/require"

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

func interval(start, end model.Time) Interval {
Expand Down Expand Up @@ -137,49 +138,49 @@ func TestIsOutsideRange(t *testing.T) {

t.Run("is outside if endFp < first fingerprint", func(t *testing.T) {
b := createBlockRef("block", 0, 90, startTs, endTs)
isOutside := isOutsideRange(b, interval(startTs, endTs), []v1.FingerprintBounds{{100, 199}})
isOutside := isOutsideRange(b, interval(startTs, endTs), []v1.FingerprintBounds{{Min: 100, Max: 199}})
require.True(t, isOutside)
})

t.Run("is outside if startFp > last fingerprint", func(t *testing.T) {
b := createBlockRef("block", 200, math.MaxUint64, startTs, endTs)
isOutside := isOutsideRange(b, interval(startTs, endTs), []v1.FingerprintBounds{{0, 49}, {100, 149}})
isOutside := isOutsideRange(b, interval(startTs, endTs), []v1.FingerprintBounds{{Min: 0, Max: 49}, {Min: 100, Max: 149}})
require.True(t, isOutside)
})

t.Run("is outside if within gaps in fingerprints", func(t *testing.T) {
b := createBlockRef("block", 100, 199, startTs, endTs)
isOutside := isOutsideRange(b, interval(startTs, endTs), []v1.FingerprintBounds{{0, 99}, {200, 299}})
isOutside := isOutsideRange(b, interval(startTs, endTs), []v1.FingerprintBounds{{Min: 0, Max: 99}, {Min: 200, Max: 299}})
require.True(t, isOutside)
})

t.Run("is not outside if within fingerprints 1", func(t *testing.T) {
b := createBlockRef("block", 10, 90, startTs, endTs)
isOutside := isOutsideRange(b, interval(startTs, endTs), []v1.FingerprintBounds{{0, 99}, {200, 299}})
isOutside := isOutsideRange(b, interval(startTs, endTs), []v1.FingerprintBounds{{Min: 0, Max: 99}, {Min: 200, Max: 299}})
require.False(t, isOutside)
})

t.Run("is not outside if within fingerprints 2", func(t *testing.T) {
b := createBlockRef("block", 210, 290, startTs, endTs)
isOutside := isOutsideRange(b, interval(startTs, endTs), []v1.FingerprintBounds{{0, 99}, {200, 299}})
isOutside := isOutsideRange(b, interval(startTs, endTs), []v1.FingerprintBounds{{Min: 0, Max: 99}, {Min: 200, Max: 299}})
require.False(t, isOutside)
})

t.Run("is not outside if spans across multiple fingerprint ranges", func(t *testing.T) {
b := createBlockRef("block", 50, 250, startTs, endTs)
isOutside := isOutsideRange(b, interval(startTs, endTs), []v1.FingerprintBounds{{0, 99}, {200, 299}})
isOutside := isOutsideRange(b, interval(startTs, endTs), []v1.FingerprintBounds{{Min: 0, Max: 99}, {Min: 200, Max: 299}})
require.False(t, isOutside)
})

t.Run("is not outside if fingerprint range and time range are larger than block", func(t *testing.T) {
b := createBlockRef("block", math.MaxUint64/3, math.MaxUint64/3*2, startTs, endTs)
isOutside := isOutsideRange(b, interval(0, 3000), []v1.FingerprintBounds{{0, math.MaxUint64}})
isOutside := isOutsideRange(b, interval(0, 3000), []v1.FingerprintBounds{{Min: 0, Max: math.MaxUint64}})
require.False(t, isOutside)
})

t.Run("is not outside if block fingerprint range is bigger that search keyspace", func(t *testing.T) {
b := createBlockRef("block", 0x0000, 0xffff, model.Earliest, model.Latest)
isOutside := isOutsideRange(b, interval(startTs, endTs), []v1.FingerprintBounds{{0x0100, 0xff00}})
isOutside := isOutsideRange(b, interval(startTs, endTs), []v1.FingerprintBounds{{Min: 0x0100, Max: 0xff00}})
require.False(t, isOutside)
})
}
Expand Down

0 comments on commit 1404477

Please sign in to comment.