From f10c6afb43346515b19ebe904fd8c335b2b3d219 Mon Sep 17 00:00:00 2001 From: Tim Yates Date: Fri, 10 Nov 2023 09:16:23 +0000 Subject: [PATCH] Fix timeout test for different HttpClient --- .../AcmeCertRefresherTaskSetsTimeoutSpec.groovy | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/acme/src/test/groovy/io/micronaut/acme/AcmeCertRefresherTaskSetsTimeoutSpec.groovy b/acme/src/test/groovy/io/micronaut/acme/AcmeCertRefresherTaskSetsTimeoutSpec.groovy index fa5ebcfe..1a2c64e2 100644 --- a/acme/src/test/groovy/io/micronaut/acme/AcmeCertRefresherTaskSetsTimeoutSpec.groovy +++ b/acme/src/test/groovy/io/micronaut/acme/AcmeCertRefresherTaskSetsTimeoutSpec.groovy @@ -12,13 +12,11 @@ import org.testcontainers.shaded.org.apache.commons.lang3.exception.ExceptionUti import spock.lang.AutoCleanup import spock.lang.Shared import spock.lang.Specification -import spock.lang.Stepwise -import spock.lang.Unroll +import java.net.http.HttpTimeoutException import java.security.KeyPair import java.time.Duration -@Stepwise class AcmeCertRefresherTaskSetsTimeoutSpec extends Specification { public static final String EXPECTED_DOMAIN = "localhost" @@ -91,8 +89,7 @@ class AcmeCertRefresherTaskSetsTimeoutSpec extends Specification { ] as Map } - @Unroll - def "validate timeout applied if signup is slow"(SlowServerConfig config) { + def "validate timeout applied if signup is #config"(SlowServerConfig config) { given: "we have all the ports we could ever need" expectedHttpPort = SocketUtils.findAvailableTcpPort() expectedSecurePort = SocketUtils.findAvailableTcpPort() @@ -121,8 +118,8 @@ class AcmeCertRefresherTaskSetsTimeoutSpec extends Specification { ane?.message == "Network error" Throwable rootEx = ExceptionUtils.getRootCause(ex) - rootEx instanceof SocketTimeoutException - rootEx.message == "Read timed out" + rootEx instanceof HttpTimeoutException + rootEx.message == "request timed out" cleanup: appServer?.stop() @@ -136,9 +133,14 @@ class AcmeCertRefresherTaskSetsTimeoutSpec extends Specification { } class ActualSlowServerConfig implements SlowServerConfig { + boolean slowSignup boolean slowOrdering boolean slowAuthorization Duration duration = Duration.ofSeconds(networkTimeoutInSecs + 2) + + String toString() { + "slowSignup: $slowSignup, slowOrdering: $slowOrdering, slowAuthorization: $slowAuthorization, duration: $duration" + } } }