Skip to content

git/stats: Fix flaky timings in HTTP push tests

Patrick Steinhardt requested to merge pks-git-stats-flaky-http-push-timings into master

Part of what the HTTP push statistics provide is the information at which time we have entered specific sections. As these timings naturally fluctuate, the test for this only asserts that we have strict ordering of these times. This is flaky though:

=== FAIL: internal/git/stats TestPerformHTTPPush/branch_deletion (0.40s)
    http_push_test.go:190:
                Error Trace:	/builds/gitlab-org/gitaly/internal/git/stats/http_push_test.go:190
                Error:      	Should be true
                Test:       	TestPerformHTTPPush/branch_deletion
                Messages:   	expected to receive "response-body" packet before before "2023-03-16 14:00:22.746688075 +0000 UTC m=+5.430460188", but received at "2023-03-16 14:00:22.746688075 +0000 UTC m=+5.430460188"

The issue here is that it can happen that two packages are seemingly received at the exact same time, but because we require times to be strictly increasing the assertion fails.

Fix this flake by using require.GreaterOrEqual() instead.

Merge request reports