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

Function testIngestionSlack

tempodb/wal/wal_test.go:96–135  ·  tempodb/wal/wal_test.go::testIngestionSlack
(t *testing.T, e encoding.VersionedEncoding)

Source from the content-addressed store, hash-verified

94}
95
96func testIngestionSlack(t *testing.T, e encoding.VersionedEncoding) {
97 wal, err := New(&Config{
98 Filepath: t.TempDir(),
99 IngestionSlack: time.Minute,
100 Version: encoding.DefaultEncoding().Version(),
101 })
102 require.NoError(t, err, "unexpected error creating temp wal")
103
104 blockID := uuid.New()
105 meta := backend.NewBlockMeta("fake", blockID, e.Version())
106 block, err := wal.NewBlock(meta, model.CurrentEncoding)
107 require.NoError(t, err, "unexpected error creating block")
108
109 enc := model.MustNewSegmentDecoder(model.CurrentEncoding)
110
111 traceStart := uint32(time.Now().Add(-2 * time.Minute).Unix()) // Outside of range
112 traceEnd := uint32(time.Now().Add(-1 * time.Minute).Unix()) // At end of range
113
114 // Append a trace
115 id := make([]byte, 16)
116 _, err = crand.Read(id)
117 require.NoError(t, err)
118 obj := test.MakeTrace(rand.Int()%10+1, id)
119
120 b1, err := enc.PrepareForWrite(obj, traceStart, traceEnd)
121 require.NoError(t, err)
122
123 b2, err := enc.ToObject([][]byte{b1})
124 require.NoError(t, err)
125
126 appendTime := time.Now()
127 err = block.Append(id, b2, traceStart, traceEnd, true)
128 require.NoError(t, err, "unexpected error writing req")
129
130 blockStart := uint32(block.BlockMeta().StartTime.Unix())
131 blockEnd := uint32(block.BlockMeta().EndTime.Unix())
132
133 require.Equal(t, uint32(appendTime.Unix()), blockStart)
134 require.Equal(t, uint32(appendTime.Unix()), blockEnd)
135}
136
137func TestFindByTraceID(t *testing.T) {
138 for _, e := range encoding.AllEncodingsForWrites() {

Callers 1

TestIngestionSlackFunction · 0.85

Calls 15

BlockMetaMethod · 0.95
DefaultEncodingFunction · 0.92
NewBlockMetaFunction · 0.92
MustNewSegmentDecoderFunction · 0.92
MakeTraceFunction · 0.92
NewBlockMethod · 0.80
IntMethod · 0.80
NewFunction · 0.70
VersionMethod · 0.65
AddMethod · 0.65
NowMethod · 0.65
ReadMethod · 0.65

Tested by

no test coverage detected