Skip to content

Fix flaky TestGetSpawnToken_CommandStats test

For #5468 (closed)

This test aims to test the metrics of spawn tokens. One particularly interesting metric is the gitaly_spawn_token_waiting_length gauge. It measures the length of the queue waiting for a spawn token.

In the test, we set up two main and secondary goroutines. The spawn token parallelism is set to 1. The main goroutine acquires the goroutine first, second one in parallel follows. However, the second goroutine may not start on time, or the acquiring function hasn't been called at the time the metrics are asserted.

Even after the second goroutine starts, there is a small possibility for the metric collection to run before the second goroutine lines up for the token. There is no way to get a precise signal when the second goroutine is waiting. Hence, the only solution is to poll for the metric until it changes.

Merge request reports