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

Function testCompactionRoundtrip

tempodb/compactor_test.go:80–217  ·  tempodb/compactor_test.go::testCompactionRoundtrip
(t *testing.T, targetBlockVersion string)

Source from the content-addressed store, hash-verified

78}
79
80func testCompactionRoundtrip(t *testing.T, targetBlockVersion string) {
81 tempDir := t.TempDir()
82
83 r, w, c, err := New(&Config{
84 Backend: backend.Local,
85 Pool: &pool.Config{
86 MaxWorkers: 10,
87 QueueDepth: 100,
88 },
89 Local: &local.Config{
90 Path: path.Join(tempDir, "traces"),
91 },
92 Block: &common.BlockConfig{
93 BloomFP: .01,
94 BloomShardSizeBytes: 100_000,
95 Version: targetBlockVersion,
96 RowGroupSizeBytes: 30_000_000,
97 DedicatedColumns: backend.DedicatedColumns{{Scope: "span", Name: "key", Type: "string"}},
98 },
99 WAL: &wal.Config{
100 Filepath: path.Join(tempDir, "wal"),
101 },
102 BlocklistPoll: 0,
103 }, nil, log.NewNopLogger())
104 require.NoError(t, err)
105
106 ctx := context.Background()
107 err = c.EnableCompaction(ctx, &CompactorConfig{
108 MaxCompactionRange: 24 * time.Hour,
109 BlockRetention: 0,
110 CompactedBlockRetention: 0,
111 }, &mockSharder{}, &mockOverrides{})
112 require.NoError(t, err)
113
114 r.EnablePolling(ctx, &mockJobSharder{}, true)
115
116 wal := w.WAL()
117 require.NoError(t, err)
118
119 blockCount := 4
120 recordCount := 50
121
122 dec := model.MustNewSegmentDecoder(model.CurrentEncoding)
123
124 allReqs := make([]*tempopb.Trace, 0, blockCount*recordCount)
125 allIDs := make([]common.ID, 0, blockCount*recordCount)
126
127 for i := 0; i < blockCount; i++ {
128 blockID := backend.NewUUID()
129 meta := &backend.BlockMeta{BlockID: blockID, TenantID: testTenantID}
130 head, err := wal.NewBlock(meta, model.CurrentEncoding)
131 require.NoError(t, err)
132
133 for j := 0; j < recordCount; j++ {
134 id := test.ValidTraceID(nil)
135 req := test.MakeTrace(10, id)
136
137 writeTraceToWal(t, head, dec, id, req, 0, 0)

Callers 1

TestCompactionRoundtripFunction · 0.85

Calls 15

ConsumeMethod · 0.95
ResultMethod · 0.95
MustNewSegmentDecoderFunction · 0.92
NewUUIDFunction · 0.92
ValidTraceIDFunction · 0.92
MakeTraceFunction · 0.92
DefaultSearchOptionsFunction · 0.92
NewCombinerFunction · 0.92
SortTraceFunction · 0.92
checkBlocklistsFunction · 0.85
NewBlockMethod · 0.80

Tested by

no test coverage detected