19
19
20
20
package org .elasticsearch .cluster .routing .allocation .decider ;
21
21
22
+ import org .elasticsearch .action .admin .indices .recovery .RecoveryResponse ;
22
23
import org .elasticsearch .cluster .ClusterInfo ;
23
24
import org .elasticsearch .cluster .ClusterInfoService ;
24
25
import org .elasticsearch .cluster .ClusterState ;
30
31
import org .elasticsearch .common .unit .TimeValue ;
31
32
import org .elasticsearch .plugins .Plugin ;
32
33
import org .elasticsearch .test .ESIntegTestCase ;
34
+ import org .elasticsearch .test .junit .annotations .TestLogging ;
33
35
34
36
import java .util .ArrayList ;
35
37
import java .util .Collection ;
@@ -51,6 +53,7 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
51
53
return Collections .singletonList (MockInternalClusterInfoService .TestPlugin .class );
52
54
}
53
55
56
+ @ TestLogging ("org.elasticsearch.indices.recovery:TRACE" )
54
57
public void testRerouteOccursOnDiskPassingHighWatermark () throws Exception {
55
58
List <String > nodes = internalCluster ().startNodes (3 );
56
59
@@ -98,10 +101,16 @@ public void testRerouteOccursOnDiskPassingHighWatermark() throws Exception {
98
101
cis .setN2Usage (realNodeNames .get (1 ), new DiskUsage (nodes .get (1 ), "n2" , "_na_" , 100 , 50 ));
99
102
cis .setN3Usage (realNodeNames .get (2 ), new DiskUsage (nodes .get (2 ), "n3" , "_na_" , 100 , 0 )); // nothing free on node3
100
103
104
+ logger .info ("--> waiting for shards to relocate off node [{}]" , realNodeNames .get (2 ));
105
+
101
106
assertBusy (() -> {
102
107
final ClusterState clusterState = client ().admin ().cluster ().prepareState ().get ().getState ();
103
108
logger .info ("--> {}" , clusterState .routingTable ());
104
109
110
+ final RecoveryResponse recoveryResponse = client ().admin ().indices ()
111
+ .prepareRecoveries ("test" ).setActiveOnly (true ).setDetailed (true ).get ();
112
+ logger .info ("--> recoveries: {}" , recoveryResponse );
113
+
105
114
final Map <String , Integer > nodesToShardCount = new HashMap <>();
106
115
for (final RoutingNode node : clusterState .getRoutingNodes ()) {
107
116
logger .info ("--> node {} has {} shards" ,
@@ -118,6 +127,8 @@ public void testRerouteOccursOnDiskPassingHighWatermark() throws Exception {
118
127
cis .setN2Usage (realNodeNames .get (1 ), new DiskUsage (nodes .get (1 ), "n2" , "_na_" , 100 , 50 ));
119
128
cis .setN3Usage (realNodeNames .get (2 ), new DiskUsage (nodes .get (2 ), "n3" , "_na_" , 100 , 50 )); // node3 has free space now
120
129
130
+ logger .info ("--> waiting for shards to rebalance back onto node [{}]" , realNodeNames .get (2 ));
131
+
121
132
assertBusy (() -> {
122
133
final Map <String , Integer > nodesToShardCount = new HashMap <>();
123
134
final ClusterState clusterState = client ().admin ().cluster ().prepareState ().get ().getState ();
0 commit comments