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

Function TestSearchCompactedBlocks

tempodb/tempodb_test.go:491–568  ·  tempodb/tempodb_test.go::TestSearchCompactedBlocks
(t *testing.T)

Source from the content-addressed store, hash-verified

489}
490
491func TestSearchCompactedBlocks(t *testing.T) {
492 t.Parallel()
493 r, w, c, _ := testConfig(t, time.Hour)
494
495 err := c.EnableCompaction(context.Background(), &CompactorConfig{
496 MaxCompactionRange: time.Hour,
497 BlockRetention: 0,
498 CompactedBlockRetention: 0,
499 }, &mockSharder{}, &mockOverrides{})
500 require.NoError(t, err)
501
502 r.EnablePolling(context.Background(), &mockJobSharder{}, false)
503
504 wal := w.WAL()
505
506 meta := &backend.BlockMeta{BlockID: backend.NewUUID(), TenantID: testTenantID}
507 head, err := wal.NewBlock(meta, model.CurrentEncoding)
508 assert.NoError(t, err)
509
510 dec := model.MustNewSegmentDecoder(model.CurrentEncoding)
511
512 // write
513 numMsgs := 10
514 reqs := make([]*tempopb.Trace, 0, numMsgs)
515 ids := make([][]byte, 0, numMsgs)
516 for i := 0; i < numMsgs; i++ {
517 id := test.ValidTraceID(nil)
518 req := test.MakeTrace(rand.Int()%1000, id)
519 writeTraceToWal(t, head, dec, id, req, 0, 0)
520 reqs = append(reqs, req)
521 ids = append(ids, id)
522 }
523
524 ctx := context.Background()
525 complete, err := w.CompleteBlock(ctx, head)
526 require.NoError(t, err)
527
528 blockID := complete.BlockMeta().BlockID.String()
529
530 rw := r.(*readerWriter)
531
532 // poll
533 rw.pollBlocklist(ctx)
534
535 // read
536 for i, id := range ids {
537 bFound, failedBlocks, err := r.Find(ctx, testTenantID, id, blockID, blockID, 0, 0, common.DefaultSearchOptions())
538 require.NoError(t, err)
539 require.Nil(t, failedBlocks)
540 require.True(t, proto.Equal(bFound[0].Trace, reqs[i]))
541 require.Greater(t, bFound[0].Metrics.InspectedBytes, uint64(100000))
542 }
543
544 // compact
545 var blockMetas []*backend.BlockMeta
546 blockMetas = append(blockMetas, complete.BlockMeta())
547 require.NoError(t, rw.compactOneJob(ctx, blockMetas, testTenantID))
548

Callers

nothing calls this directly

Calls 15

NewUUIDFunction · 0.92
MustNewSegmentDecoderFunction · 0.92
ValidTraceIDFunction · 0.92
MakeTraceFunction · 0.92
DefaultSearchOptionsFunction · 0.92
NewBlockMethod · 0.80
IntMethod · 0.80
pollBlocklistMethod · 0.80
compactOneJobMethod · 0.80
testConfigFunction · 0.70
writeTraceToWalFunction · 0.70
EnableCompactionMethod · 0.65

Tested by

no test coverage detected