Browse Source
Fix flaky TbRateLimitsTest timing tolerance
Increased timing tolerance gap from 500ms to 1000ms in both
testRateLimitWithGreedyRefill and testRateLimitWithIntervalRefill
to prevent ConditionTimeoutException caused by scheduling jitter.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
pull/15047/head
Viacheslav Klimov
7 months ago
Failed to extract signature
1 changed files with
2 additions and
2 deletions
common/message/src/test/java/org/thingsboard/server/common/msg/tools/TbRateLimitsTest.java
@ -42,7 +42,7 @@ public class TbRateLimitsTest {
assertThat ( rateLimits . tryConsume ( ) ) . as ( "new token is available" ) . isFalse ( ) ;
assertThat ( rateLimits . tryConsume ( ) ) . as ( "new token is available" ) . isFalse ( ) ;
int expectedRefillTime = ( int ) ( ( ( double ) period / capacity ) * 1000 ) ;
int expectedRefillTime = ( int ) ( ( ( double ) period / capacity ) * 1000 ) ;
int gap = 5 00;
int gap = 10 00;
for ( int i = 0 ; i < capacity ; i + + ) {
for ( int i = 0 ; i < capacity ; i + + ) {
await ( "token refill for rate limit " + rateLimitConfig )
await ( "token refill for rate limit " + rateLimitConfig )
@ -71,7 +71,7 @@ public class TbRateLimitsTest {
assertThat ( rateLimits . tryConsume ( ) ) . as ( "new token is available" ) . isFalse ( ) ;
assertThat ( rateLimits . tryConsume ( ) ) . as ( "new token is available" ) . isFalse ( ) ;
int expectedRefillTime = period * 1000 ;
int expectedRefillTime = period * 1000 ;
int gap = 5 00;
int gap = 10 00;
await ( "tokens refill for rate limit " + rateLimitConfig )
await ( "tokens refill for rate limit " + rateLimitConfig )
. pollInterval ( new FixedPollInterval ( 10 , TimeUnit . MILLISECONDS ) )
. pollInterval ( new FixedPollInterval ( 10 , TimeUnit . MILLISECONDS ) )