Skip to content

Commit 19f3bbe

Browse files
committed
Remove flaky test - which wasn't testing the property it described. Closes #59
1 parent 129f397 commit 19f3bbe

File tree

1 file changed

+0
-24
lines changed

1 file changed

+0
-24
lines changed

examples/src/test/scala/ox/ratelimiter/test/RateLimiterTest.scala

-24
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,3 @@ class RateLimiterTest extends AnyFlatSpec with Matchers with Eventually with Int
3030
}
3131
}
3232

33-
it should "maintain the rate limit in all time windows" in {
34-
RateLimiter.withRateLimiter(10, 1.second) { rateLimiter =>
35-
val complete = new AtomicReference(Vector.empty[Long])
36-
for (i <- 1 to 20) {
37-
rateLimiter.runLimited {
38-
println(s"${LocalTime.now()} Running $i")
39-
complete.updateAndGet(_ :+ System.currentTimeMillis())
40-
}
41-
Thread.sleep(100)
42-
}
43-
44-
eventually {
45-
complete.get() should have size (20)
46-
47-
// the spacing should be preserved. In a token bucket algorithm, at some point the bucket would refill and
48-
// all pending futures would be run. In a windowed algorithm, the spacings are preserved.
49-
val secondHalf = complete.get().slice(10, 20)
50-
secondHalf.zip(secondHalf.tail).map { case (p, n) => n - p }.foreach { d =>
51-
d should be <= (150L)
52-
d should be >= (50L)
53-
}
54-
}
55-
}
56-
}

0 commit comments

Comments
 (0)