-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c79b9f6
commit f10d775
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |