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

Function cutTestBlocks

tempodb/compactor_test.go:857–880  ·  view source on GitHub ↗
(t testing.TB, w Writer, tenantID string, blockCount int, recordCount int)

Source from the content-addressed store, hash-verified

855}
856
857func cutTestBlocks(t testing.TB, w Writer, tenantID string, blockCount int, recordCount int) []common.BackendBlock {
858 blocks := make([]common.BackendBlock, 0)
859 dec := model.MustNewSegmentDecoder(model.CurrentEncoding)
860
861 wal := w.WAL()
862 for i := 0; i < blockCount; i++ {
863 meta := &backend.BlockMeta{BlockID: backend.NewUUID(), TenantID: tenantID}
864 head, err := wal.NewBlock(meta, model.CurrentEncoding)
865 require.NoError(t, err)
866
867 for j := 0; j < recordCount; j++ {
868 id := makeTraceID(i, j)
869 tr := test.MakeTrace(1, id)
870 now := uint32(time.Now().Unix())
871 writeTraceToWal(t, head, dec, id, tr, now, now)
872 }
873
874 b, err := w.CompleteBlock(context.Background(), head)
875 require.NoError(t, err)
876 blocks = append(blocks, b)
877 }
878
879 return blocks
880}
881
882func makeTraceID(i int, j int) []byte {
883 id := make([]byte, 16)

Calls 9

MustNewSegmentDecoderFunction · 0.92
NewUUIDFunction · 0.92
MakeTraceFunction · 0.92
NewBlockMethod · 0.80
makeTraceIDFunction · 0.70
writeTraceToWalFunction · 0.70
WALMethod · 0.65
NowMethod · 0.65
CompleteBlockMethod · 0.65

Tested by

no test coverage detected