MCPcopy
hub / github.com/grafana/tempo / testCompactionDropsTraces

Function testCompactionDropsTraces

tempodb/compactor_test.go:645–749  ·  tempodb/compactor_test.go::testCompactionDropsTraces
(t *testing.T, targetBlockVersion string)

Source from the content-addressed store, hash-verified

643}
644
645func testCompactionDropsTraces(t *testing.T, targetBlockVersion string) {
646 tempDir := t.TempDir()
647
648 r, w, _, err := New(&Config{
649 Backend: backend.Local,
650 Pool: &pool.Config{
651 MaxWorkers: 10,
652 QueueDepth: 100,
653 },
654 Local: &local.Config{
655 Path: path.Join(tempDir, "traces"),
656 },
657 Block: &common.BlockConfig{
658 BloomFP: .01,
659 BloomShardSizeBytes: 100_000,
660 Version: targetBlockVersion,
661 RowGroupSizeBytes: 30_000_000,
662 },
663 WAL: &wal.Config{
664 Filepath: path.Join(tempDir, "wal"),
665 },
666 BlocklistPoll: 0,
667 }, nil, log.NewNopLogger())
668 require.NoError(t, err)
669
670 wal := w.WAL()
671 require.NoError(t, err)
672
673 dec := model.MustNewSegmentDecoder(v1.Encoding)
674
675 recordCount := 100
676 allIDs := make([]common.ID, 0, recordCount)
677
678 // write a bunch of dummy data
679 blockID := backend.NewUUID()
680 meta := &backend.BlockMeta{BlockID: blockID, TenantID: testTenantID}
681 head, err := wal.NewBlock(meta, v1.Encoding)
682 require.NoError(t, err)
683
684 for j := 0; j < recordCount; j++ {
685 id := test.ValidTraceID(nil)
686 allIDs = append(allIDs, id)
687
688 obj, err := dec.PrepareForWrite(test.MakeTrace(1, id), 0, 0)
689 require.NoError(t, err)
690
691 obj2, err := dec.ToObject([][]byte{obj})
692 require.NoError(t, err)
693
694 err = head.Append(id, obj2, 0, 0, true)
695 require.NoError(t, err, "unexpected error writing req")
696 }
697
698 firstBlock, err := w.CompleteBlock(context.Background(), head)
699 require.NoError(t, err)
700
701 // choose a random id to drop
702 dropID := allIDs[rand.Intn(len(allIDs))]

Callers 1

Calls 15

CompactMethod · 0.95
MustNewSegmentDecoderFunction · 0.92
NewUUIDFunction · 0.92
ValidTraceIDFunction · 0.92
MakeTraceFunction · 0.92
FromVersionFunction · 0.92
DefaultSearchOptionsFunction · 0.92
NewBlockMethod · 0.80
NewFunction · 0.70
JoinMethod · 0.65
WALMethod · 0.65
PrepareForWriteMethod · 0.65

Tested by

no test coverage detected