Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2023-09-07 09:26:23 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2023-09-07 09:26:23 +0300
commit5c205ddf27ab9b290efa256060940505caa2c201 (patch)
treea38a60ccbcd054d0cbd8b5df5dd0f37b7be72bd5
parent0279bd27cb92941ba71936f10a63cd52bd081c63 (diff)
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.
-rw-r--r--internal/git/stats/send_pack_test.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/internal/git/stats/send_pack_test.go b/internal/git/stats/send_pack_test.go
index 5434f4739..7a2b33cb2 100644
--- a/internal/git/stats/send_pack_test.go
+++ b/internal/git/stats/send_pack_test.go
@@ -37,8 +37,8 @@ func TestSendPack_Parse(t *testing.T) {
require.Equal(t, 44, sendPack.largestPacketSize)
for _, band := range []string{"pack", "progress"} {
- require.True(t, startTime.Before(sendPack.multiband[band].firstPacket))
- require.True(t, endTime.After(sendPack.multiband[band].firstPacket))
+ require.LessOrEqual(t, startTime, sendPack.multiband[band].firstPacket)
+ require.LessOrEqual(t, sendPack.multiband[band].firstPacket, endTime)
sendPack.multiband[band].firstPacket = startTime
}