diff options
author | Quang-Minh Nguyen <qmnguyen@gitlab.com> | 2023-09-19 05:39:02 +0300 |
---|---|---|
committer | Quang-Minh Nguyen <qmnguyen@gitlab.com> | 2023-09-19 05:39:02 +0300 |
commit | 3842bac5b59754f1dac38e791213c105658164ad (patch) | |
tree | 0ff9a5374bf73a02b3ee60db34ae0b1e58ed1e88 | |
parent | 8e36035898e136f098e71e8d77052542edccbf8f (diff) |
Flaky tests: Fix TestAdaptiveCalculator flaky tests
In TestAdaptiveCalculator, we set the calibration duration to 10
milliseconds. This test setup uses a manual ticker. This calibration
duration is irrelevant to the actual calibration cycle of the
calculation. That value was supposed to be a placeholder.
Unfortunately, the calculator uses this value to determine a timeout
when polling events from the watchers. Although event polling is
supposed to be instant, it might not be the case for slow machines.
Thus, on CIs, even polling might return deadline exceeded
unintentionally. This commit fixes this flake by setting the calibration
duration to an unrealistically high value.
For https://gitlab.com/gitlab-org/gitaly/-/issues/5467.
-rw-r--r-- | internal/limiter/adaptive_calculator_test.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/internal/limiter/adaptive_calculator_test.go b/internal/limiter/adaptive_calculator_test.go index 7fed9b01b..2a735ed59 100644 --- a/internal/limiter/adaptive_calculator_test.go +++ b/internal/limiter/adaptive_calculator_test.go @@ -555,7 +555,11 @@ gitaly_concurrency_limiting_watcher_errors_total{watcher="testWatcher2"} 5 close(tickerDone) }) - calibration := 10 * time.Millisecond + // This test setup uses a manual ticker. This calibration duration is irrelevant to the actual + // calibration cycle of the calculation. However, the calculator uses this value to determine a + // timeout when polling events from the watchers. Thus, we need to pass an unrealistically high + // value. Otherwise, the tests might be flaky when running on slow machines. + calibration := 1 * time.Hour calculator := NewAdaptiveCalculator(calibration, logger, tc.limits, tc.watchers) calculator.tickerCreator = func(duration time.Duration) helper.Ticker { return ticker } |