You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2012/04/24 17:05:36 UTC
svn commit: r1329775 -
/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java
Author: siren
Date: Tue Apr 24 15:05:35 2012
New Revision: 1329775
URL: http://svn.apache.org/viewvc?rev=1329775&view=rev
Log:
SOLR-3354: the corecontainer sometimes fail to start (#cores==0), check that everything is correctly set up before going to actual tests or fail fast
Modified:
lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java?rev=1329775&r1=1329774&r2=1329775&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java Tue Apr 24 15:05:35 2012
@@ -21,6 +21,7 @@ import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
@@ -94,20 +95,43 @@ public class LeaderElectionIntegrationTe
System.setProperty("solr.test.sys.prop2", "proptwo");
for (int i = 7000; i < 7000 + NUM_SHARD_REPLICAS; i++) {
- setupContainer(i, "shard1");
+ try {
+ setupContainer(i, "shard1");
+ } catch (Throwable t) {
+ log.error("!!!Could not start container:" + i + " The exception thrown was: " + t.getClass() + " " + t.getMessage());
+ fail("Could not start container:" + i + ". Reason:" + t.getClass() + " " + t.getMessage());
+ }
+ }
+ try {
+ setupContainer(3333, "shard2");
+ } catch (Throwable t) {
+ log.error("!!!Could not start container 3333. The exception thrown was: " + t.getClass() + " " + t.getMessage());
+ fail("Could not start container: 3333");
}
-
- setupContainer(3333, "shard2");
zkClient = new SolrZkClient(zkServer.getZkAddress(),
AbstractZkTestCase.TIMEOUT);
-
+
reader = new ZkStateReader(zkClient);
reader.createClusterStateWatchersAndUpdate();
+ boolean initSuccessful = false;
+ for (int i = 0; i < 30; i++) {
+ List<String> liveNodes = zkClient.getChildren("/live_nodes", null, true);
+ if (liveNodes.size() == NUM_SHARD_REPLICAS + 1) {
+ // all nodes up
+ initSuccessful = true;
+ break;
+ }
+ Thread.sleep(1000);
+ log.info("Waiting for more nodes to come up, now: " + liveNodes.size()
+ + "/" + (NUM_SHARD_REPLICAS + 1));
+ }
+ if (!initSuccessful) {
+ fail("Init was not successful!");
+ }
log.info("####SETUP_END " + getName());
-
}
-
+
private void setupContainer(int port, String shard) throws IOException,
ParserConfigurationException, SAXException {
File data = new File(dataDir + File.separator + "data_" + port);
@@ -125,6 +149,8 @@ public class LeaderElectionIntegrationTe
}
ports.add(port);
CoreContainer container = init.initialize();
+ assertTrue("Container " + port + " has no cores!", container.getCores()
+ .size() > 0);
containerMap.put(port, container);
System.clearProperty("solr.solr.home");
System.clearProperty("hostPort");
@@ -171,6 +197,7 @@ public class LeaderElectionIntegrationTe
}
if (leaderPort == newLeaderPort) {
+ zkClient.printLayoutToStdOut();
fail("We didn't find a new leader! " + leaderPort + " was shutdown, but it's still showing as the leader");
}