浏览代码

[TEST] simplified unicast bw comp test

also fixed unchecked warning in CompositeTestCluster
javanna 11 年之前
父节点
当前提交
6f09eb1b06

+ 6 - 21
src/test/java/org/elasticsearch/bwcompat/UnicastBackwardsCompatibilityTest.java

@@ -19,9 +19,7 @@
 
 package org.elasticsearch.bwcompat;
 
-import org.elasticsearch.client.Client;
-import org.elasticsearch.cluster.ClusterState;
-import org.elasticsearch.cluster.node.DiscoveryNode;
+import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
 import org.elasticsearch.common.settings.ImmutableSettings;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.test.ElasticsearchBackwardsCompatIntegrationTest;
@@ -36,7 +34,7 @@ public class UnicastBackwardsCompatibilityTest extends ElasticsearchBackwardsCom
         return ImmutableSettings.builder()
                 .put("transport.tcp.port", 9380 + nodeOrdinal)
                 .put("discovery.zen.ping.multicast.enabled", false)
-                .put("discovery.zen.ping.unicast.hosts", "localhost:9390")
+                .put("discovery.zen.ping.unicast.hosts", "localhost:9390,localhost:9391")
                 .put(super.nodeSettings(nodeOrdinal))
                 .build();
     }
@@ -44,29 +42,16 @@ public class UnicastBackwardsCompatibilityTest extends ElasticsearchBackwardsCom
     @Override
     protected Settings externalNodeSettings(int nodeOrdinal) {
         return ImmutableSettings.settingsBuilder()
-                .put("discovery.zen.ping.multicast.enabled", false)
                 .put("transport.tcp.port", 9390 + nodeOrdinal)
-                .put("discovery.zen.ping.unicast.hosts", "localhost:9380")
+                .put("discovery.zen.ping.multicast.enabled", false)
+                .put("discovery.zen.ping.unicast.hosts", "localhost:9380,localhost:9381")
                 .put(super.nodeSettings(nodeOrdinal))
                 .build();
     }
 
     @Test
     public void testUnicastDiscovery() throws Exception {
-        for (final Client client : clients()) {
-            assertBusy(new Runnable() {
-                           @Override
-                           public void run() {
-                               ClusterState state = client.admin().cluster().prepareState().setLocal(true).get().getState();
-                               int dataNodes = 0;
-                               for (DiscoveryNode discoveryNode : state.nodes()) {
-                                   if (discoveryNode.isDataNode()) {
-                                       dataNodes++;
-                                   }
-                               }
-                               assertThat(dataNodes, equalTo(cluster().numDataNodes()));
-                           }
-                       });
-        }
+        ClusterHealthResponse healthResponse = client().admin().cluster().prepareHealth().get();
+        assertThat(healthResponse.getNumberOfDataNodes(), equalTo(cluster().numDataNodes()));
     }
 }

+ 1 - 1
src/test/java/org/elasticsearch/test/CompositeTestCluster.java

@@ -18,10 +18,10 @@
  */
 package org.elasticsearch.test;
 
-import com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.collect.Iterators;
 import com.carrotsearch.randomizedtesting.generators.RandomPicks;
 import com.google.common.base.Predicate;
 import com.google.common.collect.Collections2;
+import com.google.common.collect.Iterators;
 import org.apache.lucene.util.IOUtils;
 import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
 import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;