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.common.SolrDocument;
|
||||
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.CommonParams;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
|
@ -148,26 +149,17 @@ public class SystemLogListenerTest extends SolrCloudTestCase {
|
|||
response = solrClient.request(req);
|
||||
assertEquals(response.get("result").toString(), "success");
|
||||
|
||||
// stop non-overseer node
|
||||
NamedList<Object> overSeerStatus = cluster.getSolrClient().request(CollectionAdminRequest.getOverseerStatus());
|
||||
String overseerLeader = (String) overSeerStatus.get("leader");
|
||||
int nonOverseerLeaderIndex = 0;
|
||||
for (int i = 0; i < cluster.getJettySolrRunners().size(); i++) {
|
||||
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);
|
||||
// Stop a node (that's safe to stop for the purposes of this test)
|
||||
final JettySolrRunner stoppedJetty = pickNodeToStop();
|
||||
log.info("Stopping node " + stoppedJetty.getNodeName());
|
||||
cluster.stopJettySolrRunner(stoppedJetty);
|
||||
cluster.waitForJettyToStop(stoppedJetty);
|
||||
|
||||
assertTrue("Trigger was not fired ", triggerFiredLatch.await(60, TimeUnit.SECONDS));
|
||||
assertTrue(fired.get());
|
||||
Map context = actionContextPropsRef.get();
|
||||
assertNotNull(context);
|
||||
|
||||
|
||||
|
||||
TimeOut timeout = new TimeOut(30, TimeUnit.SECONDS, TimeSource.NANO_TIME);
|
||||
|
||||
ModifiableSolrParams query = new ModifiableSolrParams();
|
||||
|
@ -199,7 +191,8 @@ public class SystemLogListenerTest extends SolrCloudTestCase {
|
|||
QueryResponse resp = cluster.getSolrClient().query(CollectionAdminParams.SYSTEM_COLL, query);
|
||||
SolrDocumentList docs = resp.getResults();
|
||||
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));
|
||||
|
||||
// STARTED
|
||||
|
@ -273,4 +266,25 @@ public class SystemLogListenerTest extends SolrCloudTestCase {
|
|||
assertNotNull(doc.getFieldValue("event_str"));
|
||||
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