Skip to content

Commit

Permalink
fix after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
salvacorts committed Oct 21, 2024
1 parent fb7753a commit 8360fdc
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 208 deletions.
8 changes: 6 additions & 2 deletions pkg/bloombuild/planner/plannertest/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,12 @@ func GenBlock(ref bloomshipper.BlockRef) (bloomshipper.Block, error) {
}

func GenSeries(bounds v1.FingerprintBounds) []*v1.Series {
series := make([]*v1.Series, 0, int(bounds.Max-bounds.Min+1))
for i := bounds.Min; i <= bounds.Max; i++ {
return GenSeriesWithStep(bounds, 1)
}

func GenSeriesWithStep(bounds v1.FingerprintBounds, step int) []*v1.Series {
series := make([]*v1.Series, 0, int(bounds.Max-bounds.Min+1)/step)
for i := bounds.Min; i <= bounds.Max; i += model.Fingerprint(step) {
series = append(series, &v1.Series{
Fingerprint: i,
Chunks: v1.ChunkRefs{
Expand Down
100 changes: 50 additions & 50 deletions pkg/bloombuild/planner/strategies/chunksize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ package strategies

import (
"context"
"github.com/grafana/loki/v3/pkg/bloombuild/planner/test_utils"
v1 "github.com/grafana/loki/v3/pkg/storage/bloom/v1"
"testing"

"github.com/go-kit/log"
"github.com/stretchr/testify/require"

"github.com/grafana/loki/v3/pkg/bloombuild/planner/plannertest"
"github.com/grafana/loki/v3/pkg/bloombuild/protos"
v1 "github.com/grafana/loki/v3/pkg/storage/bloom/v1"
"github.com/grafana/loki/v3/pkg/storage/stores/shipper/bloomshipper"
)

func taskForGap(bounds v1.FingerprintBounds) *protos.Task {
return protos.NewTask(test_utils.TestTable, "fake", bounds, test_utils.TsdbID(0), []protos.Gap{
return protos.NewTask(plannertest.TestTable, "fake", bounds, plannertest.TsdbID(0), []protos.Gap{
{
Bounds: bounds,
Series: test_utils.GenSeriesWithStep(bounds, 10),
Series: plannertest.GenSeriesWithStep(bounds, 10),
Blocks: nil,
},
})
Expand All @@ -37,7 +37,7 @@ func Test_ChunkSizeStrategy_Plan(t *testing.T) {

// Each series will have 1 chunk of 100KB each
tsdbs: TSDBSet{
test_utils.TsdbID(0): newFakeForSeries(test_utils.GenSeriesWithStep(v1.NewBounds(0, 100), 10)), // 10 series
plannertest.TsdbID(0): newFakeForSeries(plannertest.GenSeriesWithStep(v1.NewBounds(0, 100), 10)), // 10 series
},

// We expect 5 tasks, each with 2 series each
Expand All @@ -56,30 +56,30 @@ func Test_ChunkSizeStrategy_Plan(t *testing.T) {
// Original metas cover the entire range
// One meta for each 2 series w/ 1 block per series
originalMetas: []bloomshipper.Meta{
test_utils.GenMeta(0, 10, []int{0}, []bloomshipper.BlockRef{
test_utils.GenBlockRef(0, 0),
test_utils.GenBlockRef(10, 10),
plannertest.GenMeta(0, 10, []int{0}, []bloomshipper.BlockRef{
plannertest.GenBlockRef(0, 0),
plannertest.GenBlockRef(10, 10),
}),
test_utils.GenMeta(20, 30, []int{0}, []bloomshipper.BlockRef{
test_utils.GenBlockRef(20, 20),
test_utils.GenBlockRef(30, 30),
plannertest.GenMeta(20, 30, []int{0}, []bloomshipper.BlockRef{
plannertest.GenBlockRef(20, 20),
plannertest.GenBlockRef(30, 30),
}),
test_utils.GenMeta(40, 50, []int{0}, []bloomshipper.BlockRef{
test_utils.GenBlockRef(40, 40),
test_utils.GenBlockRef(50, 50),
plannertest.GenMeta(40, 50, []int{0}, []bloomshipper.BlockRef{
plannertest.GenBlockRef(40, 40),
plannertest.GenBlockRef(50, 50),
}),
test_utils.GenMeta(60, 70, []int{0}, []bloomshipper.BlockRef{
test_utils.GenBlockRef(60, 60),
test_utils.GenBlockRef(70, 70),
plannertest.GenMeta(60, 70, []int{0}, []bloomshipper.BlockRef{
plannertest.GenBlockRef(60, 60),
plannertest.GenBlockRef(70, 70),
}),
test_utils.GenMeta(80, 90, []int{0}, []bloomshipper.BlockRef{
test_utils.GenBlockRef(80, 80),
test_utils.GenBlockRef(90, 90),
plannertest.GenMeta(80, 90, []int{0}, []bloomshipper.BlockRef{
plannertest.GenBlockRef(80, 80),
plannertest.GenBlockRef(90, 90),
}),
},

tsdbs: TSDBSet{
test_utils.TsdbID(0): newFakeForSeries(test_utils.GenSeriesWithStep(v1.NewBounds(0, 100), 10)), // 10 series
plannertest.TsdbID(0): newFakeForSeries(plannertest.GenSeriesWithStep(v1.NewBounds(0, 100), 10)), // 10 series
},

// We expect no tasks
Expand All @@ -93,30 +93,30 @@ func Test_ChunkSizeStrategy_Plan(t *testing.T) {
// Original metas cover the entire range
// One meta for each 2 series w/ 1 block per series
originalMetas: []bloomshipper.Meta{
test_utils.GenMeta(0, 10, []int{0}, []bloomshipper.BlockRef{
test_utils.GenBlockRef(0, 0),
test_utils.GenBlockRef(10, 10),
plannertest.GenMeta(0, 10, []int{0}, []bloomshipper.BlockRef{
plannertest.GenBlockRef(0, 0),
plannertest.GenBlockRef(10, 10),
}),
test_utils.GenMeta(20, 30, []int{0}, []bloomshipper.BlockRef{
test_utils.GenBlockRef(20, 20),
plannertest.GenMeta(20, 30, []int{0}, []bloomshipper.BlockRef{
plannertest.GenBlockRef(20, 20),
// Missing block for 30
}),
test_utils.GenMeta(40, 50, []int{0}, []bloomshipper.BlockRef{
test_utils.GenBlockRef(40, 40),
test_utils.GenBlockRef(50, 50),
plannertest.GenMeta(40, 50, []int{0}, []bloomshipper.BlockRef{
plannertest.GenBlockRef(40, 40),
plannertest.GenBlockRef(50, 50),
}),
test_utils.GenMeta(60, 70, []int{0}, []bloomshipper.BlockRef{
test_utils.GenBlockRef(60, 60),
test_utils.GenBlockRef(70, 70),
plannertest.GenMeta(60, 70, []int{0}, []bloomshipper.BlockRef{
plannertest.GenBlockRef(60, 60),
plannertest.GenBlockRef(70, 70),
}),
test_utils.GenMeta(80, 90, []int{0}, []bloomshipper.BlockRef{
test_utils.GenBlockRef(80, 80),
test_utils.GenBlockRef(90, 90),
plannertest.GenMeta(80, 90, []int{0}, []bloomshipper.BlockRef{
plannertest.GenBlockRef(80, 80),
plannertest.GenBlockRef(90, 90),
}),
},

tsdbs: TSDBSet{
test_utils.TsdbID(0): newFakeForSeries(test_utils.GenSeriesWithStep(v1.NewBounds(0, 100), 10)), // 10 series
plannertest.TsdbID(0): newFakeForSeries(plannertest.GenSeriesWithStep(v1.NewBounds(0, 100), 10)), // 10 series
},

// We expect 1 tasks for the missing series
Expand All @@ -132,27 +132,27 @@ func Test_ChunkSizeStrategy_Plan(t *testing.T) {
// Original metas cover the entire range
// One meta for each 2 series w/ 1 block per series
originalMetas: []bloomshipper.Meta{
test_utils.GenMeta(0, 10, []int{0}, []bloomshipper.BlockRef{
test_utils.GenBlockRef(0, 0),
test_utils.GenBlockRef(10, 10),
plannertest.GenMeta(0, 10, []int{0}, []bloomshipper.BlockRef{
plannertest.GenBlockRef(0, 0),
plannertest.GenBlockRef(10, 10),
}),
// Missing meta for 20-30
test_utils.GenMeta(40, 50, []int{0}, []bloomshipper.BlockRef{
test_utils.GenBlockRef(40, 40),
test_utils.GenBlockRef(50, 50),
plannertest.GenMeta(40, 50, []int{0}, []bloomshipper.BlockRef{
plannertest.GenBlockRef(40, 40),
plannertest.GenBlockRef(50, 50),
}),
test_utils.GenMeta(60, 70, []int{0}, []bloomshipper.BlockRef{
test_utils.GenBlockRef(60, 60),
test_utils.GenBlockRef(70, 70),
plannertest.GenMeta(60, 70, []int{0}, []bloomshipper.BlockRef{
plannertest.GenBlockRef(60, 60),
plannertest.GenBlockRef(70, 70),
}),
test_utils.GenMeta(80, 90, []int{0}, []bloomshipper.BlockRef{
test_utils.GenBlockRef(80, 80),
test_utils.GenBlockRef(90, 90),
plannertest.GenMeta(80, 90, []int{0}, []bloomshipper.BlockRef{
plannertest.GenBlockRef(80, 80),
plannertest.GenBlockRef(90, 90),
}),
},

tsdbs: TSDBSet{
test_utils.TsdbID(0): newFakeForSeries(test_utils.GenSeriesWithStep(v1.NewBounds(0, 100), 10)), // 10 series
plannertest.TsdbID(0): newFakeForSeries(plannertest.GenSeriesWithStep(v1.NewBounds(0, 100), 10)), // 10 series
},

// We expect 1 tasks for the missing series
Expand All @@ -168,7 +168,7 @@ func Test_ChunkSizeStrategy_Plan(t *testing.T) {
strategy, err := NewChunkSizeStrategy(tc.limits, logger)
require.NoError(t, err)

actual, err := strategy.Plan(context.Background(), test_utils.TestTable, "fake", tc.tsdbs, tc.originalMetas)
actual, err := strategy.Plan(context.Background(), plannertest.TestTable, "fake", tc.tsdbs, tc.originalMetas)
require.NoError(t, err)

require.ElementsMatch(t, tc.expectedTasks, actual)
Expand Down
156 changes: 0 additions & 156 deletions pkg/bloombuild/planner/test_utils/utils.go

This file was deleted.

0 comments on commit 8360fdc

Please sign in to comment.