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

Function TestBlockCleanup

tempodb/tempodb_test.go:201–241  ·  tempodb/tempodb_test.go::TestBlockCleanup
(t *testing.T)

Source from the content-addressed store, hash-verified

199}
200
201func TestBlockCleanup(t *testing.T) {
202 r, w, c, tempDir := testConfig(t, 0)
203
204 err := c.EnableCompaction(context.Background(), &CompactorConfig{
205 MaxCompactionRange: time.Hour,
206 BlockRetention: 0,
207 CompactedBlockRetention: 0,
208 }, &mockSharder{}, &mockOverrides{})
209 require.NoError(t, err)
210
211 r.EnablePolling(context.Background(), &mockJobSharder{}, false)
212
213 ctx, cancel := context.WithCancel(context.Background())
214 defer cancel()
215
216 blockID := backend.NewUUID()
217
218 wal := w.WAL()
219
220 meta := &backend.BlockMeta{BlockID: blockID, TenantID: testTenantID}
221 head, err := wal.NewBlock(meta, model.CurrentEncoding)
222 assert.NoError(t, err)
223
224 _, err = w.CompleteBlock(context.Background(), head)
225 assert.NoError(t, err)
226
227 rw := r.(*readerWriter)
228
229 // poll
230 rw.pollBlocklist(ctx)
231
232 assert.Len(t, rw.blocklist.Metas(testTenantID), 1)
233
234 os.RemoveAll(tempDir + "/traces/" + testTenantID)
235
236 // poll
237 rw.pollBlocklist(ctx)
238
239 m := rw.blocklist.Metas(testTenantID)
240 assert.Equal(t, 0, len(m))
241}
242
243func checkBlocklists(ctx context.Context, t *testing.T, expectedID uuid.UUID, expectedB int, expectedCB int, rw *readerWriter) {
244 rw.pollBlocklist(ctx)

Callers

nothing calls this directly

Calls 11

NewUUIDFunction · 0.92
NewBlockMethod · 0.80
pollBlocklistMethod · 0.80
testConfigFunction · 0.70
EnableCompactionMethod · 0.65
EnablePollingMethod · 0.65
WALMethod · 0.65
CompleteBlockMethod · 0.65
LenMethod · 0.65
MetasMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected