Skip to content

Commit

Permalink
Test for new strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
salvacorts committed Oct 21, 2024
1 parent c79b9f6 commit f10d775
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions pkg/bloombuild/planner/strategies/chunksize_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package strategies

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

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

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

func Test_ChunkSizeStrategy_Plan(t *testing.T) {
for _, tc := range []struct {
name string
originalMetas []bloomshipper.Meta
tsdbs TSDBSet
expectedTasks []*protos.Task
}{
{
name: "no previous blocks and metas",
// TODO: Build TSDB with mock ForEach with equally sized series
},
{
name: "Test case 2",
},
} {
t.Run(tc.name, func(t *testing.T) {
logger := log.NewNopLogger()
//logger := log.NewLogfmtLogger(os.Stdout)

strategy, err := NewChunkSizeStrategy(fakeChunkSizeLimits{TargetSize: 1000}, logger)
require.NoError(t, err)

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

require.ElementsMatch(t, tc.expectedTasks, actual)
})
}
}

type fakeChunkSizeLimits struct {
TargetSize uint64
}

func (f fakeChunkSizeLimits) BloomTaskTargetChunkSizeBytes(tenantID string) uint64 {
return f.TargetSize
}

0 comments on commit f10d775

Please sign in to comment.