mirror of https://github.com/apache/lucene.git
SOLR-13050: add workaround for issue to SystemLogListenerTest
make sure the node we kill isn't the .system collection leader
This commit is contained in:
parent
f89f109ec1
commit
a2199c72d4
|
@ -38,6 +38,7 @@ import org.apache.solr.client.solrj.response.QueryResponse;
|
||||||
import org.apache.solr.cloud.SolrCloudTestCase;
|
import org.apache.solr.cloud.SolrCloudTestCase;
|
||||||
import org.apache.solr.common.SolrDocument;
|
import org.apache.solr.common.SolrDocument;
|
||||||
import org.apache.solr.common.SolrDocumentList;
|
import org.apache.solr.common.SolrDocumentList;
|
||||||
|
import org.apache.solr.common.cloud.Replica;
|
||||||
import org.apache.solr.common.params.CollectionAdminParams;
|
import org.apache.solr.common.params.CollectionAdminParams;
|
||||||
import org.apache.solr.common.params.CommonParams;
|
import org.apache.solr.common.params.CommonParams;
|
||||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||||
|
@ -148,26 +149,17 @@ public class SystemLogListenerTest extends SolrCloudTestCase {
|
||||||
response = solrClient.request(req);
|
response = solrClient.request(req);
|
||||||
assertEquals(response.get("result").toString(), "success");
|
assertEquals(response.get("result").toString(), "success");
|
||||||
|
|
||||||
// stop non-overseer node
|
// Stop a node (that's safe to stop for the purposes of this test)
|
||||||
NamedList<Object> overSeerStatus = cluster.getSolrClient().request(CollectionAdminRequest.getOverseerStatus());
|
final JettySolrRunner stoppedJetty = pickNodeToStop();
|
||||||
String overseerLeader = (String) overSeerStatus.get("leader");
|
log.info("Stopping node " + stoppedJetty.getNodeName());
|
||||||
int nonOverseerLeaderIndex = 0;
|
cluster.stopJettySolrRunner(stoppedJetty);
|
||||||
for (int i = 0; i < cluster.getJettySolrRunners().size(); i++) {
|
cluster.waitForJettyToStop(stoppedJetty);
|
||||||
JettySolrRunner jetty = cluster.getJettySolrRunner(i);
|
|
||||||
if (!jetty.getNodeName().equals(overseerLeader)) {
|
|
||||||
nonOverseerLeaderIndex = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log.info("Stopping node " + cluster.getJettySolrRunner(nonOverseerLeaderIndex).getNodeName());
|
|
||||||
JettySolrRunner j = cluster.stopJettySolrRunner(nonOverseerLeaderIndex);
|
|
||||||
cluster.waitForJettyToStop(j);
|
|
||||||
assertTrue("Trigger was not fired ", triggerFiredLatch.await(60, TimeUnit.SECONDS));
|
assertTrue("Trigger was not fired ", triggerFiredLatch.await(60, TimeUnit.SECONDS));
|
||||||
assertTrue(fired.get());
|
assertTrue(fired.get());
|
||||||
Map context = actionContextPropsRef.get();
|
Map context = actionContextPropsRef.get();
|
||||||
assertNotNull(context);
|
assertNotNull(context);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TimeOut timeout = new TimeOut(30, TimeUnit.SECONDS, TimeSource.NANO_TIME);
|
TimeOut timeout = new TimeOut(30, TimeUnit.SECONDS, TimeSource.NANO_TIME);
|
||||||
|
|
||||||
ModifiableSolrParams query = new ModifiableSolrParams();
|
ModifiableSolrParams query = new ModifiableSolrParams();
|
||||||
|
@ -199,7 +191,8 @@ public class SystemLogListenerTest extends SolrCloudTestCase {
|
||||||
QueryResponse resp = cluster.getSolrClient().query(CollectionAdminParams.SYSTEM_COLL, query);
|
QueryResponse resp = cluster.getSolrClient().query(CollectionAdminParams.SYSTEM_COLL, query);
|
||||||
SolrDocumentList docs = resp.getResults();
|
SolrDocumentList docs = resp.getResults();
|
||||||
assertNotNull(docs);
|
assertNotNull(docs);
|
||||||
assertEquals("wrong number of events added to .system", 9, docs.size());
|
assertEquals("wrong number of events added to .system: " + docs.toString(),
|
||||||
|
9, docs.size());
|
||||||
docs.forEach(doc -> assertCommonFields(doc));
|
docs.forEach(doc -> assertCommonFields(doc));
|
||||||
|
|
||||||
// STARTED
|
// STARTED
|
||||||
|
@ -273,4 +266,25 @@ public class SystemLogListenerTest extends SolrCloudTestCase {
|
||||||
assertNotNull(doc.getFieldValue("event_str"));
|
assertNotNull(doc.getFieldValue("event_str"));
|
||||||
assertEquals("NODELOST", doc.getFieldValue("event.type_s"));
|
assertEquals("NODELOST", doc.getFieldValue("event.type_s"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method for picking a node that can safely be stoped
|
||||||
|
* @see <a href="https://issues.apache.org/jira/browse/SOLR-13050">SOLR-13050</a>
|
||||||
|
*/
|
||||||
|
private JettySolrRunner pickNodeToStop() throws Exception {
|
||||||
|
// first get the nodeName of the overser.
|
||||||
|
// stopping the overseer is not something we want to hassle with in this test
|
||||||
|
final String overseerNodeName = (String) cluster.getSolrClient().request
|
||||||
|
(CollectionAdminRequest.getOverseerStatus()).get("leader");
|
||||||
|
|
||||||
|
// now find a node that is *NOT* the overseer or the leader of a .system collection shard
|
||||||
|
for (Replica r : getCollectionState(CollectionAdminParams.SYSTEM_COLL).getReplicas()) {
|
||||||
|
if ( ! (r.getBool("leader", false) || r.getNodeName().equals(overseerNodeName) ) ) {
|
||||||
|
return cluster.getReplicaJetty(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fail("Couldn't find non-leader, non-overseer, replica of .system collection to kill");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue