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

Function testFetch

tempodb/wal/wal_test.go:259–294  ·  view source on GitHub ↗
(t *testing.T, e encoding.VersionedEncoding)

Source from the content-addressed store, hash-verified

257}
258
259func testFetch(t *testing.T, e encoding.VersionedEncoding) {
260 runWALTest(t, e.Version(), func(ids [][]byte, objs []*tempopb.Trace, block common.WALBlock) {
261 ctx := context.Background()
262
263 for i, o := range objs {
264 k, v := findFirstAttribute(o)
265 require.NotEmpty(t, k)
266 require.NotEmpty(t, v)
267
268 query := fmt.Sprintf("{ .%s = \"%s\" }", k, v)
269
270 resp, err := block.Fetch(ctx, traceql.MustExtractFetchSpansRequestWithMetadata(query), common.DefaultSearchOptions())
271 require.NoError(t, err)
272
273 // grab the first result
274 ss, err := resp.Results.Next(ctx)
275 require.NoError(t, err)
276 require.NotNil(t, ss)
277
278 // confirm traceid matches
279 expectedID := ids[i]
280 require.NotNil(t, ss)
281 require.Equal(t, ss.TraceID, expectedID)
282
283 // ensure Bytes callback is set
284 require.NotNil(t, resp.Bytes())
285 require.NotZero(t, resp.Bytes())
286 require.LessOrEqual(t, resp.Bytes(), block.DataLength())
287
288 // confirm no more matches
289 ss, err = resp.Results.Next(ctx)
290 require.NoError(t, err)
291 require.Nil(t, ss)
292 }
293 })
294}
295
296func findFirstAttribute(obj *tempopb.Trace) (string, string) {
297 for _, b := range obj.ResourceSpans {

Callers 1

TestFetchFunction · 0.85

Calls 10

DefaultSearchOptionsFunction · 0.92
runWALTestFunction · 0.85
findFirstAttributeFunction · 0.85
BytesMethod · 0.80
VersionMethod · 0.65
FetchMethod · 0.65
NextMethod · 0.65
DataLengthMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected