From 11a6ed3528aad82c8352b2074e842472f51d1cc7 Mon Sep 17 00:00:00 2001 From: Tamas Cservenak Date: Thu, 17 Oct 2024 14:07:05 +0200 Subject: [PATCH] mvnd IT: increase connectTimeout for ITs (#1171) Experiment PR to figure out why MacOS GH runners keep failing with transport related (SSL handshake abort, HTTP timeouts) errors. As we know linux and windows boxes are in Azure, while macos boxes are somewhere else, and we get regularly real strange errors like "SSL handshake errors", "HTTP timeout error (against Central?)", so suspicion is on JDK transport (in HTTP/2 mode). Experiments: * force apache transport (HTTP/1.1) - :heavy_check_mark: * force JDK transport into HTTP/1.1 - :red_square: * use big timeout for connectTimeout - :heavy_check_mark: Conclusion: for ITs we will for now increase the default (10sec) `connectTimeout` Resolver configuration, as it seems too low. --- .../org/mvndaemon/mvnd/junit/JvmTestClient.java | 4 +++- .../mvndaemon/mvnd/junit/NativeTestClient.java | 5 ++++- .../java/org/mvndaemon/mvnd/junit/TestUtils.java | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/integration-tests/src/test/java/org/mvndaemon/mvnd/junit/JvmTestClient.java b/integration-tests/src/test/java/org/mvndaemon/mvnd/junit/JvmTestClient.java index 144ab702..56f523fd 100644 --- a/integration-tests/src/test/java/org/mvndaemon/mvnd/junit/JvmTestClient.java +++ b/integration-tests/src/test/java/org/mvndaemon/mvnd/junit/JvmTestClient.java @@ -30,6 +30,8 @@ import org.mvndaemon.mvnd.client.ExecutionResult; import org.mvndaemon.mvnd.common.Environment; import org.mvndaemon.mvnd.common.logging.ClientOutput; +import static org.mvndaemon.mvnd.junit.TestUtils.augmentArgs; + public class JvmTestClient extends DefaultClient { private final DaemonParameters parameters; @@ -47,7 +49,7 @@ public class JvmTestClient extends DefaultClient { if (parameters instanceof TestParameters && ((TestParameters) parameters).isNoTransferProgress()) { argv.add("-ntp"); } - final ExecutionResult delegate = super.execute(output, argv); + final ExecutionResult delegate = super.execute(output, augmentArgs(argv)); if (output instanceof TestClientOutput) { return new JvmTestResult(delegate, ((TestClientOutput) output).messagesToString()); } diff --git a/integration-tests/src/test/java/org/mvndaemon/mvnd/junit/NativeTestClient.java b/integration-tests/src/test/java/org/mvndaemon/mvnd/junit/NativeTestClient.java index 6325282e..7391b6e9 100644 --- a/integration-tests/src/test/java/org/mvndaemon/mvnd/junit/NativeTestClient.java +++ b/integration-tests/src/test/java/org/mvndaemon/mvnd/junit/NativeTestClient.java @@ -35,6 +35,8 @@ import org.mvndaemon.mvnd.common.Message; import org.mvndaemon.mvnd.common.OsUtils.CommandProcess; import org.mvndaemon.mvnd.common.logging.ClientOutput; +import static org.mvndaemon.mvnd.junit.TestUtils.augmentArgs; + /** * A wrapper around the native executable. */ @@ -66,7 +68,8 @@ public class NativeTestClient implements Client { public ExecutionResult execute(ClientOutput output, List args) throws InterruptedException { final List cmd = new ArrayList<>(args.size() + 6); cmd.add(mvndNativeExecutablePath.toString()); - cmd.addAll(args); + cmd.addAll(augmentArgs(args)); + add(Environment.MVND_DAEMON_STORAGE, cmd, parameters::daemonStorage); add(Environment.MAVEN_REPO_LOCAL, cmd, parameters::mavenRepoLocal); add(Environment.MAVEN_SETTINGS, cmd, parameters::settings); diff --git a/integration-tests/src/test/java/org/mvndaemon/mvnd/junit/TestUtils.java b/integration-tests/src/test/java/org/mvndaemon/mvnd/junit/TestUtils.java index 3004684b..7808d41e 100644 --- a/integration-tests/src/test/java/org/mvndaemon/mvnd/junit/TestUtils.java +++ b/integration-tests/src/test/java/org/mvndaemon/mvnd/junit/TestUtils.java @@ -21,10 +21,25 @@ package org.mvndaemon.mvnd.junit; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.ArrayList; import java.util.Comparator; +import java.util.List; import java.util.stream.Stream; public class TestUtils { + /** + * IT circumvention for JDK transport low timeouts and GH macOS runners networking issues. + * If arguments does not contain settings for timeouts (ie as part of test), they will be + * added to increase timeouts for IT runs. + */ + public static List augmentArgs(List args) { + ArrayList result = new ArrayList<>(args); + if (result.stream().noneMatch(s -> s.contains("aether.transport.http.connectTimeout"))) { + result.add("-Daether.transport.http.connectTimeout=1800000"); + } + // note: def value for requestTimeout=1800000; not setting it as it is fine + return result; + } public static void replace(Path path, String find, String replacement) { try {