Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-6511: adjust test logic to account for timing issues in zk session expiration scenario.

Timothy Potter41f65776d3ba
diff --git a/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java b/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
index 155cd31d307..1027a88d492 100644
--- a/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
@@ -302,36 +302,23 @@ public class HttpPartitionTest extends AbstractFullDistribZkTestBase {
cloudClient.getZkStateReader().getLeaderRetry(testCollectionName, "shard1");
assertEquals(expectedNewLeaderCoreNodeName, currentLeader.getName());
+ // TODO: This test logic seems to be timing dependent and fails on Jenkins
+ // need to come up with a better approach
log.info("Sending doc 2 to old leader "+leader.getName());
try {
leaderSolr.add(doc);
leaderSolr.shutdown();
- Replica oldLeaderInRecovery = null;
- for (Replica next : getActiveOrRecoveringReplicas(testCollectionName, "shard1")) {
- if (next.getName().equals(leader.getName()) &&
- ZkStateReader.RECOVERING.equals(next.getStr(ZkStateReader.STATE_PROP)))
- {
- oldLeaderInRecovery = next;
- break;
- }
- }
-
- // if the old leader is not active or recovering, the add should have failed
- if (oldLeaderInRecovery != null) {
- HttpSolrServer oldLeaderSolr = getHttpSolrServer(oldLeaderInRecovery, testCollectionName);
- try {
- assertDocExists(oldLeaderSolr, testCollectionName, "2");
- } finally {
- oldLeaderSolr.shutdown();
- }
- } else {
- fail("Send doc 2 to old leader " + leader.getName() +
- " should have failed! ClusterState: " + printClusterStateInfo(testCollectionName));
+ // if the add worked, then the doc must exist on the new leader
+ HttpSolrServer newLeaderSolr = getHttpSolrServer(currentLeader, testCollectionName);
+ try {
+ assertDocExists(newLeaderSolr, testCollectionName, "2");
+ } finally {
+ newLeaderSolr.shutdown();
}
} catch (SolrException exc) {
- // this is expected ..
+ // this is ok provided the doc doesn't exist on the current leader
leaderSolr = getHttpSolrServer(currentLeader, testCollectionName);
try {
leaderSolr.add(doc); // this should work