SOLR-14000: clean up more static field leaks in tests

On windows, these objects can't be inspected due to security restrictions. So the test runner fails the tests since it does not know how big the leak is.
This commit is contained in:
Robert Muir 2019-12-03 18:49:36 -05:00
parent 16f793915e
commit 165529767b
19 changed files with 86 additions and 0 deletions

View File

@ -91,6 +91,8 @@ public class SolrStandaloneScraperTest extends RestTestBase {
jetty.stop();
jetty = null;
}
solrScraper = null;
solrClient = null;
}
@Test

View File

@ -204,6 +204,7 @@ public class OverseerCollectionConfigSetProcessorTest extends SolrTestCaseJ4 {
zkControllerMock = null;
cloudDataProviderMock = null;
clusterStateProviderMock = null;
stateManagerMock = null;;
cloudManagerMock = null;
distribStateManagerMock = null;
coreContainerMock = null;

View File

@ -315,6 +315,8 @@ public class OverseerTest extends SolrTestCaseJ4 {
if (null != server) {
server.shutdown();
}
server = null;
}
@After

View File

@ -48,6 +48,7 @@ import org.apache.solr.common.util.TimeSource;
import org.apache.solr.util.LogLevel;
import org.apache.solr.util.TimeOut;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
@ -92,6 +93,11 @@ public class TestWithCollection extends SolrCloudTestCase {
shutdownCluster();
}
@AfterClass
public static void cleanUpAfterClass() throws Exception {
cloudManager = null;
}
private void deleteChildrenRecursively(String path) throws Exception {
cloudManager.getDistribStateManager().removeRecursively(path, true, false);
}

View File

@ -56,6 +56,7 @@ import org.apache.solr.common.util.Utils;
import org.apache.solr.core.SolrResourceLoader;
import org.apache.solr.util.LogLevel;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@ -168,6 +169,11 @@ public class ComputePlanActionTest extends SolrCloudTestCase {
state.forEachCollection(coll -> log.debug("* Collection " + coll.getName() + " state: " + coll));
}
@AfterClass
public static void cleanUpAfterClass() throws Exception {
cloudManager = null;
}
@Test
@LuceneTestCase.AwaitsFix(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028")
public void testNodeLost() throws Exception {

View File

@ -41,6 +41,7 @@ import org.apache.solr.util.LogLevel;
import org.apache.solr.util.TimeOut;
import org.apache.zookeeper.data.Stat;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
@ -68,6 +69,11 @@ public class NodeAddedTriggerIntegrationTest extends SolrCloudTestCase {
shutdownCluster();
}
@AfterClass
public static void cleanUpAfterClass() throws Exception {
cloudManager = null;
}
private static CountDownLatch getTriggerFiredLatch() {
return triggerFiredLatch;
}

View File

@ -43,6 +43,7 @@ import org.apache.solr.util.LogLevel;
import org.apache.solr.util.TimeOut;
import org.apache.zookeeper.data.Stat;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
@ -116,6 +117,11 @@ public class NodeLostTriggerIntegrationTest extends SolrCloudTestCase {
shutdownCluster();
}
@AfterClass
public static void cleanUpAfterClass() throws Exception {
cloudManager = null;
}
private void deleteChildrenRecursively(String path) throws Exception {
cloudManager.getDistribStateManager().removeRecursively(path, true, false);
}

View File

@ -50,6 +50,7 @@ import org.apache.solr.common.util.Utils;
import org.apache.solr.core.SolrResourceLoader;
import org.apache.solr.util.LogLevel;
import org.apache.zookeeper.data.Stat;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@ -90,6 +91,11 @@ public class TriggerIntegrationTest extends SolrCloudTestCase {
CloudTestUtils.suspendTrigger(cluster.getOpenOverseer().getSolrCloudManager(), ".scheduled_maintenance");
}
@AfterClass
public static void cleanUpAfterClass() throws Exception {
cloudManager = null;
}
private static CountDownLatch getTriggerFiredLatch() {
return triggerFiredLatch;
}

View File

@ -88,6 +88,7 @@ public class TestSimClusterStateProvider extends SolrCloudTestCase {
if (simulated && cloudManager != null) {
cloudManager.close();
}
cloudManager = null;
}
private static void init() throws Exception {

View File

@ -51,6 +51,7 @@ import org.apache.solr.common.cloud.Replica;
import org.apache.solr.common.params.CollectionAdminParams;
import org.apache.solr.common.util.TimeSource;
import org.apache.solr.common.util.Utils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
@ -82,6 +83,11 @@ public class TestSnapshotCloudManager extends SolrCloudTestCase {
.getZkController().getSolrCloudManager();
}
@AfterClass
public static void cleanUpAfterClass() throws Exception {
realManager = null;
}
@Test
public void testSnapshots() throws Exception {
SnapshotCloudManager snapshotCloudManager = new SnapshotCloudManager(realManager, null);

View File

@ -100,6 +100,7 @@ public class TestJmxIntegration extends SolrTestCaseJ4 {
MBeanServerFactory.releaseMBeanServer(newMbeanServer);
}
mbeanServer = null;
newMbeanServer = null;
}
@Before

View File

@ -111,6 +111,11 @@ public class MetricsHistoryHandlerTest extends SolrCloudTestCase {
if (simulated) {
cloudManager.close();
}
handler = null;
metricsHandler = null;
cloudManager = null;
metricManager = null;
solrClient = null;
}
@Test

View File

@ -42,6 +42,7 @@ import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.ContentStream;
import org.apache.solr.common.util.ContentStreamBase;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
@ -62,6 +63,11 @@ public class EmbeddedSolrNoSerializeTest extends SolrTestCaseJ4 {
//we don't need to close the EmbeddedSolrServer because SolrTestCaseJ4 closes the core
}
@AfterClass
public static void cleanUpAfterClass() throws Exception {
solrServer = null;
}
@Before
public void setUp() throws Exception {
super.setUp();

View File

@ -40,6 +40,7 @@ import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
import org.apache.solr.common.SolrException;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.xml.sax.InputSource;
@ -59,6 +60,11 @@ public class XmlInterpolationTest extends TaggerTestCase {
initCore("solrconfig-tagger.xml", "schema-tagger.xml");
}
@AfterClass
public static void cleanUpAfterClass() throws Exception {
xmlDocBuilder = null;
}
@Override
public void setUp() throws Exception {
super.setUp();

View File

@ -36,6 +36,7 @@ import org.apache.solr.cloud.SolrCloudTestCase;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.cloud.ZkStateReader;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@ -120,6 +121,11 @@ public class TestCloudNestedDocsSort extends SolrCloudTestCase {
}
}
@AfterClass
public static void cleanUpAfterClass() throws Exception {
client = null;
}
@Test
public void test() throws SolrServerException, IOException {
final boolean asc = random().nextBoolean();

View File

@ -40,6 +40,7 @@ import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.update.UpdateCommand;
import org.apache.solr.util.LogLevel;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
@ -85,6 +86,11 @@ public class CategoryRoutedAliasUpdateProcessorTest extends RoutedAliasUpdatePro
}
}
@AfterClass
public static void cleanUpAfterClass() throws Exception {
solrClient = null;
}
@Test
@Slow
public void testNonEnglish() throws Exception {

View File

@ -85,6 +85,7 @@ public class DimensionalRoutedAliasUpdateProcessorTest extends RoutedAliasUpdate
@AfterClass
public static void finish() throws Exception {
IOUtils.close(solrClient);
solrClient = null;
}
@Test
public void testTimeCat() throws Exception {

View File

@ -71,6 +71,7 @@ import org.apache.solr.handler.admin.CollectionsHandler;
import org.apache.solr.handler.admin.ConfigSetsHandler;
import org.apache.solr.handler.admin.CoreAdminHandler;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@ -134,6 +135,12 @@ public class CloudHttp2SolrClientTest extends SolrCloudTestCase {
super.tearDown();
}
@AfterClass
public static void cleanUpAfterClass() throws Exception {
httpBasedCloudSolrClient = null;
zkBasedCloudSolrClient = null;
}
/**
* Randomly return the cluster's ZK based CSC, or HttpClusterProvider based CSC.
*/

View File

@ -72,6 +72,7 @@ import org.apache.solr.handler.admin.CollectionsHandler;
import org.apache.solr.handler.admin.ConfigSetsHandler;
import org.apache.solr.handler.admin.CoreAdminHandler;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@ -124,6 +125,11 @@ public class CloudSolrClientTest extends SolrCloudTestCase {
super.tearDown();
}
@AfterClass
public static void cleanUpAfterClass() throws Exception {
httpBasedCloudSolrClient = null;
}
/**
* Randomly return the cluster's ZK based CSC, or HttpClusterProvider based CSC.
*/