From 34b44422cbe9ccf2e6c1562234e39f85128be2dc Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Tue, 18 Nov 2025 13:34:03 +0200 Subject: [PATCH] Reinstate missing output from `@QuarkusIntegrationTest` Follows up on: #50952 --- .../test/common/DefaultJarLauncher.java | 21 ++++++++++++------- .../common/DefaultNativeImageLauncher.java | 16 ++++++++------ .../io/quarkus/test/common/LauncherUtil.java | 15 +++++++++---- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/test-framework/common/src/main/java/io/quarkus/test/common/DefaultJarLauncher.java b/test-framework/common/src/main/java/io/quarkus/test/common/DefaultJarLauncher.java index 5a582af635992..f5e59d334b5f7 100644 --- a/test-framework/common/src/main/java/io/quarkus/test/common/DefaultJarLauncher.java +++ b/test-framework/common/src/main/java/io/quarkus/test/common/DefaultJarLauncher.java @@ -56,6 +56,7 @@ public class DefaultJarLauncher implements JarArtifactLauncher { private Process quarkusProcess; private boolean isSsl; + private Path logFile; @Override public void init(JarArtifactLauncher.JarInitContext initContext) { @@ -74,9 +75,10 @@ public void start() throws IOException { Function startedFunction = createStartedFunction(); LogRuntimeConfig logRuntimeConfig = ConfigProvider.getConfig().unwrap(SmallRyeConfig.class) .getConfigMapping(LogRuntimeConfig.class); + logFile = logRuntimeConfig.file().path().toPath(); if (startedFunction != null) { IntegrationTestStartedNotifier.Result result = waitForStartedFunction(startedFunction, quarkusProcess, - waitTimeSeconds, logRuntimeConfig.file().path().toPath()); + waitTimeSeconds, logFile); isSsl = result.isSsl(); } else { ListeningAddress result = waitForCapturedListeningData(quarkusProcess, logRuntimeConfig.file().path().toPath(), @@ -107,6 +109,7 @@ public LaunchResult runToCompletion(String[] args) { public void start(String[] programArgs, boolean handleIo) throws IOException { SmallRyeConfig config = ConfigProvider.getConfig().unwrap(SmallRyeConfig.class); LogRuntimeConfig logRuntimeConfig = config.getConfigMapping(LogRuntimeConfig.class); + logFile = logRuntimeConfig.file().path().toPath(); System.setProperty("test.url", TestHTTPResourceManager.getUri()); List args = new ArrayList<>(); @@ -120,12 +123,12 @@ public void start(String[] programArgs, boolean handleIo) throws IOException { if (HTTP_PRESENT) { args.add("-Dquarkus.http.port=" + httpPort); args.add("-Dquarkus.http.ssl-port=" + httpsPort); - // this won't be correct when using the random port but it's really only used by us for the rest client tests + // this won't be correct when using the random port but it's really only used by us for the rest client + // tests // in the main module, since those tests hit the application itself args.add("-Dtest.url=" + TestHTTPResourceManager.getUri()); } - File logPath = logRuntimeConfig.file().path(); - args.add("-Dquarkus.log.file.path=" + logPath.getAbsolutePath()); + args.add("-Dquarkus.log.file.path=" + logFile.toAbsolutePath()); args.add("-Dquarkus.log.file.enabled=true"); args.add("-Dquarkus.log.category.\"io.quarkus\".level=INFO"); if (testProfile != null) { @@ -141,12 +144,12 @@ public void start(String[] programArgs, boolean handleIo) throws IOException { System.out.println("Executing \"" + String.join(" ", args) + "\""); try { - Files.deleteIfExists(logPath.toPath()); - if (logPath.getParent() != null) { - Files.createDirectories(logPath.toPath().getParent()); + Files.deleteIfExists(logFile); + if (logFile.getParent() != null) { + Files.createDirectories(logFile.getParent()); } } catch (FileSystemException e) { - log.warnf("Log file %s deletion failed, could happen on Windows, we can carry on.", logPath); + log.warnf("Log file %s deletion failed, could happen on Windows, we can carry on.", logFile); } if (handleIo) { @@ -189,6 +192,8 @@ public void includeAsSysProps(Map systemProps) { @Override public void close() { + LauncherUtil.toStdOut(logFile); LauncherUtil.destroyProcess(quarkusProcess); } + } diff --git a/test-framework/common/src/main/java/io/quarkus/test/common/DefaultNativeImageLauncher.java b/test-framework/common/src/main/java/io/quarkus/test/common/DefaultNativeImageLauncher.java index b318a35718722..08da6ccd05d11 100644 --- a/test-framework/common/src/main/java/io/quarkus/test/common/DefaultNativeImageLauncher.java +++ b/test-framework/common/src/main/java/io/quarkus/test/common/DefaultNativeImageLauncher.java @@ -11,6 +11,7 @@ import java.net.URLClassLoader; import java.nio.file.FileSystemException; import java.nio.file.Files; +import java.nio.file.Path; import java.security.CodeSource; import java.util.ArrayList; import java.util.Arrays; @@ -48,6 +49,7 @@ public class DefaultNativeImageLauncher implements NativeImageLauncher { private final Map systemProps = new HashMap<>(); private boolean isSsl; + private Path logFile; @Override public void init(NativeImageInitContext initContext) { @@ -105,6 +107,7 @@ public void start() throws IOException { Supplier startedSupplier = createStartedSupplier(); // keep the legacy SPI handling LogRuntimeConfig logRuntimeConfig = ConfigProvider.getConfig().unwrap(SmallRyeConfig.class) .getConfigMapping(LogRuntimeConfig.class); + logFile = logRuntimeConfig.file().path().toPath(); Function startedFunction = createStartedFunction(); if (startedSupplier != null) { waitForStartedSupplier(startedSupplier, quarkusProcess, waitTimeSeconds); @@ -140,8 +143,8 @@ public void start(String[] programArgs, boolean handleIo) throws IOException { // in the main module, since those tests hit the application itself args.add("-Dtest.url=" + TestHTTPResourceManager.getUri()); } - File logPath = logRuntimeConfig.file().path(); - args.add("-Dquarkus.log.file.path=" + logPath.getAbsolutePath()); + logFile = logRuntimeConfig.file().path().toPath(); + args.add("-Dquarkus.log.file.path=" + logFile.toAbsolutePath()); args.add("-Dquarkus.log.file.enabled=true"); args.add("-Dquarkus.log.category.\"io.quarkus\".level=INFO"); if (testProfile != null) { @@ -154,12 +157,12 @@ public void start(String[] programArgs, boolean handleIo) throws IOException { System.out.println("Executing \"" + String.join(" ", args) + "\""); try { - Files.deleteIfExists(logPath.toPath()); - if (logPath.getParent() != null) { - Files.createDirectories(logPath.toPath().getParent()); + Files.deleteIfExists(logFile); + if (logFile.getParent() != null) { + Files.createDirectories(logFile.getParent()); } } catch (FileSystemException e) { - log.warnf("Log file %s deletion failed, could happen on Windows, we can carry on.", logPath); + log.warnf("Log file %s deletion failed, could happen on Windows, we can carry on.", logFile); } if (handleIo) { @@ -294,6 +297,7 @@ public void includeAsSysProps(Map systemProps) { @Override public void close() { + LauncherUtil.toStdOut(logFile); LauncherUtil.destroyProcess(quarkusProcess); } } diff --git a/test-framework/common/src/main/java/io/quarkus/test/common/LauncherUtil.java b/test-framework/common/src/main/java/io/quarkus/test/common/LauncherUtil.java index 5860b422ad555..68067456adab6 100644 --- a/test-framework/common/src/main/java/io/quarkus/test/common/LauncherUtil.java +++ b/test-framework/common/src/main/java/io/quarkus/test/common/LauncherUtil.java @@ -50,10 +50,7 @@ static Process launchProcessAndDrainIO(List args, Map en .redirectError(ProcessBuilder.Redirect.DISCARD) .redirectInput(ProcessBuilder.Redirect.INHERIT); pb.environment().putAll(env); - Process process = pb.start(); - // new Thread(new ProcessReader(process.getInputStream())).start(); - // new Thread(new ProcessReader(process.getErrorStream())).start(); - return process; + return pb.start(); } /** @@ -224,6 +221,16 @@ static void updateConfigForPort(Integer effectivePort) { } } + static void toStdOut(Path log) { + if (log != null) { + try (var r = Files.newBufferedReader(log, StandardCharsets.UTF_8)) { + r.lines().forEach(System.out::println); + } catch (IOException ignored) { + System.err.println("Unable to write process output"); + } + } + } + /** * Thread that reads a process output file looking for the line that indicates the address the application * is listening on.