Skip to content

Commit 4845438

Browse files
committed
test improvement
1 parent dc524c0 commit 4845438

File tree

1 file changed

+8
-4
lines changed
  • operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/rate

1 file changed

+8
-4
lines changed

operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/rate/RateLimiterTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,19 @@
1212

1313
class RateLimiterTest {
1414

15-
public static final Duration REFRESH_PERIOD = Duration.ofSeconds(1);
15+
public static final Duration REFRESH_PERIOD = Duration.ofMillis(300);
1616
ResourceID resourceID = ResourceID.fromResource(TestUtils.testCustomResource());
1717

1818
@Test
1919
void acquirePermissionForNewResource() {
20-
var rl = new RateLimiter(REFRESH_PERIOD, 1);
20+
var rl = new RateLimiter(REFRESH_PERIOD, 2);
2121
var res = rl.acquirePermission(resourceID);
22-
2322
assertThat(res).isEmpty();
23+
res = rl.acquirePermission(resourceID);
24+
assertThat(res).isEmpty();
25+
26+
res = rl.acquirePermission(resourceID);
27+
assertThat(res).isNotEmpty();
2428
}
2529

2630
@Test
@@ -44,7 +48,7 @@ void resetsPeriodAfterLimit() throws InterruptedException {
4448
assertThat(res).isPresent();
4549

4650
// sleep plus some slack
47-
Thread.sleep(REFRESH_PERIOD.toMillis() + REFRESH_PERIOD.toMillis() / 2);
51+
Thread.sleep(REFRESH_PERIOD.toMillis() + REFRESH_PERIOD.toMillis() / 3);
4852

4953
res = rl.acquirePermission(resourceID);
5054
assertThat(res).isEmpty();

0 commit comments

Comments
 (0)