Skip to content

Fix TestUnaryLimitHandler_queueing/simple_timeout flake

For #5601 (closed)

This test setups two requests:

  • The first one is eligible. It enters the handler and blocks the queue.
  • The second request is blocked until timeout.

Both of them share this timeout. Internally, the limiter creates a context deadline to reject timed-out requests. This test has a flake because the timeout is set too low (1 ms). There's a possibility that the context exceeds the deadline when the limiter checks for the request.

We can replicate the failure by adding a tiny sleep before this line

This MR fixes that flake by setting a reasonable timeout and retry a a couple of times.

Another approach is to implement a hooking mechanism that allows us to override context deadline setup. However, that approach exposes the internal implementation of the limiter. It also adds unnecessary logic. Configuring the timeout is more straightforward and close to the expected behavior.

Edited by Quang-Minh Nguyen

Merge request reports