From 8f97d37747cbd5746ed7dc0cf96710557f4b1187 Mon Sep 17 00:00:00 2001 From: chronark Date: Fri, 20 Sep 2024 15:35:53 +0200 Subject: [PATCH] refactor(ratelimit_test.go): simplify calculation of lower limit in test fix(ratelimit_test.go): fix calculation of upper limit in test --- apps/agent/services/ratelimit/ratelimit_test.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/agent/services/ratelimit/ratelimit_test.go b/apps/agent/services/ratelimit/ratelimit_test.go index 6ae0a722ba..1d2c7dcc92 100644 --- a/apps/agent/services/ratelimit/ratelimit_test.go +++ b/apps/agent/services/ratelimit/ratelimit_test.go @@ -143,13 +143,12 @@ func TestAccuracy_fixed_time(t *testing.T) { } } - exactLimit := limit * (windows + 1) - lower := exactLimit + lower := limit * windows // At most 150% + 75% per additional ingress node should pass upper := 1.50 + 1.0*float64(len(ingressNodes)-1) require.GreaterOrEqual(t, passed, lower) - require.LessOrEqual(t, passed, int64(float64(exactLimit)*upper)) + require.LessOrEqual(t, passed, int64(float64(limit*(windows+1))*upper)) }) }