mirror of https://github.com/apache/lucene.git
SOLR-8472: tests - pull up common errorHook code
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1724069 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6d7e64311d
commit
fa3b4c9623
|
@ -30,8 +30,6 @@ import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
import org.apache.solr.common.SolrInputDocument;
|
||||||
import org.apache.solr.common.cloud.ZkStateReader;
|
import org.apache.solr.common.cloud.ZkStateReader;
|
||||||
import org.apache.solr.common.util.IOUtils;
|
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.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -60,23 +58,13 @@ public class ChaosMonkeyNothingIsSafeTest extends AbstractFullDistribZkTestBase
|
||||||
public static void beforeSuperClass() {
|
public static void beforeSuperClass() {
|
||||||
schemaString = "schema15.xml"; // we need a string id
|
schemaString = "schema15.xml"; // we need a string id
|
||||||
System.setProperty("solr.autoCommit.maxTime", "15000");
|
System.setProperty("solr.autoCommit.maxTime", "15000");
|
||||||
SolrCmdDistributor.testing_errorHook = new Diagnostics.Callable() {
|
setErrorHook();
|
||||||
@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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void afterSuperClass() {
|
public static void afterSuperClass() {
|
||||||
System.clearProperty("solr.autoCommit.maxTime");
|
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 String[] fieldNames = new String[]{"f_i", "f_f", "f_d", "f_l", "f_dt"};
|
||||||
|
|
|
@ -22,8 +22,6 @@ import org.apache.solr.client.solrj.SolrQuery;
|
||||||
import org.apache.solr.client.solrj.SolrServerException;
|
import org.apache.solr.client.solrj.SolrServerException;
|
||||||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
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.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -41,25 +39,15 @@ public class ChaosMonkeySafeLeaderTest extends AbstractFullDistribZkTestBase {
|
||||||
public static void beforeSuperClass() {
|
public static void beforeSuperClass() {
|
||||||
schemaString = "schema15.xml"; // we need a string id
|
schemaString = "schema15.xml"; // we need a string id
|
||||||
System.setProperty("solr.autoCommit.maxTime", "15000");
|
System.setProperty("solr.autoCommit.maxTime", "15000");
|
||||||
SolrCmdDistributor.testing_errorHook = new Diagnostics.Callable() {
|
setErrorHook();
|
||||||
@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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void afterSuperClass() {
|
public static void afterSuperClass() {
|
||||||
System.clearProperty("solr.autoCommit.maxTime");
|
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 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};
|
protected static final RandVal[] randVals = new RandVal[]{rint, rfloat, rdouble, rlong, rdate};
|
||||||
|
|
||||||
|
|
|
@ -71,9 +71,11 @@ import org.apache.solr.common.util.NamedList;
|
||||||
import org.apache.solr.common.util.StrUtils;
|
import org.apache.solr.common.util.StrUtils;
|
||||||
import org.apache.solr.common.util.Utils;
|
import org.apache.solr.common.util.Utils;
|
||||||
import org.apache.solr.core.CoreContainer;
|
import org.apache.solr.core.CoreContainer;
|
||||||
|
import org.apache.solr.core.Diagnostics;
|
||||||
import org.apache.solr.core.SolrCore;
|
import org.apache.solr.core.SolrCore;
|
||||||
import org.apache.solr.servlet.SolrDispatchFilter;
|
import org.apache.solr.servlet.SolrDispatchFilter;
|
||||||
import org.apache.solr.update.DirectUpdateHandler2;
|
import org.apache.solr.update.DirectUpdateHandler2;
|
||||||
|
import org.apache.solr.update.SolrCmdDistributor;
|
||||||
import org.apache.solr.util.RTimer;
|
import org.apache.solr.util.RTimer;
|
||||||
import org.apache.solr.util.TimeOut;
|
import org.apache.solr.util.TimeOut;
|
||||||
import org.apache.zookeeper.CreateMode;
|
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
|
@Override
|
||||||
public void distribSetUp() throws Exception {
|
public void distribSetUp() throws Exception {
|
||||||
super.distribSetUp();
|
super.distribSetUp();
|
||||||
|
|
Loading…
Reference in New Issue