Skip to content

Fix Thread#sleep in ClientStatsTest #1904

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions client/src/test/java/org/asynchttpclient/ClientStatsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package org.asynchttpclient;

import io.github.artsok.RepeatedIfExceptionsTest;
import org.junit.jupiter.api.Test;

import java.time.Duration;
import java.util.List;
Expand All @@ -34,7 +34,7 @@ public class ClientStatsTest extends AbstractBasicTest {

private static final String hostname = "localhost";

@RepeatedIfExceptionsTest(repeats = 5)
@Test
public void testClientStatus() throws Throwable {
try (final AsyncHttpClient client = asyncHttpClient(config().setKeepAlive(true).setPooledConnectionIdleTimeout(Duration.ofSeconds(5)))) {
final String url = getTargetUrl();
Expand All @@ -51,7 +51,7 @@ public void testClientStatus() throws Throwable {
.limit(5)
.collect(Collectors.toList());

Thread.sleep(2000 + 1000);
Thread.sleep(2000);

final ClientStats activeStats = client.getClientStats();

Expand All @@ -63,7 +63,7 @@ public void testClientStatus() throws Throwable {

futures.forEach(future -> future.toCompletableFuture().join());

Thread.sleep(1000 + 1000);
Thread.sleep(1000);

final ClientStats idleStats = client.getClientStats();

Expand All @@ -79,7 +79,7 @@ public void testClientStatus() throws Throwable {
.limit(3)
.collect(Collectors.toList());

Thread.sleep(2000 + 1000);
Thread.sleep(2000);

final ClientStats activeCachedStats = client.getClientStats();

Expand All @@ -91,7 +91,7 @@ public void testClientStatus() throws Throwable {

repeatedFutures.forEach(future -> future.toCompletableFuture().join());

Thread.sleep(1000 + 1000);
Thread.sleep(1000);

final ClientStats idleCachedStats = client.getClientStats();

Expand All @@ -101,7 +101,7 @@ public void testClientStatus() throws Throwable {
assertEquals(3, idleCachedStats.getTotalConnectionCount());
assertEquals(3, idleCachedStats.getStatsPerHost().get(hostname).getHostConnectionCount());

Thread.sleep(5000 + 1000);
Thread.sleep(5000);

final ClientStats timeoutStats = client.getClientStats();

Expand All @@ -113,7 +113,7 @@ public void testClientStatus() throws Throwable {
}
}

@RepeatedIfExceptionsTest(repeats = 5)
@Test
public void testClientStatusNoKeepalive() throws Throwable {
try (final AsyncHttpClient client = asyncHttpClient(config().setKeepAlive(false).setPooledConnectionIdleTimeout(Duration.ofSeconds(1)))) {
final String url = getTargetUrl();
Expand All @@ -130,7 +130,7 @@ public void testClientStatusNoKeepalive() throws Throwable {
.limit(5)
.collect(Collectors.toList());

Thread.sleep(2000 + 1000);
Thread.sleep(2000);

final ClientStats activeStats = client.getClientStats();

Expand All @@ -142,7 +142,7 @@ public void testClientStatusNoKeepalive() throws Throwable {

futures.forEach(future -> future.toCompletableFuture().join());

Thread.sleep(1000 + 1000);
Thread.sleep(1000);

final ClientStats idleStats = client.getClientStats();

Expand All @@ -158,7 +158,7 @@ public void testClientStatusNoKeepalive() throws Throwable {
.limit(3)
.collect(Collectors.toList());

Thread.sleep(2000 + 1000);
Thread.sleep(2000);

final ClientStats activeCachedStats = client.getClientStats();

Expand All @@ -170,7 +170,7 @@ public void testClientStatusNoKeepalive() throws Throwable {

repeatedFutures.forEach(future -> future.toCompletableFuture().join());

Thread.sleep(1000 + 1000);
Thread.sleep(1000);

final ClientStats idleCachedStats = client.getClientStats();

Expand Down