Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -74,9 +75,10 @@ public void start() throws IOException {
Function<IntegrationTestStartedNotifier.Context, IntegrationTestStartedNotifier.Result> 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(),
Expand Down Expand Up @@ -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<String> args = new ArrayList<>();
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -189,6 +192,8 @@ public void includeAsSysProps(Map<String, String> systemProps) {

@Override
public void close() {
LauncherUtil.toStdOut(logFile);
LauncherUtil.destroyProcess(quarkusProcess);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -48,6 +49,7 @@ public class DefaultNativeImageLauncher implements NativeImageLauncher {
private final Map<String, String> systemProps = new HashMap<>();

private boolean isSsl;
private Path logFile;

@Override
public void init(NativeImageInitContext initContext) {
Expand Down Expand Up @@ -105,6 +107,7 @@ public void start() throws IOException {
Supplier<Boolean> startedSupplier = createStartedSupplier(); // keep the legacy SPI handling
LogRuntimeConfig logRuntimeConfig = ConfigProvider.getConfig().unwrap(SmallRyeConfig.class)
.getConfigMapping(LogRuntimeConfig.class);
logFile = logRuntimeConfig.file().path().toPath();
Function<IntegrationTestStartedNotifier.Context, IntegrationTestStartedNotifier.Result> startedFunction = createStartedFunction();
if (startedSupplier != null) {
waitForStartedSupplier(startedSupplier, quarkusProcess, waitTimeSeconds);
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -294,6 +297,7 @@ public void includeAsSysProps(Map<String, String> systemProps) {

@Override
public void close() {
LauncherUtil.toStdOut(logFile);
LauncherUtil.destroyProcess(quarkusProcess);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ static Process launchProcessAndDrainIO(List<String> args, Map<String, String> 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();
}

/**
Expand Down Expand Up @@ -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.
Expand Down
Loading