From bdbee6a1584cecf587bbb976079f736f64125907 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Thu, 21 Nov 2024 12:38:35 +0100 Subject: [PATCH] 1h timeout on REST-call if running in debugger --- .../hsadminng/hs/office/scenarios/UseCase.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java index 23244d64..27e38e13 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/office/scenarios/UseCase.java @@ -36,6 +36,7 @@ import java.util.function.Supplier; import static java.net.URLEncoder.encode; import static net.hostsharing.hsadminng.hs.office.scenarios.TemplateResolver.Resolver.DROP_COMMENTS; import static net.hostsharing.hsadminng.hs.office.scenarios.TemplateResolver.Resolver.KEEP_COMMENTS; +import static net.hostsharing.hsadminng.test.DebuggerDetection.isDebuggerAttached; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.fail; import static org.junit.platform.commons.util.StringUtils.isBlank; @@ -151,7 +152,7 @@ public abstract class UseCase> { .GET() .uri(new URI("http://localhost:" + testSuite.port + uriPath)) .header("current-subject", ScenarioTest.RUN_AS_USER) - .timeout(Duration.ofSeconds(10)) + .timeout(seconds(10)) .build(); final var response = client.send(request, BodyHandlers.ofString()); return new HttpResponse(HttpMethod.GET, uriPath, null, response); @@ -166,7 +167,7 @@ public abstract class UseCase> { .uri(new URI("http://localhost:" + testSuite.port + uriPath)) .header("Content-Type", "application/json") .header("current-subject", ScenarioTest.RUN_AS_USER) - .timeout(Duration.ofSeconds(10)) + .timeout(seconds(10)) .build(); final var response = client.send(request, BodyHandlers.ofString()); return new HttpResponse(HttpMethod.POST, uriPath, requestBody, response); @@ -181,7 +182,7 @@ public abstract class UseCase> { .uri(new URI("http://localhost:" + testSuite.port + uriPath)) .header("Content-Type", "application/json") .header("current-subject", ScenarioTest.RUN_AS_USER) - .timeout(Duration.ofSeconds(10)) + .timeout(seconds(10)) .build(); final var response = client.send(request, BodyHandlers.ofString()); return new HttpResponse(HttpMethod.PATCH, uriPath, requestBody, response); @@ -195,7 +196,7 @@ public abstract class UseCase> { .uri(new URI("http://localhost:" + testSuite.port + uriPath)) .header("Content-Type", "application/json") .header("current-subject", ScenarioTest.RUN_AS_USER) - .timeout(Duration.ofSeconds(10)) + .timeout(seconds(10)) .build(); final var response = client.send(request, BodyHandlers.ofString()); return new HttpResponse(HttpMethod.DELETE, uriPath, null, response); @@ -237,6 +238,10 @@ public abstract class UseCase> { } } + private static Duration seconds(final int secondsIfNoDebuggerAttached) { + return isDebuggerAttached() ? Duration.ofHours(1) : Duration.ofSeconds(secondsIfNoDebuggerAttached); + } + public final class HttpResponse { @Getter