mirror of https://github.com/apache/lucene.git
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
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1329775 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
03bf368edd
commit
6f43ebfd90
|
@ -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 LeaderElectionIntegrationTest extends SolrTestCaseJ4 {
|
|||
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 LeaderElectionIntegrationTest extends SolrTestCaseJ4 {
|
|||
}
|
||||
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 LeaderElectionIntegrationTest extends SolrTestCaseJ4 {
|
|||
}
|
||||
|
||||
if (leaderPort == newLeaderPort) {
|
||||
zkClient.printLayoutToStdOut();
|
||||
fail("We didn't find a new leader! " + leaderPort + " was shutdown, but it's still showing as the leader");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue