diff --git a/presto-product-tests-launcher/pom.xml b/presto-product-tests-launcher/pom.xml
index 662da057d399..5385ee040eee 100644
--- a/presto-product-tests-launcher/pom.xml
+++ b/presto-product-tests-launcher/pom.xml
@@ -32,6 +32,16 @@
units
+
+ com.fasterxml.jackson.core
+ jackson-core
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+
+
com.google.code.findbugs
jsr305
diff --git a/presto-product-tests-launcher/src/main/java/io/prestosql/tests/product/launcher/cli/EnvironmentUp.java b/presto-product-tests-launcher/src/main/java/io/prestosql/tests/product/launcher/cli/EnvironmentUp.java
index d39651c121a6..c3a1bb64980c 100644
--- a/presto-product-tests-launcher/src/main/java/io/prestosql/tests/product/launcher/cli/EnvironmentUp.java
+++ b/presto-product-tests-launcher/src/main/java/io/prestosql/tests/product/launcher/cli/EnvironmentUp.java
@@ -43,6 +43,7 @@
import static io.prestosql.tests.product.launcher.env.EnvironmentListener.compose;
import static io.prestosql.tests.product.launcher.env.EnvironmentListener.logCopyingListener;
import static io.prestosql.tests.product.launcher.env.EnvironmentListener.loggingListener;
+import static io.prestosql.tests.product.launcher.env.EnvironmentListener.statsPrintingListener;
import static java.util.Objects.requireNonNull;
import static picocli.CommandLine.Mixin;
import static picocli.CommandLine.Option;
@@ -144,7 +145,11 @@ public void run()
}
Optional environmentLogPath = logsDirBase.map(dir -> dir.resolve(environment));
- Environment environment = builder.build(compose(loggingListener(), logCopyingListener(environmentLogPath)));
+ Environment environment = builder.build(compose(
+ loggingListener(),
+ logCopyingListener(environmentLogPath),
+ statsPrintingListener()));
+
environment.start();
if (background) {
diff --git a/presto-product-tests-launcher/src/main/java/io/prestosql/tests/product/launcher/cli/TestRun.java b/presto-product-tests-launcher/src/main/java/io/prestosql/tests/product/launcher/cli/TestRun.java
index d2ce0228fa7a..f59aeeb01d7e 100644
--- a/presto-product-tests-launcher/src/main/java/io/prestosql/tests/product/launcher/cli/TestRun.java
+++ b/presto-product-tests-launcher/src/main/java/io/prestosql/tests/product/launcher/cli/TestRun.java
@@ -48,6 +48,7 @@
import static io.prestosql.tests.product.launcher.env.EnvironmentListener.compose;
import static io.prestosql.tests.product.launcher.env.EnvironmentListener.logCopyingListener;
import static io.prestosql.tests.product.launcher.env.EnvironmentListener.loggingListener;
+import static io.prestosql.tests.product.launcher.env.EnvironmentListener.statsPrintingListener;
import static io.prestosql.tests.product.launcher.env.common.Standard.CONTAINER_TEMPTO_PROFILE_CONFIG;
import static java.util.Objects.requireNonNull;
import static org.testcontainers.containers.BindMode.READ_ONLY;
@@ -242,7 +243,10 @@ private Environment getEnvironment()
environmentConfig.extendEnvironment(this.environment).ifPresent(extender -> extender.extendEnvironment(environment));
- return environment.build(compose(loggingListener(), logCopyingListener(logsDirBase)));
+ return environment.build(compose(
+ loggingListener(),
+ logCopyingListener(logsDirBase),
+ statsPrintingListener()));
}
private static Iterable extends String> reportsDirOptions(Path path)
diff --git a/presto-product-tests-launcher/src/main/java/io/prestosql/tests/product/launcher/env/DockerContainer.java b/presto-product-tests-launcher/src/main/java/io/prestosql/tests/product/launcher/env/DockerContainer.java
index 00c70e1da76f..72d960d7c378 100644
--- a/presto-product-tests-launcher/src/main/java/io/prestosql/tests/product/launcher/env/DockerContainer.java
+++ b/presto-product-tests-launcher/src/main/java/io/prestosql/tests/product/launcher/env/DockerContainer.java
@@ -13,11 +13,15 @@
*/
package io.prestosql.tests.product.launcher.env;
+import com.github.dockerjava.api.DockerClient;
import com.github.dockerjava.api.command.InspectContainerResponse;
+import com.github.dockerjava.api.model.Statistics;
+import com.github.dockerjava.core.InvocationBuilder;
import com.google.common.base.Splitter;
import com.google.common.base.Stopwatch;
import com.google.common.io.RecursiveDeleteOption;
import io.airlift.log.Logger;
+import org.testcontainers.DockerClientFactory;
import org.testcontainers.containers.BindMode;
import org.testcontainers.containers.FixedHostPortGenericContainer;
import org.testcontainers.containers.SelinuxContext;
@@ -210,6 +214,18 @@ private Stream listFilesInContainer(String path)
return Stream.empty();
}
+ public Statistics getStats()
+ {
+ try (DockerClient client = DockerClientFactory.lazyClient()) {
+ InvocationBuilder.AsyncResultCallback callback = new InvocationBuilder.AsyncResultCallback<>();
+ client.statsCmd(getContainerId()).exec(callback);
+ return callback.awaitResult();
+ }
+ catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+
@Override
public String toString()
{
diff --git a/presto-product-tests-launcher/src/main/java/io/prestosql/tests/product/launcher/env/EnvironmentListener.java b/presto-product-tests-launcher/src/main/java/io/prestosql/tests/product/launcher/env/EnvironmentListener.java
index 378e422d8f31..767b8a5d7ecf 100644
--- a/presto-product-tests-launcher/src/main/java/io/prestosql/tests/product/launcher/env/EnvironmentListener.java
+++ b/presto-product-tests-launcher/src/main/java/io/prestosql/tests/product/launcher/env/EnvironmentListener.java
@@ -13,6 +13,8 @@
*/
package io.prestosql.tests.product.launcher.env;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.dockerjava.api.command.InspectContainerResponse;
import io.airlift.log.Logger;
@@ -23,6 +25,7 @@
public interface EnvironmentListener
{
Logger log = Logger.get(EnvironmentListener.class);
+ ObjectMapper mapper = new ObjectMapper();
default void environmentStarting(Environment environment)
{
@@ -179,6 +182,23 @@ public void containerStopping(DockerContainer container, InspectContainerRespons
};
}
+ static EnvironmentListener statsPrintingListener()
+ {
+ return new EnvironmentListener()
+ {
+ @Override
+ public void containerStopping(DockerContainer container, InspectContainerResponse response)
+ {
+ try {
+ log.info("Container %s stats: %s", container, mapper.writeValueAsString(container.getStats()));
+ }
+ catch (JsonProcessingException e) {
+ log.warn("Could not display container %s stats: %s", container, e);
+ }
+ }
+ };
+ }
+
static EnvironmentListener noop()
{
return new EnvironmentListener() {};