Skip to content

Commit

Permalink
Fix integration test with nicolas.henneaux.io failing some tests, usi…
Browse files Browse the repository at this point in the history
…ng another domain
  • Loading branch information
nhenneaux committed Nov 18, 2024
1 parent 7ff67db commit 5d89aa6
Showing 1 changed file with 4 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@
import static org.mockito.Mockito.when;

@SuppressWarnings("resource") // HttpClient and ExecutorService not closeable on Java 17
@Timeout(61)
class HttpClientPoolTest {

private static final Set<HealthCheckResult.HealthStatus> NOT_ERROR = Set.of(HealthCheckResult.HealthStatus.OK, HealthCheckResult.HealthStatus.WARNING);
public static final List<String> PUBLIC_HOST_TO_TEST = List.of(
"nicolas.henneaux.io", "openjdk.org", "github.com", "twitter.com", "cloudflare.com", "facebook.com", "amazon.com", "en.wikipedia.org"
//"nicolas.henneaux.io",
"openjdk.org", "github.com", "twitter.com", "cloudflare.com", "facebook.com", "amazon.com", "en.wikipedia.org"
//,"travis-ci.com","google.com" failing on Java22
);

Expand All @@ -96,7 +98,6 @@ void tearDown(TestInfo testInfo) {
}

@Test
@Timeout(61)
void getNextHttpClient() throws MalformedURLException, URISyntaxException {
for (String hostname : PUBLIC_HOST_TO_TEST) {
final ServerConfiguration serverConfiguration = new ServerConfiguration(hostname);
Expand All @@ -121,7 +122,6 @@ void getNextHttpClient() throws MalformedURLException, URISyntaxException {
}

@Test
@Timeout(61)
void resilientClient() throws MalformedURLException, URISyntaxException {
for (String hostname : PUBLIC_HOST_TO_TEST) {
final ServerConfiguration serverConfiguration = new ServerConfiguration(hostname, 443);
Expand All @@ -141,7 +141,6 @@ void resilientClient() throws MalformedURLException, URISyntaxException {
}

@Test
@Timeout(61)
void shouldUseCustomSingleHostHttpClientBuilder() throws MalformedURLException, URISyntaxException {
String hostname = oneHostname();
final ServerConfiguration serverConfiguration = new ServerConfiguration(hostname);
Expand Down Expand Up @@ -172,7 +171,6 @@ void shouldUseCustomSingleHostHttpClientBuilder() throws MalformedURLException,
}

@Test
@Timeout(61)
void shouldUseNullTruststore() throws MalformedURLException, URISyntaxException {
String hostname = oneHostname();
final ServerConfiguration serverConfiguration = new ServerConfiguration(hostname);
Expand Down Expand Up @@ -203,9 +201,8 @@ void shouldUseNullTruststore() throws MalformedURLException, URISyntaxException
}

@Test
@Timeout(61)
void shouldReturnToString() {
var hostname = "nicolas.henneaux.io";
var hostname = oneHostname();
final ServerConfiguration serverConfiguration = new ServerConfiguration(hostname);
try (HttpClientPool httpClientPool = HttpClientPool.builder(serverConfiguration)
.withScheduledExecutorService(Executors.newScheduledThreadPool(4))
Expand All @@ -224,7 +221,6 @@ void shouldReturnToString() {
}

@Test
@Timeout(61)
void getNextHttpClientNotFound() {
final String hostname = "not.found.host";
final ServerConfiguration serverConfiguration = new ServerConfiguration(hostname);
Expand All @@ -241,7 +237,6 @@ void getNextHttpClientNotFound() {
}

@Test
@Timeout(61)
void check() {
for (String hostname : PUBLIC_HOST_TO_TEST) {
final ServerConfiguration serverConfiguration = new ServerConfiguration(hostname);
Expand All @@ -262,7 +257,6 @@ private static ConditionFactory waitOneMinute(String hostname) {
}

@Test
@Timeout(61)
void checkInJson() throws JsonProcessingException {
String hostname = oneHostname();
final ServerConfiguration serverConfiguration = new ServerConfiguration(hostname);
Expand Down Expand Up @@ -298,7 +292,6 @@ private ObjectMapper objectMapper() {


@Test
@Timeout(61)
void scheduleRefresh() {
// Given
final ServerConfiguration serverConfiguration = new ServerConfiguration(oneHostname());
Expand All @@ -324,7 +317,6 @@ void scheduleRefresh() {


@Test
@Timeout(61)
void keepPreviousListWhenNewLookupEmpty() throws UnknownHostException {
// Given
final String hostname = oneHostname();
Expand Down Expand Up @@ -371,7 +363,6 @@ private void mockDns(DnsLookupWrapper dnsLookupWrapper, InetAddress byName, Set<
}

@Test
@Timeout(61)
void updatePreviousListWhenNewLookupResult() throws UnknownHostException {
// Given
final String hostname = oneHostname();
Expand Down Expand Up @@ -419,7 +410,6 @@ private static InetAddress localInetAddress() throws UnknownHostException {
}

@Test
@Timeout(61)
void updatePreviousListWhenNewLookupInvalid() throws UnknownHostException {
// Given
final String hostname = oneHostname();
Expand All @@ -442,7 +432,6 @@ void updatePreviousListWhenNewLookupInvalid() throws UnknownHostException {
}

@Test
@Timeout(61)
void warningHealthWhenOneHostDown() throws UnknownHostException {
// Given
final String hostname = oneHostname();
Expand Down Expand Up @@ -496,7 +485,6 @@ void warningHealthWhenOneHostDown() throws UnknownHostException {
}

@Test
@Timeout(61)
void shouldUseDnsFailsafe() throws IOException, InterruptedException {
// Given
final String hostname = oneHostname();
Expand Down Expand Up @@ -754,31 +742,27 @@ void shouldUseDnsFailsafeAsyncWithPushPromise() throws IOException {
}

@Test
@Timeout(61)
void validatePropertyMinus1() {
final String key = "validatePropertyMinus1";
Security.setProperty(key, "-1");
assertFalse(HttpClientPool.validateProperty(key, 10));
}

@Test
@Timeout(61)
void validatePropertyLowerThanBound() {
final String key = "validatePropertyLowerThanBound";
Security.setProperty(key, "5");
assertTrue(HttpClientPool.validateProperty(key, 10));
}

@Test
@Timeout(61)
void validatePropertyEmpty() {
final String key = "validatePropertyEmpty";
Security.setProperty(key, "");
assertTrue(HttpClientPool.validateProperty(key, 10));
}

@Test
@Timeout(61)
void validatePropertyHigherThanBound() {
final String key = "validatePropertyHigherThanBound";
Security.setProperty(key, "11");
Expand Down Expand Up @@ -820,7 +804,6 @@ private static String oneHostname() {
}

@Test
@Timeout(61)
void readme() {
HttpClientPool singleInstanceByHost = HttpClientPool.newHttpClientPool(
new ServerConfiguration(oneHostname()));
Expand Down Expand Up @@ -859,7 +842,6 @@ void shouldUpdateToFailedCountForHealthChecksFailed() {
}

@Test
@Timeout(61)
void shouldDecommissionIfCouldNotFulfillFailedResponseCountThresholdRequirement() throws IOException, URISyntaxException, InterruptedException {
// Given
final String hostname = "postman-echo.com";
Expand Down

0 comments on commit 5d89aa6

Please sign in to comment.