SearchStreamAndAssertTrace will search and assert that the trace is present in the streamed results. nolint: revive
(t *testing.T, ctx context.Context, client tempopb.StreamingQuerierClient, info *tempoUtil.TraceInfo, start, end int64)
| 89 | // SearchStreamAndAssertTrace will search and assert that the trace is present in the streamed results. |
| 90 | // nolint: revive |
| 91 | func SearchStreamAndAssertTrace(t *testing.T, ctx context.Context, client tempopb.StreamingQuerierClient, info *tempoUtil.TraceInfo, start, end int64) { |
| 92 | expected, err := info.ConstructTraceFromEpoch() |
| 93 | require.NoError(t, err) |
| 94 | |
| 95 | attr := tempoUtil.RandomAttrFromTrace(expected) |
| 96 | query := fmt.Sprintf(`{ .%s = "%s"}`, attr.GetKey(), attr.GetValue().GetStringValue()) |
| 97 | |
| 98 | // -- assert search |
| 99 | resp, err := client.Search(ctx, &tempopb.SearchRequest{ |
| 100 | Query: query, |
| 101 | Start: uint32(start), |
| 102 | End: uint32(end), |
| 103 | }) |
| 104 | require.NoError(t, err) |
| 105 | |
| 106 | // drain the stream until everything is returned while watching for the trace in question |
| 107 | found := false |
| 108 | for { |
| 109 | resp, err := resp.Recv() |
| 110 | if resp != nil { |
| 111 | found = traceIDInResults(t, info.HexID(), resp) |
| 112 | if found { |
| 113 | break |
| 114 | } |
| 115 | } |
| 116 | if errors.Is(err, io.EOF) { |
| 117 | break |
| 118 | } |
| 119 | require.NoError(t, err) |
| 120 | } |
| 121 | require.True(t, found) |
| 122 | } |
| 123 | |
| 124 | func traceIDInResults(t *testing.T, hexID string, resp *tempopb.SearchResponse) bool { |
| 125 | for _, s := range resp.Traces { |
nothing calls this directly
no test coverage detected