31
31
import org .elasticsearch .cluster .metadata .IndexMetaData ;
32
32
import org .elasticsearch .cluster .routing .RoutingNode ;
33
33
import org .elasticsearch .cluster .routing .allocation .DiskThresholdSettings ;
34
+ import org .elasticsearch .common .Priority ;
34
35
import org .elasticsearch .common .settings .Settings ;
35
36
import org .elasticsearch .common .unit .TimeValue ;
36
37
import org .elasticsearch .common .xcontent .XContentType ;
41
42
import java .util .Collection ;
42
43
import java .util .Collections ;
43
44
import java .util .HashMap ;
44
- import java .util .Iterator ;
45
45
import java .util .List ;
46
46
import java .util .Map ;
47
47
48
+ import static org .elasticsearch .test .hamcrest .ElasticsearchAssertions .assertBlocked ;
49
+ import static org .elasticsearch .test .hamcrest .ElasticsearchAssertions .assertSearchHits ;
48
50
import static org .hamcrest .Matchers .equalTo ;
49
51
import static org .hamcrest .Matchers .greaterThan ;
50
52
import static org .hamcrest .Matchers .greaterThanOrEqualTo ;
51
- import static org .elasticsearch .test .hamcrest .ElasticsearchAssertions .assertBlocked ;
52
- import static org .elasticsearch .test .hamcrest .ElasticsearchAssertions .assertSearchHits ;
53
53
54
54
@ ESIntegTestCase .ClusterScope (scope = ESIntegTestCase .Scope .TEST , numDataNodes = 0 )
55
55
public class MockDiskUsagesIT extends ESIntegTestCase {
@@ -143,7 +143,6 @@ public void testRerouteOccursOnDiskPassingHighWatermark() throws Exception {
143
143
});
144
144
}
145
145
146
- @ AwaitsFix (bugUrl = "https://github.com/elastic/elasticsearch/issues/45338" )
147
146
public void testAutomaticReleaseOfIndexBlock () throws Exception {
148
147
List <String > nodes = internalCluster ().startNodes (3 );
149
148
@@ -185,9 +184,7 @@ public void testAutomaticReleaseOfIndexBlock() throws Exception {
185
184
186
185
final List <String > realNodeNames = new ArrayList <>();
187
186
ClusterStateResponse resp = client ().admin ().cluster ().prepareState ().get ();
188
- Iterator <RoutingNode > iter = resp .getState ().getRoutingNodes ().iterator ();
189
- while (iter .hasNext ()) {
190
- RoutingNode node = iter .next ();
187
+ for (RoutingNode node : resp .getState ().getRoutingNodes ()) {
191
188
realNodeNames .add (node .nodeId ());
192
189
logger .info ("--> node {} has {} shards" ,
193
190
node .nodeId (), resp .getState ().getRoutingNodes ().node (node .nodeId ()).numberOfOwningShards ());
@@ -203,10 +200,10 @@ public void testAutomaticReleaseOfIndexBlock() throws Exception {
203
200
cis .setN3Usage (realNodeNames .get (2 ), new DiskUsage (nodes .get (2 ), "n3" , "_na_" , 100 , 3 ));
204
201
205
202
// Wait until index "test" is blocked
206
- assertBusy (() -> {
207
- assertBlocked ( client (). prepareIndex (). setIndex ( "test" ). setType ( "doc" ). setId ( "1" ). setSource ( "foo" , "bar" ),
208
- IndexMetaData . INDEX_READ_ONLY_ALLOW_DELETE_BLOCK );
209
- } );
203
+ assertBusy (() -> assertBlocked ( client (). prepareIndex (). setIndex ( "test" ). setType ( "doc" ). setId ( "1" ). setSource ( "foo" , "bar" ),
204
+ IndexMetaData . INDEX_READ_ONLY_ALLOW_DELETE_BLOCK ));
205
+
206
+ assertFalse ( client (). admin (). cluster (). prepareHealth ( "test" ). setWaitForEvents ( Priority . LANGUID ). get (). isTimedOut () );
210
207
211
208
// Cannot add further documents
212
209
assertBlocked (client ().prepareIndex ().setIndex ("test" ).setType ("doc" ).setId ("2" ).setSource ("foo" , "bar" ),
0 commit comments