mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
* o7 compactor Signed-off-by: Joe Elliott <[email protected]> * wip: o7 v2 Signed-off-by: Joe Elliott <[email protected]> * test cleanup Signed-off-by: Joe Elliott <[email protected]> * remove compactor from jsonnet Signed-off-by: Joe Elliott <[email protected]> * changelog Signed-off-by: Joe Elliott <[email protected]> * gen manifest Signed-off-by: Joe Elliott <[email protected]> * config cleanup Signed-off-by: Joe Elliott <[email protected]> * docs Signed-off-by: Joe Elliott <[email protected]> * jsonnet Signed-off-by: Joe Elliott <[email protected]> * remove encoding Signed-off-by: Joe Elliott <[email protected]> * remove data encoding Signed-off-by: Joe Elliott <[email protected]> * lint and cleanup Signed-off-by: Joe Elliott <[email protected]> * unflake TestWorker\? Signed-off-by: Joe Elliott <[email protected]> --------- Signed-off-by: Joe Elliott <[email protected]>
76 lines
1.7 KiB
Go
76 lines
1.7 KiB
Go
package vparquet5
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/grafana/tempo/pkg/tempopb"
|
|
"github.com/grafana/tempo/pkg/util/test"
|
|
"github.com/grafana/tempo/tempodb/backend"
|
|
"github.com/grafana/tempo/tempodb/backend/local"
|
|
"github.com/grafana/tempo/tempodb/encoding/common"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestCreateBlockHonorsTraceStartEndTimesFromWalMeta(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
rawR, rawW, _, err := local.New(&local.Config{
|
|
Path: t.TempDir(),
|
|
})
|
|
require.NoError(t, err)
|
|
|
|
r := backend.NewReader(rawR)
|
|
w := backend.NewWriter(rawW)
|
|
|
|
iter := newTestIterator()
|
|
|
|
iter.Add(test.MakeTrace(10, nil), 100, 401)
|
|
iter.Add(test.MakeTrace(10, nil), 101, 402)
|
|
iter.Add(test.MakeTrace(10, nil), 102, 403)
|
|
|
|
cfg := &common.BlockConfig{
|
|
BloomFP: 0.01,
|
|
BloomShardSizeBytes: 100 * 1024,
|
|
}
|
|
|
|
meta := backend.NewBlockMeta("fake", uuid.New(), VersionString)
|
|
meta.TotalObjects = 1
|
|
meta.StartTime = time.Unix(300, 0)
|
|
meta.EndTime = time.Unix(305, 0)
|
|
|
|
outMeta, err := CreateBlock(ctx, cfg, meta, iter, r, w)
|
|
require.NoError(t, err)
|
|
require.Equal(t, 300, int(outMeta.StartTime.Unix()))
|
|
require.Equal(t, 305, int(outMeta.EndTime.Unix()))
|
|
}
|
|
|
|
type testIterator struct {
|
|
traces []*tempopb.Trace
|
|
}
|
|
|
|
var _ common.Iterator = (*testIterator)(nil)
|
|
|
|
func newTestIterator() *testIterator {
|
|
return &testIterator{}
|
|
}
|
|
|
|
func (i *testIterator) Add(tr *tempopb.Trace, _, _ uint32) {
|
|
i.traces = append(i.traces, tr)
|
|
}
|
|
|
|
func (i *testIterator) Next(context.Context) (common.ID, *tempopb.Trace, error) {
|
|
if len(i.traces) == 0 {
|
|
return nil, nil, io.EOF
|
|
}
|
|
tr := i.traces[0]
|
|
i.traces = i.traces[1:]
|
|
return nil, tr, nil
|
|
}
|
|
|
|
func (i *testIterator) Close() {
|
|
}
|