|
| 1 | +package protos |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/stretchr/testify/require" |
| 7 | + |
| 8 | + "github.com/grafana/loki/v3/pkg/bloombuild/planner/plannertest" |
| 9 | + v1 "github.com/grafana/loki/v3/pkg/storage/bloom/v1" |
| 10 | + "github.com/grafana/loki/v3/pkg/storage/stores/shipper/bloomshipper" |
| 11 | + "github.com/grafana/loki/v3/pkg/storage/stores/shipper/indexshipper/tsdb" |
| 12 | +) |
| 13 | + |
| 14 | +func TestTaskToProtoTask(t *testing.T) { |
| 15 | + // Hack to set exportTSInSecs to true |
| 16 | + idx := plannertest.TsdbID(1234) |
| 17 | + idx, _ = tsdb.ParseSingleTenantTSDBPath(idx.Name()) |
| 18 | + |
| 19 | + in := NewTask(plannertest.TestTable, "fake", v1.NewBounds(0, 100), idx, []Gap{ |
| 20 | + { |
| 21 | + Bounds: v1.NewBounds(0, 25), |
| 22 | + Series: plannertest.GenSeriesWithStep(v1.NewBounds(0, 10), 2), |
| 23 | + Blocks: []bloomshipper.BlockRef{ |
| 24 | + plannertest.GenBlockRef(0, 2), |
| 25 | + plannertest.GenBlockRef(4, 10), |
| 26 | + }, |
| 27 | + }, |
| 28 | + { |
| 29 | + Bounds: v1.NewBounds(30, 50), |
| 30 | + Series: plannertest.GenSeriesWithStep(v1.NewBounds(30, 40), 2), |
| 31 | + Blocks: []bloomshipper.BlockRef{ |
| 32 | + plannertest.GenBlockRef(30, 50), |
| 33 | + }, |
| 34 | + }, |
| 35 | + { |
| 36 | + Bounds: v1.NewBounds(60, 100), |
| 37 | + Series: plannertest.GenSeriesWithStep(v1.NewBounds(60, 70), 5), |
| 38 | + Blocks: []bloomshipper.BlockRef{ |
| 39 | + plannertest.GenBlockRef(60, 70), |
| 40 | + plannertest.GenBlockRef(71, 90), |
| 41 | + plannertest.GenBlockRef(91, 100), |
| 42 | + }, |
| 43 | + }, |
| 44 | + }) |
| 45 | + |
| 46 | + out, err := FromProtoTask(in.ToProtoTask()) |
| 47 | + require.NoError(t, err) |
| 48 | + |
| 49 | + require.Equal(t, in, out) |
| 50 | +} |
0 commit comments