Skip to content

git/stats: Fix flaky test due to time ordering

The git/stats package provides functionality to parse headers written by git-send-pack(1). Part of the provided information from such a parsed stream is the exact timing information when each of the packets has been received. As we cannot rely on exact timings in our test infrastructure, we are forced to use relative ordering of the timestamps where we simply assert that times come before or after another time.

This test logic is flaky though, where the expected relative ordering between times doesn't hold. This is because we use time.Before() and time.After() though, which assert that a time comes strictly before or after another time. It can happen that the timings are exactly the same for two packages though, and in that case our assumption breaks.

Fix this flake by instead asserting that times are less or equal to the other time. Besides fixing the flake, using require.LessOrEqual() also has the benefit of better error reporting in case the test fails.

Fixes #5541 (closed).

Merge request reports