Skip to content

Commit

Permalink
Merge pull request #20996 from stuartwdouglas/20866
Browse files Browse the repository at this point in the history
Compress startup messages with docker
  • Loading branch information
gsmet authored Oct 26, 2021
2 parents e6275f1 + ffa1151 commit eaef724
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ private TestContainersStrategy(boolean silent) {

@Override
public Result get() {
StartupLogCompressor compressor = new StartupLogCompressor("Checking Docker Environment", Optional.empty(), null);
//testcontainers uses the Unreliables library to test if docker is started
//this runs in threads that start with 'ducttape'
StartupLogCompressor compressor = new StartupLogCompressor("Checking Docker Environment", Optional.empty(), null,
(s) -> s.getName().startsWith("ducttape"));
try {
Class<?> dockerClientFactoryClass = Thread.currentThread().getContextClassLoader()
.loadClass("org.testcontainers.DockerClientFactory");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.Optional;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiPredicate;
import java.util.function.Predicate;

import io.quarkus.deployment.dev.testing.MessageFormat;
import io.quarkus.deployment.logging.LoggingSetupBuildItem;
Expand All @@ -24,10 +25,19 @@ public class StartupLogCompressor implements Closeable, BiPredicate<String, Bool
final StatusLine sl;
final List<String> toDump = new ArrayList<>();
final AtomicInteger COUNTER = new AtomicInteger();
final Predicate<Thread> additionalThreadPredicate;

public StartupLogCompressor(String name,
@SuppressWarnings("unused") Optional<ConsoleInstalledBuildItem> consoleInstalledBuildItem,
@SuppressWarnings("unused") LoggingSetupBuildItem loggingSetupBuildItem) {
this(name, consoleInstalledBuildItem, loggingSetupBuildItem, (s) -> false);
}

public StartupLogCompressor(String name,
@SuppressWarnings("unused") Optional<ConsoleInstalledBuildItem> consoleInstalledBuildItem,
@SuppressWarnings("unused") LoggingSetupBuildItem loggingSetupBuildItem,
Predicate<Thread> additionalThreadPredicate) {
this.additionalThreadPredicate = additionalThreadPredicate;
if (QuarkusConsole.INSTANCE.isAnsiSupported()) {
QuarkusConsole.installRedirects();
this.name = name;
Expand Down Expand Up @@ -68,7 +78,8 @@ public boolean test(String s, Boolean errorStream) {
//not installed
return true;
}
if (Thread.currentThread() == thread) {
Thread current = Thread.currentThread();
if (current == this.thread || additionalThreadPredicate.test(current)) {
toDump.add(s);
sl.setMessage(MessageFormat.BLUE + name + MessageFormat.RESET + " " + s.replace("\n", ""));
return false;
Expand Down

0 comments on commit eaef724

Please sign in to comment.