This is an automated email from the ASF dual-hosted git repository. tballison pushed a commit to branch improve-flaky-tests in repository https://gitbox.apache.org/repos/asf/tika.git
commit 67e5d03b9f7f4c3690f97b9055c95160819038c6 Author: tallison <[email protected]> AuthorDate: Wed Jul 15 07:22:16 2026 -0400 improve flaky tests --- .../pipes/elasticsearch/tests/ElasticsearchTest.java | 19 +++++++++++-------- .../tika/pipes/opensearch/tests/OpenSearchTest.java | 20 ++++++++++++-------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/tika-integration-tests/tika-pipes-es-integration-tests/src/test/java/org/apache/tika/pipes/elasticsearch/tests/ElasticsearchTest.java b/tika-integration-tests/tika-pipes-es-integration-tests/src/test/java/org/apache/tika/pipes/elasticsearch/tests/ElasticsearchTest.java index 7d43ce71ee..571cbaf9a0 100644 --- a/tika-integration-tests/tika-pipes-es-integration-tests/src/test/java/org/apache/tika/pipes/elasticsearch/tests/ElasticsearchTest.java +++ b/tika-integration-tests/tika-pipes-es-integration-tests/src/test/java/org/apache/tika/pipes/elasticsearch/tests/ElasticsearchTest.java @@ -178,18 +178,21 @@ public class ElasticsearchTest { assertEquals(1, (int) statusCounts.get("EMIT_SUCCESS"), "should have had 1 emit success: " + statusCounts); assertEquals(2, numberOfCrashes(statusCounts), - "should have had 2 OOM or 1 OOM and 1 timeout: " + statusCounts); + "should have had 2 forked-process crashes (OOM/TIMEOUT/UNSPECIFIED_CRASH): " + + statusCounts); } private int numberOfCrashes(Map<String, Integer> statusCounts) { - Integer oom = statusCounts.get("OOM"); - Integer timeout = statusCounts.get("TIMEOUT"); + // oom.xml (a real heap exhaustion) and fake_oom.xml both crash the fork; how a genuine OOM + // surfaces -- OOM vs UNSPECIFIED_CRASH vs TIMEOUT -- is nondeterministic under load, but all + // three are PipesResult PROCESS_CRASH statuses. Count the whole category so the assertion is + // deterministic and doesn't flake on the exact sub-classification. int sum = 0; - if (oom != null) { - sum += oom; - } - if (timeout != null) { - sum += timeout; + for (String crashStatus : new String[]{"OOM", "TIMEOUT", "UNSPECIFIED_CRASH"}) { + Integer cnt = statusCounts.get(crashStatus); + if (cnt != null) { + sum += cnt; + } } return sum; } diff --git a/tika-integration-tests/tika-pipes-opensearch-integration-tests/src/test/java/org/apache/tika/pipes/opensearch/tests/OpenSearchTest.java b/tika-integration-tests/tika-pipes-opensearch-integration-tests/src/test/java/org/apache/tika/pipes/opensearch/tests/OpenSearchTest.java index 1e33c22383..745654fc76 100644 --- a/tika-integration-tests/tika-pipes-opensearch-integration-tests/src/test/java/org/apache/tika/pipes/opensearch/tests/OpenSearchTest.java +++ b/tika-integration-tests/tika-pipes-opensearch-integration-tests/src/test/java/org/apache/tika/pipes/opensearch/tests/OpenSearchTest.java @@ -155,19 +155,23 @@ public class OpenSearchTest { assertEquals(1, (int) statusCounts.get("PARSE_SUCCESS_WITH_EXCEPTION"), "should have had 1 parse exception: " + statusCounts); //the embedded docx is emitted directly assertEquals(1, (int) statusCounts.get("EMIT_SUCCESS"), "should have had 1 emit success: " + statusCounts); - assertEquals(2, numberOfCrashes(statusCounts), "should have had 2 OOM or 1 OOM and 1 timeout: " + statusCounts); + assertEquals(2, numberOfCrashes(statusCounts), + "should have had 2 forked-process crashes (OOM/TIMEOUT/UNSPECIFIED_CRASH): " + + statusCounts); } private int numberOfCrashes(Map<String, Integer> statusCounts) { - Integer oom = statusCounts.get("OOM"); - Integer timeout = statusCounts.get("TIMEOUT"); + // oom.xml (a real heap exhaustion) and fake_oom.xml both crash the fork; how a genuine OOM + // surfaces -- OOM vs UNSPECIFIED_CRASH vs TIMEOUT -- is nondeterministic under load, but all + // three are PipesResult PROCESS_CRASH statuses. Count the whole category so the assertion is + // deterministic and doesn't flake on the exact sub-classification. int sum = 0; - if (oom != null) { - sum += oom; - } - if (timeout != null) { - sum += timeout; + for (String crashStatus : new String[]{"OOM", "TIMEOUT", "UNSPECIFIED_CRASH"}) { + Integer cnt = statusCounts.get(crashStatus); + if (cnt != null) { + sum += cnt; + } } return sum; }
