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:
authorWill Chandler <wchandler@gitlab.com>2023-02-15 18:51:13 +0300
committerWill Chandler <wchandler@gitlab.com>2023-02-16 17:44:08 +0300
commit57d736053e44dd0588237d50417616ef119aeeae (patch)
tree5fd39c55b2eaeecc62fb4ef16b832b8241447bec /internal
parentb457f56e7c5cc34b51441bcfa618daa44ff64143 (diff)
tracker: Fix racey error insertion in test
`TestErrorTracker_ClearErrors` would occasionally flake when the insertion time of the second write error exactly matched `now`, causing all write errors to be cleared. Use the new `incr{Read,Write}ErrTime()` methods to ensure that the errors times fall before or after our cutoff time.
Diffstat (limited to 'internal')
-rw-r--r--internal/praefect/nodes/tracker/errors_test.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/internal/praefect/nodes/tracker/errors_test.go b/internal/praefect/nodes/tracker/errors_test.go
index 81e4a8e3b..61576ac09 100644
--- a/internal/praefect/nodes/tracker/errors_test.go
+++ b/internal/praefect/nodes/tracker/errors_test.go
@@ -90,18 +90,21 @@ func TestErrorTracker_ClearErrors(t *testing.T) {
node := "backend-node-1"
- errors.IncrWriteErr(node)
- errors.IncrReadErr(node)
-
now := time.Now()
+ beforeNow := now.Add(-10 * time.Millisecond)
+ afterNow := now.Add(10 * time.Millisecond)
+
+ errors.incrWriteErrTime(node, beforeNow)
+ errors.incrReadErrTime(node, beforeNow)
+
errors.isInErrorWindow = func(_ time.Time, errTime time.Time) bool {
// Consider all errors which have been added until now to not be part of the error
// window anymore. All new events will be considered part of it though.
return errTime.After(now)
}
- errors.IncrWriteErr(node)
- errors.IncrReadErr(node)
+ errors.incrWriteErrTime(node, afterNow)
+ errors.incrReadErrTime(node, afterNow)
errors.clear()
assert.Len(t, errors.readErrors[node], 1, "clear should only have cleared the read error older than the time specified")