Sometimes we need to run a test that produces a lot of output in its logs. AFAICT we send the log output to disk in case we need to read it back later on, but it seems that our Gradle setup also ends up trying to hold onto these logs (or something else which scales with log volume) in memory too. With copious enough logs, this causes the test runner to fail with an OutOfMemoryError. For instance this test tries to produce a few GiB of logs:
diff --git a/server/src/test/java/org/elasticsearch/common/logging/ExcessiveLoggingTests.java b/server/src/test/java/org/elasticsearch/common/logging/ExcessiveLoggingTests.java
new file mode 100644
index 00000000000..df5c3982b6f
--- /dev/null
+++ b/server/src/test/java/org/elasticsearch/common/logging/ExcessiveLoggingTests.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
+ * Side Public License, v 1.
+ */
+
+package org.elasticsearch.common.logging;
+
+import org.elasticsearch.test.ESTestCase;
+
+public class ExcessiveLoggingTests extends ESTestCase {
+ public void testExcessiveLogging() {
+ for (int i = 0; i < 5000 * 1024; i++) {
+ logger.info("message [{}]: {}", i, randomAlphaOfLength(1024));
+ }
+ logger.info("done");
+ fail("boom");
+ }
+}
Unsure if this is an Elasticsearch build issue or something wrong in Gradle itself so I'm starting here.
Sometimes we need to run a test that produces a lot of output in its logs. AFAICT we send the log output to disk in case we need to read it back later on, but it seems that our Gradle setup also ends up trying to hold onto these logs (or something else which scales with log volume) in memory too. With copious enough logs, this causes the test runner to fail with an
OutOfMemoryError
. For instance this test tries to produce a few GiB of logs:Unsure if this is an Elasticsearch build issue or something wrong in Gradle itself so I'm starting here.