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

Function TestQueryLimits

integration/limits/limits_test.go:188–233  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

186}
187
188func TestQueryLimits(t *testing.T) {
189 util.RunIntegrationTests(t, util.TestHarnessConfig{}, func(h *util.TempoHarness) {
190 h.WaitTracesWritable(t)
191
192 batch := util.MakeThriftBatchWithSpanCount(5)
193 require.NoError(t, h.WriteJaegerBatch(batch, ""))
194
195 // confirm the trace is queryable before adjusting overrides. otherwise the override
196 // update might beat the ingestion into livestore and the test will be flaky
197 h.WaitTracesQueryable(t, 1)
198
199 // retroactively make the trace too large so it will fail on querying
200 err := h.UpdateOverrides(map[string]*overrides.Overrides{
201 "single-tenant": {
202 Global: overrides.GlobalOverrides{
203 MaxBytesPerTrace: 1,
204 },
205 },
206 })
207 require.NoError(t, err)
208
209 // calc trace id
210 traceID := [16]byte{}
211 binary.BigEndian.PutUint64(traceID[:8], uint64(batch.Spans[0].TraceIdHigh))
212 binary.BigEndian.PutUint64(traceID[8:], uint64(batch.Spans[0].TraceIdLow))
213
214 // now try to query it back. this should fail b/c the trace is too large
215 apiClient := h.APIClientHTTP("")
216
217 _, err = apiClient.QueryTrace(tempoUtil.TraceIDToHexString(traceID[:]))
218 require.ErrorContains(t, err, trace.ErrTraceTooLarge.Error())
219 require.ErrorContains(t, err, "failed with response: 422") // confirm frontend returns 422
220
221 // wait for live store to complete the block
222 liveStore := h.Services[util.ServiceLiveStoreZoneA]
223 err = liveStore.WaitSumMetricsWithOptions(e2e.Greater(0),
224 []string{"tempo_live_store_blocks_completed_total"},
225 e2e.WaitMissingMetrics,
226 )
227 require.NoError(t, err)
228
229 _, err = apiClient.QueryTrace(tempoUtil.TraceIDToHexString(traceID[:]))
230 require.ErrorContains(t, err, trace.ErrTraceTooLarge.Error())
231 require.ErrorContains(t, err, "failed with response: 422") // confirm frontend returns 422
232 })
233}
234
235func TestLimitsPartialSuccess(t *testing.T) {
236 util.RunIntegrationTests(t, util.TestHarnessConfig{

Callers

nothing calls this directly

Calls 7

WaitTracesWritableMethod · 0.80
WriteJaegerBatchMethod · 0.80
WaitTracesQueryableMethod · 0.80
UpdateOverridesMethod · 0.80
APIClientHTTPMethod · 0.80
QueryTraceMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected