Skip to content

Commit 74904a9

Browse files
committed
Reduce test runtime
Co-authored by: Codex / GPT-6.1-Sol-High
1 parent 9953c54 commit 74904a9

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

‎test/org/apache/catalina/filters/TestRateLimitFilterWithExactRateLimiter.java‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ private void testRateLimitWith4Clients(boolean exposeHeaders, boolean enforce) t
5959
System.out.printf("Sleeping %d millis for the next time bucket to start\n", Long.valueOf(sleepTime));
6060
Thread.sleep(sleepTime);
6161

62-
TestClient tc1 = new TestClient(rateLimitFilter, filterChain, "10.20.20.5", 50, 5); // TPS: 5
63-
TestClient tc2 = new TestClient(rateLimitFilter, filterChain, "10.20.20.10", 100, 10); // TPS: 10
62+
// Stop each client after the last response checked below.
63+
TestClient tc1 = new TestClient(rateLimitFilter, filterChain, "10.20.20.5", 25, 5); // TPS: 5
64+
TestClient tc2 = new TestClient(rateLimitFilter, filterChain, "10.20.20.10", 50, 10); // TPS: 10
6465

65-
TestClient tc3 = new TestClient(rateLimitFilter, filterChain, "10.20.20.20", 200, 20); // TPS: 20
66-
TestClient tc4 = new TestClient(rateLimitFilter, filterChain, "10.20.20.40", 400, 40); // TPS: 40
66+
TestClient tc3 = new TestClient(rateLimitFilter, filterChain, "10.20.20.20", allowedRequests + 1, 20); // TPS: 20
67+
TestClient tc4 = new TestClient(rateLimitFilter, filterChain, "10.20.20.40", allowedRequests + 1, 40); // TPS: 40
6768
tc1.join();
6869
tc2.join();
6970
tc3.join();
@@ -164,7 +165,7 @@ void waitForNextRequest(long start, int requestIndex) throws Exception {
164165
*/
165166
long expectedDuration = (requestIndex + 1) * timePerRequest;
166167
long duration = (System.nanoTime() - start) / 1000000;
167-
if (expectedDuration > duration) {
168+
if (requestIndex + 1 < requests && expectedDuration > duration) {
168169
sleep(expectedDuration - duration);
169170
}
170171
}

0 commit comments

Comments
 (0)