Skip to content

Commit

Permalink
Fix timeout test for different HttpClient
Browse files Browse the repository at this point in the history
  • Loading branch information
timyates committed Nov 10, 2023
1 parent 61e8bed commit f10c6af
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -91,8 +89,7 @@ class AcmeCertRefresherTaskSetsTimeoutSpec extends Specification {
] as Map<String, Object>
}

@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()
Expand Down Expand Up @@ -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()
Expand All @@ -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"
}
}
}

0 comments on commit f10c6af

Please sign in to comment.