[TEST} make sure unicast bw comp test uses specifically set transport port and properly configure unicast hosts

Added also assertBusy block needed since we test the local cluster state on each node, not only on the master node.
This commit is contained in:
javanna 2014-08-05 11:46:33 +02:00 committed by Luca Cavanna
parent 9c89fcf5a2
commit c788a5e67b
1 changed files with 19 additions and 12 deletions

View File

@ -34,8 +34,9 @@ public class UnicastBackwardsCompatibilityTest extends ElasticsearchBackwardsCom
@Override
protected Settings nodeSettings(int nodeOrdinal) {
return ImmutableSettings.builder()
.put("transport.tcp.port", 9380 + nodeOrdinal)
.put("discovery.zen.ping.multicast.enabled", false)
.put("discovery.zen.ping.unicast.hosts", "localhost")
.put("discovery.zen.ping.unicast.hosts", "localhost:9390")
.put(super.nodeSettings(nodeOrdinal))
.build();
}
@ -44,22 +45,28 @@ public class UnicastBackwardsCompatibilityTest extends ElasticsearchBackwardsCom
protected Settings externalNodeSettings(int nodeOrdinal) {
return ImmutableSettings.settingsBuilder()
.put("discovery.zen.ping.multicast.enabled", false)
.put("discovery.zen.ping.unicast.hosts", "localhost")
.put("transport.tcp.port", 9390 + nodeOrdinal)
.put("discovery.zen.ping.unicast.hosts", "localhost:9380")
.put(super.nodeSettings(nodeOrdinal))
.build();
}
@Test
public void testUnicastDiscovery() {
for (Client client : clients()) {
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()));
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()));
}
});
}
}
}