Skip to content

Commit 06d5baa

Browse files
authored
Add more GraalThread filtering in tests (#87571)
1 parent 9682443 commit 06d5baa

File tree

14 files changed

+59
-6
lines changed

14 files changed

+59
-6
lines changed

client/test/src/main/java/org/elasticsearch/client/GraalVMThreadsFilter.java renamed to client/test/src/main/java/org/elasticsearch/client/ClientsGraalVMThreadsFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* The GraalVM spawns extra threads, which causes our thread leak
2626
* detection to fail. Filter these threads out since we can't clean them up.
2727
*/
28-
public class GraalVMThreadsFilter implements ThreadFilter {
28+
public class ClientsGraalVMThreadsFilter implements ThreadFilter {
2929
@Override
3030
public boolean reject(Thread t) {
3131
return t.getName().startsWith("Libgraal");

client/test/src/main/java/org/elasticsearch/client/RestClientTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
@ThreadLeakAction({ ThreadLeakAction.Action.WARN, ThreadLeakAction.Action.INTERRUPT })
5353
@ThreadLeakZombies(ThreadLeakZombies.Consequence.IGNORE_REMAINING_TESTS)
5454
@ThreadLeakLingering(linger = 5000) // 5 sec lingering
55-
@ThreadLeakFilters(filters = { GraalVMThreadsFilter.class })
55+
@ThreadLeakFilters(filters = { ClientsGraalVMThreadsFilter.class })
5656
@TimeoutSuite(millis = 2 * 60 * 60 * 1000)
5757
public abstract class RestClientTestCase extends RandomizedTest {
5858

plugins/analysis-icu/src/test/java/org/elasticsearch/plugin/analysis/icu/IndexableBinaryStringToolsTests.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
package org.elasticsearch.plugin.analysis.icu;
1919

2020
import com.carrotsearch.randomizedtesting.annotations.Listeners;
21+
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
2122
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;
2223
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;
2324
import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
2425

2526
import org.apache.lucene.tests.util.LuceneTestCase;
2627
import org.apache.lucene.tests.util.TimeUnits;
2728
import org.apache.lucene.util.ArrayUtil;
29+
import org.elasticsearch.test.GraalVMThreadsFilter;
2830
import org.elasticsearch.test.junit.listeners.ReproduceInfoPrinter;
2931
import org.junit.BeforeClass;
3032

@@ -35,6 +37,7 @@
3537
*/
3638
@Deprecated
3739
@Listeners({ ReproduceInfoPrinter.class })
40+
@ThreadLeakFilters(filters = { GraalVMThreadsFilter.class })
3841
@ThreadLeakScope(Scope.NONE)
3942
@TimeoutSuite(millis = TimeUnits.HOUR)
4043
@LuceneTestCase.SuppressSysoutChecks(bugUrl = "we log a lot on purpose")

qa/no-bootstrap-tests/src/test/java/org/elasticsearch/bootstrap/SpawnerNoBootstrapTests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
package org.elasticsearch.bootstrap;
1010

11+
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
12+
1113
import org.apache.logging.log4j.Level;
1214
import org.apache.logging.log4j.LogManager;
1315
import org.apache.logging.log4j.Logger;
@@ -22,6 +24,7 @@
2224
import org.elasticsearch.env.TestEnvironment;
2325
import org.elasticsearch.plugins.Platforms;
2426
import org.elasticsearch.plugins.PluginTestUtil;
27+
import org.elasticsearch.test.GraalVMThreadsFilter;
2528
import org.elasticsearch.test.MockLogAppender;
2629

2730
import java.io.IOException;
@@ -52,6 +55,7 @@
5255
* that prevents the Spawner class from doing its job. Also needs to run in a separate JVM to other
5356
* tests that extend ESTestCase for the same reason.
5457
*/
58+
@ThreadLeakFilters(filters = { GraalVMThreadsFilter.class })
5559
public class SpawnerNoBootstrapTests extends LuceneTestCase {
5660

5761
private static final String CONTROLLER_SOURCE = """

server/src/test/java/org/elasticsearch/bootstrap/NoSecurityManagerTests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@
88

99
package org.elasticsearch.bootstrap;
1010

11+
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
12+
1113
import org.apache.lucene.tests.util.LuceneTestCase;
14+
import org.elasticsearch.test.GraalVMThreadsFilter;
1215

1316
import static org.hamcrest.Matchers.is;
1417

18+
@ThreadLeakFilters(filters = { GraalVMThreadsFilter.class })
1519
public class NoSecurityManagerTests extends LuceneTestCase {
1620

1721
public void testPrepopulateSecurityCaller() {

server/src/test/java/org/elasticsearch/lucene/index/LazySoftDeletesDirectoryReaderWrapperTests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
package org.elasticsearch.lucene.index;
1010

11+
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
12+
1113
import org.apache.lucene.document.Document;
1214
import org.apache.lucene.document.Field;
1315
import org.apache.lucene.document.NumericDocValuesField;
@@ -26,12 +28,14 @@
2628
import org.apache.lucene.tests.util.LuceneTestCase;
2729
import org.elasticsearch.core.IOUtils;
2830
import org.elasticsearch.index.engine.LazySoftDeletesDirectoryReaderWrapper;
31+
import org.elasticsearch.test.GraalVMThreadsFilter;
2932

3033
import java.io.IOException;
3134
import java.util.HashSet;
3235
import java.util.Set;
3336
import java.util.concurrent.atomic.AtomicInteger;
3437

38+
@ThreadLeakFilters(filters = { GraalVMThreadsFilter.class })
3539
public class LazySoftDeletesDirectoryReaderWrapperTests extends LuceneTestCase {
3640

3741
public void testDropFullyDeletedSegments() throws IOException {

test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import com.carrotsearch.randomizedtesting.RandomizedTest;
1111
import com.carrotsearch.randomizedtesting.annotations.Listeners;
12+
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
1213
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;
1314
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;
1415
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;
@@ -170,6 +171,7 @@
170171
@ThreadLeakScope(Scope.SUITE)
171172
@ThreadLeakLingering(linger = 5000) // 5 sec lingering
172173
@TimeoutSuite(millis = 20 * TimeUnits.MINUTE)
174+
@ThreadLeakFilters(filters = { GraalVMThreadsFilter.class })
173175
@LuceneTestCase.SuppressSysoutChecks(bugUrl = "we log a lot on purpose")
174176
// we suppress pretty much all the lucene codecs for now, except asserting
175177
// assertingcodec is the winner for a codec here: it finds bugs and gives clear exceptions.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
package org.elasticsearch.test;
10+
11+
import com.carrotsearch.randomizedtesting.ThreadFilter;
12+
13+
/**
14+
* The GraalVM spawns extra threads, which causes our thread leak
15+
* detection to fail. Filter these threads out since we can't clean them up.
16+
*/
17+
public class GraalVMThreadsFilter implements ThreadFilter {
18+
@Override
19+
public boolean reject(Thread t) {
20+
return t.getName().startsWith("Libgraal");
21+
}
22+
}

x-pack/plugin/ml/qa/no-bootstrap-tests/src/test/java/org/elasticsearch/xpack/ml/utils/NamedPipeHelperNoBootstrapTests.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
package org.elasticsearch.xpack.ml.utils;
88

9+
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
910
import com.sun.jna.IntegerType;
1011
import com.sun.jna.Native;
1112
import com.sun.jna.Pointer;
@@ -19,6 +20,7 @@
1920
import org.elasticsearch.env.Environment;
2021
import org.elasticsearch.env.TestEnvironment;
2122
import org.elasticsearch.monitor.jvm.JvmInfo;
23+
import org.elasticsearch.test.GraalVMThreadsFilter;
2224

2325
import java.io.BufferedReader;
2426
import java.io.IOException;
@@ -40,6 +42,7 @@
4042
* The way that pipes are managed in this class, e.g. using the mkfifo shell command, is
4143
* not suitable for production, but adequate for this test.
4244
*/
45+
@ThreadLeakFilters(filters = { GraalVMThreadsFilter.class })
4346
public class NamedPipeHelperNoBootstrapTests extends LuceneTestCase {
4447

4548
private static final NamedPipeHelper NAMED_PIPE_HELPER = new NamedPipeHelper();

x-pack/plugin/old-lucene-versions/src/test/java/org/elasticsearch/xpack/lucene/bwc/codecs/lucene50/BlockPostingsFormat2Tests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232
import org.apache.lucene.store.Directory;
3333
import org.apache.lucene.tests.analysis.MockAnalyzer;
3434
import org.apache.lucene.tests.index.RandomIndexWriter;
35-
import org.apache.lucene.tests.util.LuceneTestCase;
3635
import org.apache.lucene.tests.util.TestUtil;
36+
import org.elasticsearch.test.ESTestCase;
3737

3838
/** Tests special cases of BlockPostingsFormat */
39-
public class BlockPostingsFormat2Tests extends LuceneTestCase {
39+
public class BlockPostingsFormat2Tests extends ESTestCase {
4040
Directory dir;
4141
RandomIndexWriter iw;
4242

0 commit comments

Comments
 (0)