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

Function testCompactionHonorsBlockStartEndTimes

tempodb/compactor_test.go:574–634  ·  view source on GitHub ↗
(t *testing.T, targetBlockVersion string)

Source from the content-addressed store, hash-verified

572}
573
574func testCompactionHonorsBlockStartEndTimes(t *testing.T, targetBlockVersion string) {
575 tempDir := t.TempDir()
576
577 r, w, c, err := New(&Config{
578 Backend: backend.Local,
579 Pool: &pool.Config{
580 MaxWorkers: 10,
581 QueueDepth: 100,
582 },
583 Local: &local.Config{
584 Path: path.Join(tempDir, "traces"),
585 },
586 Block: &common.BlockConfig{
587 BloomFP: .01,
588 BloomShardSizeBytes: 100_000,
589 Version: targetBlockVersion,
590 RowGroupSizeBytes: 30_000_000,
591 },
592 WAL: &wal.Config{
593 Filepath: path.Join(tempDir, "wal"),
594 IngestionSlack: time.Since(time.Unix(0, 0)), // Let us use obvious start/end times below
595 },
596 BlocklistPoll: 0,
597 }, nil, log.NewNopLogger())
598 require.NoError(t, err)
599
600 ctx := context.Background()
601 err = c.EnableCompaction(ctx, &CompactorConfig{
602 MaxCompactionRange: 24 * time.Hour,
603 BlockRetention: 0,
604 CompactedBlockRetention: 0,
605 }, &mockSharder{}, &mockOverrides{})
606 require.NoError(t, err)
607
608 r.EnablePolling(ctx, &mockJobSharder{}, true)
609
610 cutTestBlockWithTraces(t, w, []testData{
611 {test.ValidTraceID(nil), test.MakeTrace(10, nil), 100, 101},
612 {test.ValidTraceID(nil), test.MakeTrace(10, nil), 102, 103},
613 })
614 cutTestBlockWithTraces(t, w, []testData{
615 {test.ValidTraceID(nil), test.MakeTrace(10, nil), 104, 105},
616 {test.ValidTraceID(nil), test.MakeTrace(10, nil), 106, 107},
617 })
618
619 rw := r.(*readerWriter)
620 rw.pollBlocklist(ctx)
621
622 // compact everything
623 err = rw.compactOneJob(ctx, rw.blocklist.Metas(testTenantID), testTenantID)
624 require.NoError(t, err)
625
626 time.Sleep(100 * time.Millisecond)
627
628 // New blocklist contains 1 compacted block with min start and max end
629 blocks := rw.blocklist.Metas(testTenantID)
630 require.Equal(t, 1, len(blocks))
631 require.Equal(t, uint32(1), blocks[0].CompactionLevel)

Calls 12

ValidTraceIDFunction · 0.92
MakeTraceFunction · 0.92
cutTestBlockWithTracesFunction · 0.85
pollBlocklistMethod · 0.80
compactOneJobMethod · 0.80
NewFunction · 0.70
JoinMethod · 0.65
EnableCompactionMethod · 0.65
EnablePollingMethod · 0.65
SleepMethod · 0.65
MetasMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected