Skip to content

Commit 5710c22

Browse files
javannaareek
authored andcommitted
[TEST] simplified unicast bw comp test
also fixed unchecked warning in CompositeTestCluster
1 parent 4cddef2 commit 5710c22

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

src/test/java/org/elasticsearch/bwcompat/UnicastBackwardsCompatibilityTest.java

+6-21
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919

2020
package org.elasticsearch.bwcompat;
2121

22-
import org.elasticsearch.client.Client;
23-
import org.elasticsearch.cluster.ClusterState;
24-
import org.elasticsearch.cluster.node.DiscoveryNode;
22+
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
2523
import org.elasticsearch.common.settings.ImmutableSettings;
2624
import org.elasticsearch.common.settings.Settings;
2725
import org.elasticsearch.test.ElasticsearchBackwardsCompatIntegrationTest;
@@ -36,37 +34,24 @@ protected Settings nodeSettings(int nodeOrdinal) {
3634
return ImmutableSettings.builder()
3735
.put("transport.tcp.port", 9380 + nodeOrdinal)
3836
.put("discovery.zen.ping.multicast.enabled", false)
39-
.put("discovery.zen.ping.unicast.hosts", "localhost:9390")
37+
.put("discovery.zen.ping.unicast.hosts", "localhost:9390,localhost:9391")
4038
.put(super.nodeSettings(nodeOrdinal))
4139
.build();
4240
}
4341

4442
@Override
4543
protected Settings externalNodeSettings(int nodeOrdinal) {
4644
return ImmutableSettings.settingsBuilder()
47-
.put("discovery.zen.ping.multicast.enabled", false)
4845
.put("transport.tcp.port", 9390 + nodeOrdinal)
49-
.put("discovery.zen.ping.unicast.hosts", "localhost:9380")
46+
.put("discovery.zen.ping.multicast.enabled", false)
47+
.put("discovery.zen.ping.unicast.hosts", "localhost:9380,localhost:9381")
5048
.put(super.nodeSettings(nodeOrdinal))
5149
.build();
5250
}
5351

5452
@Test
5553
public void testUnicastDiscovery() throws Exception {
56-
for (final Client client : clients()) {
57-
assertBusy(new Runnable() {
58-
@Override
59-
public void run() {
60-
ClusterState state = client.admin().cluster().prepareState().setLocal(true).get().getState();
61-
int dataNodes = 0;
62-
for (DiscoveryNode discoveryNode : state.nodes()) {
63-
if (discoveryNode.isDataNode()) {
64-
dataNodes++;
65-
}
66-
}
67-
assertThat(dataNodes, equalTo(cluster().numDataNodes()));
68-
}
69-
});
70-
}
54+
ClusterHealthResponse healthResponse = client().admin().cluster().prepareHealth().get();
55+
assertThat(healthResponse.getNumberOfDataNodes(), equalTo(cluster().numDataNodes()));
7156
}
7257
}

src/test/java/org/elasticsearch/test/CompositeTestCluster.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
*/
1919
package org.elasticsearch.test;
2020

21-
import com.carrotsearch.ant.tasks.junit4.dependencies.com.google.common.collect.Iterators;
2221
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
2322
import com.google.common.base.Predicate;
2423
import com.google.common.collect.Collections2;
24+
import com.google.common.collect.Iterators;
2525
import org.apache.lucene.util.IOUtils;
2626
import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
2727
import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;

0 commit comments

Comments
 (0)