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

Function TestBlockRetentionOverrideDisabled

tempodb/retention_test.go:213–264  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

211}
212
213func TestBlockRetentionOverrideDisabled(t *testing.T) {
214 tempDir := t.TempDir()
215
216 r, w, c, err := New(&Config{
217 Backend: backend.Local,
218 Local: &local.Config{
219 Path: path.Join(tempDir, "traces"),
220 },
221 Block: &common.BlockConfig{
222 BloomFP: 0.01,
223 BloomShardSizeBytes: 100_000,
224 Version: encoding.DefaultEncoding().Version(),
225 },
226 WAL: &wal.Config{
227 Filepath: path.Join(tempDir, "wal"),
228 },
229 BlocklistPoll: 0,
230 }, nil, log.NewNopLogger())
231 require.NoError(t, err)
232
233 overrides := &mockOverrides{
234 disabled: true,
235 }
236
237 ctx := context.Background()
238 err = c.EnableCompaction(ctx, &CompactorConfig{
239 MaxCompactionRange: time.Hour,
240 BlockRetention: time.Hour,
241 CompactedBlockRetention: 0,
242 }, &mockSharder{}, overrides)
243 require.NoError(t, err)
244
245 r.EnablePolling(ctx, &mockJobSharder{}, false)
246
247 cutTestBlocks(t, w, testTenantID, 10, 10)
248
249 // The test spans are all 1 second long, so we have to sleep to put all the
250 // data in the past
251 time.Sleep(time.Second)
252
253 rw := r.(*readerWriter)
254 rw.pollBlocklist(ctx)
255 require.Equal(t, 10, len(rw.blocklist.Metas(testTenantID)))
256
257 time.Sleep(10 * time.Millisecond)
258
259 // Retention = 1ns, deletes everything
260 overrides.blockRetention = time.Nanosecond
261 r.(*readerWriter).doRetention(ctx)
262 rw.pollBlocklist(ctx)
263 require.Equal(t, 10, len(rw.blocklist.Metas(testTenantID)))
264}
265
266func TestRetainWithConfig(t *testing.T) {
267 for _, enc := range encoding.AllEncodingsForWrites() {

Callers

nothing calls this directly

Calls 12

DefaultEncodingFunction · 0.92
pollBlocklistMethod · 0.80
doRetentionMethod · 0.80
NewFunction · 0.70
cutTestBlocksFunction · 0.70
JoinMethod · 0.65
VersionMethod · 0.65
EnableCompactionMethod · 0.65
EnablePollingMethod · 0.65
SleepMethod · 0.65
EqualMethod · 0.45
MetasMethod · 0.45

Tested by

no test coverage detected