(t *testing.T)
| 435 | } |
| 436 | |
| 437 | func TestCompactionMetrics(t *testing.T) { |
| 438 | tempDir := t.TempDir() |
| 439 | |
| 440 | r, w, c, err := New(&Config{ |
| 441 | Backend: backend.Local, |
| 442 | Pool: &pool.Config{ |
| 443 | MaxWorkers: 10, |
| 444 | QueueDepth: 100, |
| 445 | }, |
| 446 | Local: &local.Config{ |
| 447 | Path: path.Join(tempDir, "traces"), |
| 448 | }, |
| 449 | Block: &common.BlockConfig{ |
| 450 | BloomFP: .01, |
| 451 | BloomShardSizeBytes: 100_000, |
| 452 | Version: encoding.DefaultEncoding().Version(), |
| 453 | }, |
| 454 | WAL: &wal.Config{ |
| 455 | Filepath: path.Join(tempDir, "wal"), |
| 456 | }, |
| 457 | BlocklistPoll: 0, |
| 458 | }, nil, log.NewNopLogger()) |
| 459 | assert.NoError(t, err) |
| 460 | |
| 461 | ctx := context.Background() |
| 462 | err = c.EnableCompaction(ctx, &CompactorConfig{ |
| 463 | MaxCompactionRange: 24 * time.Hour, |
| 464 | BlockRetention: 0, |
| 465 | CompactedBlockRetention: 0, |
| 466 | }, &mockSharder{}, &mockOverrides{}) |
| 467 | require.NoError(t, err) |
| 468 | |
| 469 | r.EnablePolling(ctx, &mockJobSharder{}, true) |
| 470 | |
| 471 | // Cut x blocks with y records each |
| 472 | blockCount := 5 |
| 473 | recordCount := 10 |
| 474 | cutTestBlocks(t, w, testTenantID, blockCount, recordCount) |
| 475 | |
| 476 | rw := r.(*readerWriter) |
| 477 | rw.pollBlocklist(ctx) |
| 478 | |
| 479 | // Get starting metrics |
| 480 | processedStart, err := test.GetCounterVecValue(metricCompactionObjectsWritten, "0") |
| 481 | assert.NoError(t, err) |
| 482 | |
| 483 | blocksStart, err := test.GetCounterVecValue(metricCompactionBlocks, "0") |
| 484 | assert.NoError(t, err) |
| 485 | |
| 486 | bytesStart, err := test.GetCounterVecValue(metricCompactionBytesWritten, "0") |
| 487 | assert.NoError(t, err) |
| 488 | |
| 489 | // compact everything |
| 490 | err = rw.compactOneJob(ctx, rw.blocklist.Metas(testTenantID), testTenantID) |
| 491 | assert.NoError(t, err) |
| 492 | |
| 493 | // Check metric |
| 494 | processedEnd, err := test.GetCounterVecValue(metricCompactionObjectsWritten, "0") |
nothing calls this directly
no test coverage detected