Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-8472: tests - pull up common errorHook code

Yonik Seeleyfa3b4c962349
diff --git a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java
index 68b3cc056f0..cda749f80d2 100644
--- a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java
@@ -30,8 +30,6 @@ import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.util.IOUtils;
-import org.apache.solr.core.Diagnostics;
-import org.apache.solr.update.SolrCmdDistributor;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -60,23 +58,13 @@ public class ChaosMonkeyNothingIsSafeTest extends AbstractFullDistribZkTestBase
public static void beforeSuperClass() {
schemaString = "schema15.xml"; // we need a string id
System.setProperty("solr.autoCommit.maxTime", "15000");
- SolrCmdDistributor.testing_errorHook = new Diagnostics.Callable() {
- @Override
- public void call(Object... data) {
- Exception e = (Exception) data[0];
- if (e == null) return;
- String msg = e.getMessage();
- if (msg != null && msg.contains("Timeout")) {
- Diagnostics.logThreadDumps("REQUESTING THREAD DUMP DUE TO TIMEOUT: " + e.getMessage());
- }
- }
- };
+ setErrorHook();
}
@AfterClass
public static void afterSuperClass() {
System.clearProperty("solr.autoCommit.maxTime");
- SolrCmdDistributor.testing_errorHook = null;
+ clearErrorHook();
}
protected static final String[] fieldNames = new String[]{"f_i", "f_f", "f_d", "f_l", "f_dt"};
diff --git a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java
index 51edaa8953b..314f581aa68 100644
--- a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java
@@ -22,8 +22,6 @@ import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.common.SolrInputDocument;
-import org.apache.solr.core.Diagnostics;
-import org.apache.solr.update.SolrCmdDistributor;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -41,25 +39,15 @@ public class ChaosMonkeySafeLeaderTest extends AbstractFullDistribZkTestBase {
public static void beforeSuperClass() {
schemaString = "schema15.xml"; // we need a string id
System.setProperty("solr.autoCommit.maxTime", "15000");
- SolrCmdDistributor.testing_errorHook = new Diagnostics.Callable() {
- @Override
- public void call(Object... data) {
- Exception e = (Exception) data[0];
- if (e == null) return;
- String msg = e.getMessage();
- if (msg != null && msg.contains("Timeout")) {
- Diagnostics.logThreadDumps("REQUESTING THREAD DUMP DUE TO TIMEOUT: " + e.getMessage());
- }
- }
- };
+ setErrorHook();
}
@AfterClass
public static void afterSuperClass() {
System.clearProperty("solr.autoCommit.maxTime");
- SolrCmdDistributor.testing_errorHook = null;
+ clearErrorHook();
}
-
+
protected static final String[] fieldNames = new String[]{"f_i", "f_f", "f_d", "f_l", "f_dt"};
protected static final RandVal[] randVals = new RandVal[]{rint, rfloat, rdouble, rlong, rdate};
diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
index 0aadc3edc2f..5c87376f379 100644
--- a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
+++ b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
@@ -71,9 +71,11 @@ import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.StrUtils;
import org.apache.solr.common.util.Utils;
import org.apache.solr.core.CoreContainer;
+import org.apache.solr.core.Diagnostics;
import org.apache.solr.core.SolrCore;
import org.apache.solr.servlet.SolrDispatchFilter;
import org.apache.solr.update.DirectUpdateHandler2;
+import org.apache.solr.update.SolrCmdDistributor;
import org.apache.solr.util.RTimer;
import org.apache.solr.util.TimeOut;
import org.apache.zookeeper.CreateMode;
@@ -193,6 +195,24 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
}
+ protected static void setErrorHook() {
+ SolrCmdDistributor.testing_errorHook = new Diagnostics.Callable() {
+ @Override
+ public void call(Object... data) {
+ Exception e = (Exception) data[0];
+ if (e == null) return;
+ String msg = e.getMessage();
+ if (msg != null && msg.contains("Timeout")) {
+ Diagnostics.logThreadDumps("REQUESTING THREAD DUMP DUE TO TIMEOUT: " + e.getMessage());
+ }
+ }
+ };
+ }
+
+ protected static void clearErrorHook() {
+ SolrCmdDistributor.testing_errorHook = null;
+ }
+
@Override
public void distribSetUp() throws Exception {
super.distribSetUp();