(t *testing.T)
| 280 | } |
| 281 | |
| 282 | func TestQueryRateLimits(t *testing.T) { |
| 283 | util.RunIntegrationTests(t, util.TestHarnessConfig{ |
| 284 | ConfigOverlay: configQueryRate, |
| 285 | }, func(h *util.TempoHarness) { |
| 286 | h.WaitTracesWritable(t) |
| 287 | // todo: do we even need to push a trace? |
| 288 | batch := util.MakeThriftBatchWithSpanCount(5) |
| 289 | require.NoError(t, h.WriteJaegerBatch(batch, "")) |
| 290 | |
| 291 | // now try to query it back. this should fail b/c the frontend queue doesn't have room |
| 292 | apiClient := h.APIClientHTTP("") |
| 293 | |
| 294 | // 429 HTTP Trace ID Lookup |
| 295 | traceID := []byte{0x01, 0x02} |
| 296 | _, err := apiClient.QueryTrace(tempoUtil.TraceIDToHexString(traceID)) |
| 297 | require.ErrorContains(t, err, "job queue full") |
| 298 | require.ErrorContains(t, err, "failed with response: 429") |
| 299 | |
| 300 | start := time.Now().Add(-1 * time.Hour).Unix() |
| 301 | end := time.Now().Add(1 * time.Hour).Unix() |
| 302 | |
| 303 | // 429 HTTP Search |
| 304 | _, err = apiClient.SearchTraceQLWithRange("{}", start, end) |
| 305 | require.ErrorContains(t, err, "job queue full") |
| 306 | require.ErrorContains(t, err, "failed with response: 429") |
| 307 | |
| 308 | // 429 GRPC Search |
| 309 | grpcClient, ctx, err := h.APIClientGRPC("") |
| 310 | require.NoError(t, err) |
| 311 | |
| 312 | resp, err := grpcClient.Search(ctx, &tempopb.SearchRequest{ |
| 313 | Query: "{}", |
| 314 | Start: uint32(start), |
| 315 | End: uint32(end), |
| 316 | }) |
| 317 | require.NoError(t, err) |
| 318 | |
| 319 | // loop until we get io.EOF or an error |
| 320 | for { |
| 321 | _, err = resp.Recv() |
| 322 | if err != nil { |
| 323 | break |
| 324 | } |
| 325 | } |
| 326 | require.ErrorContains(t, err, "job queue full") |
| 327 | require.ErrorContains(t, err, "code = ResourceExhausted") |
| 328 | }) |
| 329 | } |
nothing calls this directly
no test coverage detected