Apache Lucene open-source search software
SOLR-7289: Tests should not ignore all leaking threads and instead just ignore the known leaking threads.
Mark Robert Miller84adc8604d59
diff --git a/solr/contrib/map-reduce/src/test/org/apache/solr/hadoop/MorphlineBasicMiniMRTest.java b/solr/contrib/map-reduce/src/test/org/apache/solr/hadoop/MorphlineBasicMiniMRTest.javaindex 4250fc1ea19..45be1ece866 100644--- a/solr/contrib/map-reduce/src/test/org/apache/solr/hadoop/MorphlineBasicMiniMRTest.java+++ b/solr/contrib/map-reduce/src/test/org/apache/solr/hadoop/MorphlineBasicMiniMRTest.java@@ -16,13 +16,15 @@*/package org.apache.solr.hadoop;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakAction;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakAction.Action;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies.Consequence;+import java.io.File;+import java.io.IOException;+import java.io.OutputStream;+import java.io.OutputStreamWriter;+import java.io.Writer;+import java.lang.reflect.Array;+import java.nio.charset.StandardCharsets;+import java.util.Arrays;+import org.apache.commons.io.FileUtils;import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.fs.FileSystem;@@ -42,24 +44,17 @@ import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.cloud.AbstractZkTestCase;import org.apache.solr.hadoop.hack.MiniMRCluster;import org.apache.solr.morphlines.solr.AbstractSolrMorphlineTestBase;+import org.apache.solr.util.BadHdfsThreadsFilter;import org.junit.After;import org.junit.AfterClass;import org.junit.BeforeClass;import org.junit.Test;-import java.io.File;-import java.io.IOException;-import java.io.OutputStream;-import java.io.OutputStreamWriter;-import java.io.Writer;-import java.lang.reflect.Array;-import java.nio.charset.StandardCharsets;-import java.util.Arrays;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;-@ThreadLeakAction({Action.WARN})-@ThreadLeakLingering(linger = 0)-@ThreadLeakZombies(Consequence.CONTINUE)-@ThreadLeakScope(Scope.NONE)+@ThreadLeakFilters(defaultFilters = true, filters = {+ BadHdfsThreadsFilter.class // hdfs currently leaks thread(s)+})@Slowpublic class MorphlineBasicMiniMRTest extends SolrTestCaseJ4 {diff --git a/solr/contrib/map-reduce/src/test/org/apache/solr/hadoop/MorphlineGoLiveMiniMRTest.java b/solr/contrib/map-reduce/src/test/org/apache/solr/hadoop/MorphlineGoLiveMiniMRTest.javaindex 5d5190c988b..bf0bad3f916 100644--- a/solr/contrib/map-reduce/src/test/org/apache/solr/hadoop/MorphlineGoLiveMiniMRTest.java+++ b/solr/contrib/map-reduce/src/test/org/apache/solr/hadoop/MorphlineGoLiveMiniMRTest.java@@ -16,13 +16,24 @@*/package org.apache.solr.hadoop;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakAction;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakAction.Action;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies.Consequence;+import java.io.File;+import java.io.IOException;+import java.io.OutputStream;+import java.io.OutputStreamWriter;+import java.io.UnsupportedEncodingException;+import java.io.Writer;+import java.lang.reflect.Array;+import java.net.URI;+import java.nio.charset.StandardCharsets;+import java.util.ArrayList;+import java.util.Arrays;+import java.util.Collection;+import java.util.HashSet;+import java.util.List;+import java.util.Map;+import java.util.Properties;+import java.util.Set;+import org.apache.commons.io.FileUtils;import org.apache.hadoop.fs.FileSystem;import org.apache.hadoop.fs.Path;@@ -61,32 +72,24 @@ import org.apache.solr.common.util.NamedList;import org.apache.solr.hadoop.hack.MiniMRClientCluster;import org.apache.solr.hadoop.hack.MiniMRClientClusterFactory;import org.apache.solr.morphlines.solr.AbstractSolrMorphlineTestBase;+import org.apache.solr.util.BadHdfsThreadsFilter;import org.junit.AfterClass;import org.junit.BeforeClass;import org.junit.Test;-import java.io.File;-import java.io.IOException;-import java.io.OutputStream;-import java.io.OutputStreamWriter;-import java.io.UnsupportedEncodingException;-import java.io.Writer;-import java.lang.reflect.Array;-import java.net.URI;-import java.nio.charset.StandardCharsets;-import java.util.ArrayList;-import java.util.Arrays;-import java.util.Collection;-import java.util.HashSet;-import java.util.List;-import java.util.Map;-import java.util.Properties;-import java.util.Set;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakAction;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakAction.Action;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies.Consequence;@ThreadLeakAction({Action.WARN})@ThreadLeakLingering(linger = 0)@ThreadLeakZombies(Consequence.CONTINUE)-@ThreadLeakScope(Scope.NONE)+@ThreadLeakFilters(defaultFilters = true, filters = {+ BadHdfsThreadsFilter.class // hdfs currently leaks thread(s)+})@SuppressSSL // SSL does not work with this test for currently unknown reasons@Slowpublic class MorphlineGoLiveMiniMRTest extends AbstractFullDistribZkTestBase {diff --git a/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/SolrMorphlineZkAliasTest.java b/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/SolrMorphlineZkAliasTest.javaindex a9ba3a93f2f..a654e94de27 100644--- a/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/SolrMorphlineZkAliasTest.java+++ b/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/SolrMorphlineZkAliasTest.java@@ -16,13 +16,10 @@*/package org.apache.solr.morphlines.solr;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakAction;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakAction.Action;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies.Consequence;+import java.io.File;+import java.io.IOException;+import java.util.Iterator;+import org.apache.lucene.util.LuceneTestCase.Slow;import org.apache.solr.client.solrj.SolrQuery;import org.apache.solr.client.solrj.SolrServerException;@@ -32,20 +29,17 @@ import org.apache.solr.common.SolrDocument;import org.apache.solr.common.params.CollectionParams.CollectionAction;import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.util.NamedList;-import org.junit.BeforeClass;+import org.apache.solr.util.BadHdfsThreadsFilter;import org.junit.Test;import org.kitesdk.morphline.api.Record;import org.kitesdk.morphline.base.Fields;import org.kitesdk.morphline.base.Notifications;-import java.io.File;-import java.io.IOException;-import java.util.Iterator;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;-@ThreadLeakAction({Action.WARN})-@ThreadLeakLingering(linger = 0)-@ThreadLeakZombies(Consequence.CONTINUE)-@ThreadLeakScope(Scope.NONE)+@ThreadLeakFilters(defaultFilters = true, filters = {+ BadHdfsThreadsFilter.class // hdfs currently leaks thread(s)+})@Slowpublic class SolrMorphlineZkAliasTest extends AbstractSolrMorphlineZkTestBase {diff --git a/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/SolrMorphlineZkAvroTest.java b/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/SolrMorphlineZkAvroTest.javaindex 7fe175989ec..0eb9e400469 100644--- a/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/SolrMorphlineZkAvroTest.java+++ b/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/SolrMorphlineZkAvroTest.java@@ -16,16 +16,13 @@*/package org.apache.solr.morphlines.solr;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakAction;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakAction.Action;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies.Consequence;-import com.google.common.base.Joiner;-import com.google.common.base.Preconditions;-import com.google.common.io.Files;+import java.io.File;+import java.util.ArrayList;+import java.util.Collections;+import java.util.Comparator;+import java.util.Iterator;+import java.util.List;+import org.apache.avro.Schema.Field;import org.apache.avro.file.DataFileReader;import org.apache.avro.file.FileReader;@@ -35,23 +32,25 @@ import org.apache.lucene.util.LuceneTestCase.Slow;import org.apache.solr.client.solrj.SolrQuery;import org.apache.solr.client.solrj.response.QueryResponse;import org.apache.solr.common.SolrDocument;-import org.junit.BeforeClass;+import org.apache.solr.util.BadHdfsThreadsFilter;import org.junit.Test;import org.kitesdk.morphline.api.Record;import org.kitesdk.morphline.base.Fields;import org.kitesdk.morphline.base.Notifications;-import java.io.File;-import java.util.ArrayList;-import java.util.Collections;-import java.util.Comparator;-import java.util.Iterator;-import java.util.List;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakAction;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakAction.Action;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies.Consequence;+import com.google.common.base.Joiner;+import com.google.common.base.Preconditions;+import com.google.common.io.Files;-@ThreadLeakAction({Action.WARN})-@ThreadLeakLingering(linger = 0)-@ThreadLeakZombies(Consequence.CONTINUE)-@ThreadLeakScope(Scope.NONE)+@ThreadLeakFilters(defaultFilters = true, filters = {+ BadHdfsThreadsFilter.class // hdfs currently leaks thread(s)+})@Slowpublic class SolrMorphlineZkAvroTest extends AbstractSolrMorphlineZkTestBase {diff --git a/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/SolrMorphlineZkTest.java b/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/SolrMorphlineZkTest.javaindex feb2d6a60db..2687d50c8bc 100644--- a/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/SolrMorphlineZkTest.java+++ b/solr/contrib/morphlines-core/src/test/org/apache/solr/morphlines/solr/SolrMorphlineZkTest.java@@ -16,29 +16,29 @@*/package org.apache.solr.morphlines.solr;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakAction;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakAction.Action;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies.Consequence;+import java.io.File;+import java.util.Iterator;+import org.apache.lucene.util.LuceneTestCase.Slow;import org.apache.solr.client.solrj.SolrQuery;import org.apache.solr.client.solrj.response.QueryResponse;import org.apache.solr.common.SolrDocument;+import org.apache.solr.util.BadHdfsThreadsFilter;import org.junit.Test;import org.kitesdk.morphline.api.Record;import org.kitesdk.morphline.base.Fields;import org.kitesdk.morphline.base.Notifications;-import java.io.File;-import java.util.Iterator;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakAction;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakAction.Action;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies.Consequence;-@ThreadLeakAction({Action.WARN})-@ThreadLeakLingering(linger = 0)-@ThreadLeakZombies(Consequence.CONTINUE)-@ThreadLeakScope(Scope.NONE)+@ThreadLeakFilters(defaultFilters = true, filters = {+ BadHdfsThreadsFilter.class // hdfs currently leaks thread(s)+})@Slowpublic class SolrMorphlineZkTest extends AbstractSolrMorphlineZkTestBase {diff --git a/solr/core/src/test/org/apache/solr/cloud/SaslZkACLProviderTest.java b/solr/core/src/test/org/apache/solr/cloud/SaslZkACLProviderTest.javaindex 0f33825ac6f..f7b8e289dfa 100644--- a/solr/core/src/test/org/apache/solr/cloud/SaslZkACLProviderTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/SaslZkACLProviderTest.java@@ -1,32 +1,31 @@package org.apache.solr.cloud;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;-import java.io.File;import java.io.IOException;import java.nio.charset.Charset;import java.util.Arrays;import java.util.List;import java.util.Locale;+import javax.security.auth.login.Configuration;-import org.apache.lucene.util.Constants;import org.apache.hadoop.minikdc.MiniKdc;+import org.apache.lucene.util.Constants;import org.apache.solr.SolrTestCaseJ4;+import org.apache.solr.common.cloud.DefaultZkACLProvider;import org.apache.solr.common.cloud.SaslZkACLProvider;import org.apache.solr.common.cloud.SolrZkClient;import org.apache.solr.common.cloud.ZkACLProvider;-import org.apache.solr.common.cloud.DefaultZkACLProvider;+import org.apache.solr.util.BadZookeeperThreadsFilter;import org.apache.zookeeper.CreateMode;-import org.junit.AfterClass;import org.junit.BeforeClass;import org.junit.Test;-import org.slf4j.Logger;import org.slf4j.LoggerFactory;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;+/** Licensed to the Apache Software Foundation (ASF) under one or more* contributor license agreements. See the NOTICE file distributed with@@ -44,7 +43,9 @@ import org.slf4j.LoggerFactory;* limitations under the License.*/-@ThreadLeakScope(Scope.NONE) // zookeeper sasl login can leak threads, see ZOOKEEPER-2100+@ThreadLeakFilters(defaultFilters = true, filters = {+ BadZookeeperThreadsFilter.class // hdfs currently leaks thread(s)+})public class SaslZkACLProviderTest extends SolrTestCaseJ4 {protected static Logger log = LoggerFactorydiff --git a/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java b/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.javaindex 8c15a62421c..9a5cdd6b3ee 100644--- a/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/SharedFSAutoReplicaFailoverTest.java@@ -28,8 +28,8 @@ import java.util.concurrent.SynchronousQueue;import java.util.concurrent.ThreadPoolExecutor;import java.util.concurrent.TimeUnit;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;+import org.apache.hadoop.hdfs.MiniDFSCluster;import org.apache.lucene.util.LuceneTestCase.Nightly;import org.apache.lucene.util.LuceneTestCase.Slow;@@ -46,8 +46,8 @@ import org.apache.solr.common.cloud.ZkStateReader;import org.apache.solr.common.params.CollectionParams;import org.apache.solr.common.params.MapSolrParams;import org.apache.solr.util.DefaultSolrThreadFactory;+import org.apache.solr.util.BadHdfsThreadsFilter;import org.junit.AfterClass;-import org.junit.Before;import org.junit.BeforeClass;import org.junit.Test;@@ -56,7 +56,9 @@ import static org.apache.solr.common.cloud.ZkNodeProps.makeMap;@Nightly@Slow@SuppressSSL-@ThreadLeakScope(Scope.NONE) // hdfs client currently leaks thread(s)+@ThreadLeakFilters(defaultFilters = true, filters = {+ BadHdfsThreadsFilter.class // hdfs currently leaks thread(s)+})public class SharedFSAutoReplicaFailoverTest extends AbstractFullDistribZkTestBase {private static final boolean DEBUG = true;diff --git a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsBasicDistributedZk2Test.java b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsBasicDistributedZk2Test.javaindex 71103ee200a..fe23ea4e336 100644--- a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsBasicDistributedZk2Test.java+++ b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsBasicDistributedZk2Test.java@@ -22,16 +22,18 @@ import java.io.IOException;import org.apache.hadoop.hdfs.MiniDFSCluster;import org.apache.lucene.util.LuceneTestCase.Slow;import org.apache.solr.cloud.BasicDistributedZk2Test;+import org.apache.solr.util.BadHdfsThreadsFilter;import org.junit.AfterClass;import org.junit.BeforeClass;import com.carrotsearch.randomizedtesting.annotations.Nightly;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;@Slow@Nightly-@ThreadLeakScope(Scope.NONE) // hdfs client currently leaks thread(s)+@ThreadLeakFilters(defaultFilters = true, filters = {+ BadHdfsThreadsFilter.class // hdfs currently leaks thread(s)+})public class HdfsBasicDistributedZk2Test extends BasicDistributedZk2Test {private static MiniDFSCluster dfsCluster;diff --git a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsBasicDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsBasicDistributedZkTest.javaindex 928e65d9556..1f3fe3e45a4 100644--- a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsBasicDistributedZkTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsBasicDistributedZkTest.java@@ -17,23 +17,24 @@ package org.apache.solr.cloud.hdfs;* limitations under the License.*/-import java.io.File;import java.io.IOException;import org.apache.hadoop.hdfs.MiniDFSCluster;-import org.apache.lucene.util.TestUtil;import org.apache.lucene.util.LuceneTestCase.Slow;import org.apache.solr.cloud.BasicDistributedZkTest;+import org.apache.solr.util.BadHdfsThreadsFilter;import org.junit.AfterClass;import org.junit.BeforeClass;import com.carrotsearch.randomizedtesting.annotations.Nightly;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;+@Slow@Nightly-@ThreadLeakScope(Scope.NONE) // hdfs client currently leaks thread(s)+@ThreadLeakFilters(defaultFilters = true, filters = {+ BadHdfsThreadsFilter.class // hdfs currently leaks thread(s)+})public class HdfsBasicDistributedZkTest extends BasicDistributedZkTest {private static MiniDFSCluster dfsCluster;diff --git a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsChaosMonkeySafeLeaderTest.java b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsChaosMonkeySafeLeaderTest.javaindex eb4a48bfea5..0f6e9060136 100644--- a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsChaosMonkeySafeLeaderTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsChaosMonkeySafeLeaderTest.java@@ -22,16 +22,18 @@ import java.io.IOException;import org.apache.hadoop.hdfs.MiniDFSCluster;import org.apache.lucene.util.LuceneTestCase.Slow;import org.apache.solr.cloud.ChaosMonkeySafeLeaderTest;+import org.apache.solr.util.BadHdfsThreadsFilter;import org.junit.AfterClass;import org.junit.BeforeClass;import com.carrotsearch.randomizedtesting.annotations.Nightly;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;@Slow@Nightly-@ThreadLeakScope(Scope.NONE) // hdfs client currently leaks thread(s)+@ThreadLeakFilters(defaultFilters = true, filters = {+ BadHdfsThreadsFilter.class // hdfs currently leaks thread(s)+})public class HdfsChaosMonkeySafeLeaderTest extends ChaosMonkeySafeLeaderTest {private static MiniDFSCluster dfsCluster;diff --git a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsCollectionsAPIDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsCollectionsAPIDistributedZkTest.javaindex 07945db4e21..40b5c66ab52 100644--- a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsCollectionsAPIDistributedZkTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsCollectionsAPIDistributedZkTest.java@@ -23,16 +23,18 @@ import org.apache.hadoop.hdfs.MiniDFSCluster;import org.apache.lucene.util.LuceneTestCase.Slow;import org.apache.solr.cloud.CollectionsAPIDistributedZkTest;import org.apache.solr.update.HdfsUpdateLog;+import org.apache.solr.util.BadHdfsThreadsFilter;import org.junit.AfterClass;import org.junit.BeforeClass;import com.carrotsearch.randomizedtesting.annotations.Nightly;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;@Slow@Nightly-@ThreadLeakScope(Scope.NONE) // hdfs client currently leaks thread(s)+@ThreadLeakFilters(defaultFilters = true, filters = {+ BadHdfsThreadsFilter.class // hdfs currently leaks thread(s)+})public class HdfsCollectionsAPIDistributedZkTest extends CollectionsAPIDistributedZkTest {private static MiniDFSCluster dfsCluster;diff --git a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsRecoveryZkTest.java b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsRecoveryZkTest.javaindex 797a323a23e..759a32f8afe 100644--- a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsRecoveryZkTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsRecoveryZkTest.java@@ -22,16 +22,18 @@ import java.io.IOException;import org.apache.hadoop.hdfs.MiniDFSCluster;import org.apache.lucene.util.LuceneTestCase.Slow;import org.apache.solr.cloud.RecoveryZkTest;+import org.apache.solr.util.BadHdfsThreadsFilter;import org.junit.AfterClass;import org.junit.BeforeClass;import com.carrotsearch.randomizedtesting.annotations.Nightly;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;@Slow@Nightly-@ThreadLeakScope(Scope.NONE) // hdfs client currently leaks thread(s)+@ThreadLeakFilters(defaultFilters = true, filters = {+ BadHdfsThreadsFilter.class // hdfs currently leaks thread(s)+})public class HdfsRecoveryZkTest extends RecoveryZkTest {private static MiniDFSCluster dfsCluster;diff --git a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsSyncSliceTest.java b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsSyncSliceTest.javaindex 13d9cffe46e..baf3577a011 100644--- a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsSyncSliceTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsSyncSliceTest.java@@ -22,16 +22,18 @@ import java.io.IOException;import org.apache.hadoop.hdfs.MiniDFSCluster;import org.apache.lucene.util.LuceneTestCase.Slow;import org.apache.solr.cloud.SyncSliceTest;+import org.apache.solr.util.BadHdfsThreadsFilter;import org.junit.AfterClass;import org.junit.BeforeClass;import com.carrotsearch.randomizedtesting.annotations.Nightly;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;@Slow@Nightly-@ThreadLeakScope(Scope.NONE) // hdfs client currently leaks thread(s)+@ThreadLeakFilters(defaultFilters = true, filters = {+ BadHdfsThreadsFilter.class // hdfs currently leaks thread(s)+})public class HdfsSyncSliceTest extends SyncSliceTest {private static MiniDFSCluster dfsCluster;diff --git a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsThreadLeakTest.java b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsThreadLeakTest.javanew file mode 100644index 00000000000..c6cd82a1568--- /dev/null+++ b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsThreadLeakTest.java@@ -0,0 +1,87 @@+package org.apache.solr.cloud.hdfs;++/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import java.io.IOException;+import java.net.URI;++import org.apache.hadoop.conf.Configuration;+import org.apache.hadoop.fs.FSDataOutputStream;+import org.apache.hadoop.fs.FileSystem;+import org.apache.hadoop.fs.Path;+import org.apache.hadoop.hdfs.DistributedFileSystem;+import org.apache.hadoop.hdfs.MiniDFSCluster;+import org.apache.solr.SolrTestCaseJ4;+import org.apache.solr.util.BadHdfsThreadsFilter;+import org.junit.After;+import org.junit.AfterClass;+import org.junit.Before;+import org.junit.BeforeClass;+import org.junit.Test;++import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;++@ThreadLeakFilters(defaultFilters = true, filters = {+ BadHdfsThreadsFilter.class // hdfs currently leaks thread(s)+})+public class HdfsThreadLeakTest extends SolrTestCaseJ4 {++ private static MiniDFSCluster dfsCluster;++ @BeforeClass+ public static void beforeClass() throws Exception {+ dfsCluster = HdfsTestUtil.setupClass(createTempDir().toFile().getAbsolutePath(), false);+ }++ @AfterClass+ public static void afterClass() throws Exception {+ HdfsTestUtil.teardownClass(dfsCluster);+ dfsCluster = null;+ }++ @Before+ public void setUp() throws Exception {+ super.setUp();+ }++ @After+ public void tearDown() throws Exception {+ super.tearDown();+ }++ @Test+ public void testBasic() throws IOException {+ URI uri = dfsCluster.getURI();+ Path path = new Path(uri.toString());+ Configuration conf = new Configuration();+ conf.setBoolean("fs.hdfs.impl.disable.cache", true);+ FileSystem fs = FileSystem.get(path.toUri(), conf);+ Path testFile = new Path(uri.toString() + "/testfile");+ FSDataOutputStream out = fs.create(testFile);++ out.write(5);+ out.hflush();+ out.close();++ ((DistributedFileSystem) fs).recoverLease(testFile);+++ fs.close();+ }++}diff --git a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsUnloadDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsUnloadDistributedZkTest.javaindex 45a2802755a..7f6faec4f28 100644--- a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsUnloadDistributedZkTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsUnloadDistributedZkTest.java@@ -22,16 +22,18 @@ import java.io.IOException;import org.apache.hadoop.hdfs.MiniDFSCluster;import org.apache.lucene.util.LuceneTestCase.Slow;import org.apache.solr.cloud.UnloadDistributedZkTest;+import org.apache.solr.util.BadHdfsThreadsFilter;import org.junit.AfterClass;import org.junit.BeforeClass;import com.carrotsearch.randomizedtesting.annotations.Nightly;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;@Slow@Nightly-@ThreadLeakScope(Scope.NONE) // hdfs client currently leaks thread(s)+@ThreadLeakFilters(defaultFilters = true, filters = {+ BadHdfsThreadsFilter.class // hdfs currently leaks thread(s)+})public class HdfsUnloadDistributedZkTest extends UnloadDistributedZkTest {private static MiniDFSCluster dfsCluster;diff --git a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsWriteToMultipleCollectionsTest.java b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsWriteToMultipleCollectionsTest.javaindex 0aedc11f93a..ba198cee107 100644--- a/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsWriteToMultipleCollectionsTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/hdfs/HdfsWriteToMultipleCollectionsTest.java@@ -17,8 +17,8 @@package org.apache.solr.cloud.hdfs;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;+import org.apache.hadoop.hdfs.MiniDFSCluster;import org.apache.lucene.index.IndexWriter;import org.apache.lucene.store.NRTCachingDirectory;@@ -38,6 +38,7 @@ import org.apache.solr.store.blockcache.BlockCache;import org.apache.solr.store.blockcache.BlockDirectory;import org.apache.solr.store.blockcache.BlockDirectoryCache;import org.apache.solr.store.blockcache.Cache;+import org.apache.solr.util.BadHdfsThreadsFilter;import org.apache.solr.util.RefCounted;import org.junit.AfterClass;import org.junit.BeforeClass;@@ -50,7 +51,9 @@ import java.util.List;@Slow@Nightly-@ThreadLeakScope(Scope.NONE) // hdfs client currently leaks thread(s)+@ThreadLeakFilters(defaultFilters = true, filters = {+ BadHdfsThreadsFilter.class // hdfs currently leaks thread(s)+})public class HdfsWriteToMultipleCollectionsTest extends BasicDistributedZkTest {private static final String SOLR_HDFS_HOME = "solr.hdfs.home";private static final String SOLR_HDFS_BLOCKCACHE_GLOBAL = "solr.hdfs.blockcache.global";diff --git a/solr/core/src/test/org/apache/solr/cloud/hdfs/StressHdfsTest.java b/solr/core/src/test/org/apache/solr/cloud/hdfs/StressHdfsTest.javaindex a3753224575..ee55e3d851a 100644--- a/solr/core/src/test/org/apache/solr/cloud/hdfs/StressHdfsTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/hdfs/StressHdfsTest.java@@ -17,8 +17,8 @@package org.apache.solr.cloud.hdfs;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;+import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.fs.FileSystem;import org.apache.hadoop.fs.Path;@@ -36,6 +36,7 @@ import org.apache.solr.cloud.ChaosMonkey;import org.apache.solr.common.params.CollectionParams.CollectionAction;import org.apache.solr.common.params.ModifiableSolrParams;import org.apache.solr.common.util.NamedList;+import org.apache.solr.util.BadHdfsThreadsFilter;import org.apache.zookeeper.KeeperException;import org.junit.AfterClass;import org.junit.BeforeClass;@@ -50,7 +51,9 @@ import java.util.Timer;import java.util.TimerTask;@Slow-@ThreadLeakScope(Scope.NONE) // hdfs client currently leaks thread(s)+@ThreadLeakFilters(defaultFilters = true, filters = {+ BadHdfsThreadsFilter.class // hdfs currently leaks thread(s)+})public class StressHdfsTest extends BasicDistributedZkTest {private static final String DELETE_DATA_DIR_COLLECTION = "delete_data_dir";diff --git a/solr/core/src/test/org/apache/solr/core/HdfsDirectoryFactoryTest.java b/solr/core/src/test/org/apache/solr/core/HdfsDirectoryFactoryTest.javaindex 26fbdf72522..9bb6de51d9e 100644--- a/solr/core/src/test/org/apache/solr/core/HdfsDirectoryFactoryTest.java+++ b/solr/core/src/test/org/apache/solr/core/HdfsDirectoryFactoryTest.java@@ -26,15 +26,17 @@ import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.cloud.hdfs.HdfsTestUtil;import org.apache.solr.common.util.NamedList;import org.apache.solr.core.DirectoryFactory.DirContext;+import org.apache.solr.util.BadHdfsThreadsFilter;import org.apache.solr.util.MockCoreContainer.MockCoreDescriptor;import org.junit.AfterClass;import org.junit.BeforeClass;import org.junit.Test;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;-@ThreadLeakScope(Scope.NONE) // hdfs client currently leaks thread(s)+@ThreadLeakFilters(defaultFilters = true, filters = {+ BadHdfsThreadsFilter.class // hdfs currently leaks thread(s)+})public class HdfsDirectoryFactoryTest extends SolrTestCaseJ4 {private static MiniDFSCluster dfsCluster;diff --git a/solr/core/src/test/org/apache/solr/search/TestRecoveryHdfs.java b/solr/core/src/test/org/apache/solr/search/TestRecoveryHdfs.javaindex 6f866a2ec14..249754400cc 100644--- a/solr/core/src/test/org/apache/solr/search/TestRecoveryHdfs.java+++ b/solr/core/src/test/org/apache/solr/search/TestRecoveryHdfs.java@@ -49,16 +49,18 @@ import org.apache.solr.update.HdfsUpdateLog;import org.apache.solr.update.UpdateHandler;import org.apache.solr.update.UpdateLog;import org.apache.solr.update.processor.DistributedUpdateProcessor.DistribPhase;+import org.apache.solr.util.BadHdfsThreadsFilter;import org.junit.AfterClass;import org.junit.BeforeClass;import org.junit.Ignore;import org.junit.Test;import org.noggit.ObjectBuilder;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;-@ThreadLeakScope(Scope.NONE) // hdfs mini cluster currently leaks threads+@ThreadLeakFilters(defaultFilters = true, filters = {+ BadHdfsThreadsFilter.class // hdfs currently leaks thread(s)+})// TODO: longer term this should be combined with TestRecovery somehow ??public class TestRecoveryHdfs extends SolrTestCaseJ4 {diff --git a/solr/core/src/test/org/apache/solr/store/hdfs/HdfsDirectoryTest.java b/solr/core/src/test/org/apache/solr/store/hdfs/HdfsDirectoryTest.javaindex 5042dcf9bc5..12a93b2d44f 100644--- a/solr/core/src/test/org/apache/solr/store/hdfs/HdfsDirectoryTest.java+++ b/solr/core/src/test/org/apache/solr/store/hdfs/HdfsDirectoryTest.java@@ -33,17 +33,18 @@ import org.apache.lucene.store.NoLockFactory;import org.apache.lucene.store.RAMDirectory;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.cloud.hdfs.HdfsTestUtil;+import org.apache.solr.util.BadHdfsThreadsFilter;import org.junit.After;import org.junit.AfterClass;import org.junit.Before;import org.junit.BeforeClass;import org.junit.Test;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;-@ThreadLeakScope(Scope.NONE) // hdfs client currently leaks thread (HADOOP-9049)-//@Ignore("this test violates the test security policy because of org.apache.hadoop.fs.RawLocalFileSystem.mkdirs")+@ThreadLeakFilters(defaultFilters = true, filters = {+ BadHdfsThreadsFilter.class // hdfs currently leaks thread(s)+})public class HdfsDirectoryTest extends SolrTestCaseJ4 {private static final int MAX_NUMBER_OF_WRITES = 10000;diff --git a/solr/core/src/test/org/apache/solr/store/hdfs/HdfsLockFactoryTest.java b/solr/core/src/test/org/apache/solr/store/hdfs/HdfsLockFactoryTest.javaindex 24ebec37507..75fc74c6c48 100644--- a/solr/core/src/test/org/apache/solr/store/hdfs/HdfsLockFactoryTest.java+++ b/solr/core/src/test/org/apache/solr/store/hdfs/HdfsLockFactoryTest.java@@ -26,16 +26,18 @@ import org.apache.hadoop.hdfs.MiniDFSCluster;import org.apache.lucene.store.Lock;import org.apache.solr.SolrTestCaseJ4;import org.apache.solr.cloud.hdfs.HdfsTestUtil;+import org.apache.solr.util.BadHdfsThreadsFilter;import org.junit.After;import org.junit.AfterClass;import org.junit.Before;import org.junit.BeforeClass;import org.junit.Test;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;-@ThreadLeakScope(Scope.NONE) // hdfs client currently leaks thread (HADOOP-9049)+@ThreadLeakFilters(defaultFilters = true, filters = {+ BadHdfsThreadsFilter.class // hdfs currently leaks thread(s)+})public class HdfsLockFactoryTest extends SolrTestCaseJ4 {private static MiniDFSCluster dfsCluster;diff --git a/solr/core/src/test/org/apache/solr/update/TestHdfsUpdateLog.java b/solr/core/src/test/org/apache/solr/update/TestHdfsUpdateLog.javaindex b782a04a7a3..4c8b4e9493b 100644--- a/solr/core/src/test/org/apache/solr/update/TestHdfsUpdateLog.java+++ b/solr/core/src/test/org/apache/solr/update/TestHdfsUpdateLog.java@@ -29,14 +29,16 @@ import org.apache.solr.SolrTestCaseJ4.SuppressObjectReleaseTracker;import org.apache.solr.cloud.hdfs.HdfsTestUtil;import org.apache.solr.common.util.IOUtils;import org.apache.solr.request.SolrQueryRequest;+import org.apache.solr.util.BadHdfsThreadsFilter;import org.junit.AfterClass;import org.junit.BeforeClass;import org.junit.Test;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;-import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope.Scope;+import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;-@ThreadLeakScope(Scope.NONE) // hdfs mini cluster currently leaks threads+@ThreadLeakFilters(defaultFilters = true, filters = {+ BadHdfsThreadsFilter.class // hdfs currently leaks thread(s)+})@SuppressObjectReleaseTracker(bugUrl = "https://issues.apache.org/jira/browse/SOLR-7115")public class TestHdfsUpdateLog extends SolrTestCaseJ4 {diff --git a/solr/test-framework/src/java/org/apache/solr/util/BadHdfsThreadsFilter.java b/solr/test-framework/src/java/org/apache/solr/util/BadHdfsThreadsFilter.javanew file mode 100644index 00000000000..f1eea7a7d5f--- /dev/null+++ b/solr/test-framework/src/java/org/apache/solr/util/BadHdfsThreadsFilter.java@@ -0,0 +1,36 @@+package org.apache.solr.util;++/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import com.carrotsearch.randomizedtesting.ThreadFilter;++public class BadHdfsThreadsFilter implements ThreadFilter {++ @Override+ public boolean reject(Thread t) {+ String name = t.getName();+ if (name.startsWith("IPC Parameter Sending Thread ")) { // SOLR-5007+ return true;+ } else if (name.startsWith("org.apache.hadoop.hdfs.PeerCache")) { // SOLR-7288+ return true;+ } else if (name.startsWith("LeaseRenewer")) { // SOLR-7287+ return true;+ }+ return false;+ }+}diff --git a/solr/test-framework/src/java/org/apache/solr/util/BadZookeeperThreadsFilter.java b/solr/test-framework/src/java/org/apache/solr/util/BadZookeeperThreadsFilter.javanew file mode 100644index 00000000000..2e89a6d7e8e--- /dev/null+++ b/solr/test-framework/src/java/org/apache/solr/util/BadZookeeperThreadsFilter.java@@ -0,0 +1,35 @@+package org.apache.solr.util;++/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import com.carrotsearch.randomizedtesting.ThreadFilter;++public class BadZookeeperThreadsFilter implements ThreadFilter {++ @Override+ public boolean reject(Thread t) {+ String name = t.getName();++ StackTraceElement [] stack = t.getStackTrace();+ if (name.startsWith("Thread-") && stack.length > 1 && stack[stack.length - 2].getClassName().equals("org.apache.zookeeper.Login$1")) {+ return true; // see ZOOKEEPER-2100+ }++ return false;+ }+}