Apache Lucene open-source search software
SOLR-5888: Speed up SyncSliceTest as well as some other tests.
Mark Robert Miller2ce105ed4523
diff --git a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.javaindex 6ca7607f7bb..9803470e25b 100644--- a/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java@@ -313,7 +313,7 @@ public class ChaosMonkeyNothingIsSafeTest extends AbstractFullDistribZkTestBasetry {numAdds++;- if (numAdds > 4000)+ if (numAdds > (TEST_NIGHTLY ? 4002 : 197))continue;SolrInputDocument doc = getDoc("id",diff --git a/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java b/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.javaindex 04f98894ef5..e9f9ed0f262 100644--- a/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java+++ b/solr/core/src/test/org/apache/solr/cloud/SyncSliceTest.java@@ -164,10 +164,10 @@ public class SyncSliceTest extends AbstractFullDistribZkTestBase {assertEquals(shardCount - 1, jetties.size());chaosMonkey.killJetty(leaderJetty);-- Thread.sleep(2000);- waitForThingsToLevelOut(120);+ Thread.sleep(3000);++ waitForNoShardInconsistency();Thread.sleep(1000);@@ -187,7 +187,7 @@ public class SyncSliceTest extends AbstractFullDistribZkTestBase {// bring back dead nodeChaosMonkey.start(deadJetty.jetty); // he is not the leader anymore- waitTillRecovered();+ waitTillAllNodesActive();skipServers = getRandomOtherJetty(leaderJetty, deadJetty);skipServers.addAll( getRandomOtherJetty(leaderJetty, deadJetty));@@ -228,20 +228,14 @@ public class SyncSliceTest extends AbstractFullDistribZkTestBase {// kill the current leaderchaosMonkey.killJetty(leaderJetty);- Thread.sleep(3000);-- waitForThingsToLevelOut(120);-- Thread.sleep(2000);-- waitForRecoveriesToFinish(false);+ waitForNoShardInconsistency();checkShardConsistency(true, true);success = true;}- private void waitTillRecovered() throws Exception {+ private void waitTillAllNodesActive() throws Exception {for (int i = 0; i < 60; i++) {Thread.sleep(3000);ZkStateReader zkStateReader = cloudClient.getZkStateReader();@@ -264,7 +258,7 @@ public class SyncSliceTest extends AbstractFullDistribZkTestBase {}}printLayout();- fail("timeout waiting to see recovered node");+ fail("timeout waiting to see all nodes active");}private String waitTillInconsistent() throws Exception, InterruptedException {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.javaindex 6fbd5c41d8a..50a650cf5f1 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@@ -1510,7 +1510,43 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes}if (failMessage != null) {- retry = true;+ log.info("shard inconsistency - waiting ...");+ retry = true;+ } else {+ retry = false;+ }+ cnt++;+ if (cnt > 20) break;+ Thread.sleep(2000);+ } while (retry);+ }+++ public void waitForNoShardInconsistency() throws Exception {+ log.info("Wait for no shard inconsistency");+ int cnt = 0;+ boolean retry = false;+ do {+ try {+ commit();+ } catch (Throwable t) {+ t.printStackTrace();+ // we don't care if this commit fails on some nodes+ }++ updateMappingsFromZk(jettys, clients);++ Set<String> theShards = shardToJetty.keySet();+ String failMessage = null;+ for (String shard : theShards) {+ failMessage = checkShardConsistency(shard, true, false);+ }++ if (failMessage != null) {+ log.info("shard inconsistency - waiting ...");+ retry = true;+ } else {+ retry = false;}cnt++;if (cnt > 20) break;