19
19
20
20
package org .elasticsearch .bwcompat ;
21
21
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 ;
25
23
import org .elasticsearch .common .settings .ImmutableSettings ;
26
24
import org .elasticsearch .common .settings .Settings ;
27
25
import org .elasticsearch .test .ElasticsearchBackwardsCompatIntegrationTest ;
@@ -36,37 +34,24 @@ protected Settings nodeSettings(int nodeOrdinal) {
36
34
return ImmutableSettings .builder ()
37
35
.put ("transport.tcp.port" , 9380 + nodeOrdinal )
38
36
.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 " )
40
38
.put (super .nodeSettings (nodeOrdinal ))
41
39
.build ();
42
40
}
43
41
44
42
@ Override
45
43
protected Settings externalNodeSettings (int nodeOrdinal ) {
46
44
return ImmutableSettings .settingsBuilder ()
47
- .put ("discovery.zen.ping.multicast.enabled" , false )
48
45
.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" )
50
48
.put (super .nodeSettings (nodeOrdinal ))
51
49
.build ();
52
50
}
53
51
54
52
@ Test
55
53
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 ()));
71
56
}
72
57
}
0 commit comments