SOLR-4923: do not test if not sending to leaders first

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1493861 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2013-06-17 17:58:07 +00:00
parent 4f05d88704
commit 6b06ac1026
2 changed files with 34 additions and 26 deletions

View File

@ -355,6 +355,10 @@ public class CloudSolrServer extends SolrServer {
public LBHttpSolrServer getLbServer() {
return lbServer;
}
public boolean isUpdatesToLeaders() {
return updatesToLeaders;
}
// for tests
Map<String,List<String>> getUrlLists() {

View File

@ -102,35 +102,39 @@ public class CloudSolrServerTest extends AbstractFullDistribZkTestBase {
indexr(id, 0, "a_t", "to come to the aid of their country.");
// compare leaders list
CloudJettyRunner shard1Leader = shardToLeaderJetty.get("shard1");
CloudJettyRunner shard2Leader = shardToLeaderJetty.get("shard2");
assertEquals(2, cloudClient.getLeaderUrlLists().get("collection1").size());
HashSet<String> leaderUrlSet = new HashSet<String>();
leaderUrlSet.addAll(cloudClient.getLeaderUrlLists().get("collection1"));
assertTrue("fail check for leader:" + shard1Leader.url + " in "
+ leaderUrlSet, leaderUrlSet.contains(shard1Leader.url + "/"));
assertTrue("fail check for leader:" + shard2Leader.url + " in "
+ leaderUrlSet, leaderUrlSet.contains(shard2Leader.url + "/"));
// compare replicas list
Set<String> replicas = new HashSet<String>();
List<CloudJettyRunner> jetties = shardToJetty.get("shard1");
for (CloudJettyRunner cjetty : jetties) {
replicas.add(cjetty.url);
}
jetties = shardToJetty.get("shard2");
for (CloudJettyRunner cjetty : jetties) {
replicas.add(cjetty.url);
}
replicas.remove(shard1Leader.url);
replicas.remove(shard2Leader.url);
assertEquals(replicas.size(), cloudClient.getReplicasLists().get("collection1").size());
for (String url : cloudClient.getReplicasLists().get("collection1")) {
assertTrue("fail check for replica:" + url + " in " + replicas,
replicas.contains(stripTrailingSlash(url)));
if (cloudClient.isUpdatesToLeaders()) {
// compare leaders list
assertEquals(2, cloudClient.getLeaderUrlLists().get("collection1").size());
HashSet<String> leaderUrlSet = new HashSet<String>();
leaderUrlSet.addAll(cloudClient.getLeaderUrlLists().get("collection1"));
assertTrue("fail check for leader:" + shard1Leader.url + " in "
+ leaderUrlSet, leaderUrlSet.contains(shard1Leader.url + "/"));
assertTrue("fail check for leader:" + shard2Leader.url + " in "
+ leaderUrlSet, leaderUrlSet.contains(shard2Leader.url + "/"));
// compare replicas list
Set<String> replicas = new HashSet<String>();
List<CloudJettyRunner> jetties = shardToJetty.get("shard1");
for (CloudJettyRunner cjetty : jetties) {
replicas.add(cjetty.url);
}
jetties = shardToJetty.get("shard2");
for (CloudJettyRunner cjetty : jetties) {
replicas.add(cjetty.url);
}
replicas.remove(shard1Leader.url);
replicas.remove(shard2Leader.url);
assertEquals(replicas.size(),
cloudClient.getReplicasLists().get("collection1").size());
for (String url : cloudClient.getReplicasLists().get("collection1")) {
assertTrue("fail check for replica:" + url + " in " + replicas,
replicas.contains(stripTrailingSlash(url)));
}
}
}