46
46
import org .elasticsearch .xpack .core .XPackSettings ;
47
47
48
48
import java .io .IOException ;
49
- import java .io .UncheckedIOException ;
50
49
import java .util .Arrays ;
51
50
import java .util .Collection ;
52
51
import java .util .Collections ;
@@ -337,26 +336,12 @@ public void testFollowIndexAndCloseNode() throws Exception {
337
336
ShardFollowNodeTask .DEFAULT_MAX_WRITE_BUFFER_SIZE , TimeValue .timeValueMillis (500 ), TimeValue .timeValueMillis (10 ));
338
337
client ().execute (FollowIndexAction .INSTANCE , followRequest ).get ();
339
338
340
- long maxNumDocsReplicated = Math .min (3000 , randomLongBetween (followRequest .getMaxBatchOperationCount (),
339
+ long maxNumDocsReplicated = Math .min (1000 , randomLongBetween (followRequest .getMaxBatchOperationCount (),
341
340
followRequest .getMaxBatchOperationCount () * 10 ));
342
341
long minNumDocsReplicated = maxNumDocsReplicated / 3L ;
343
342
logger .info ("waiting for at least [{}] documents to be indexed and then stop a random data node" , minNumDocsReplicated );
344
- awaitBusy (() -> {
345
- SearchRequest request = new SearchRequest ("index2" );
346
- request .source (new SearchSourceBuilder ().size (0 ));
347
- SearchResponse response = client ().search (request ).actionGet ();
348
- if (response .getHits ().getTotalHits () >= minNumDocsReplicated ) {
349
- try {
350
- internalCluster ().stopRandomNonMasterNode ();
351
- } catch (IOException e ) {
352
- throw new UncheckedIOException (e );
353
- }
354
- return true ;
355
- } else {
356
- return false ;
357
- }
358
- }, 30 , TimeUnit .SECONDS );
359
-
343
+ atLeastDocsIndexed ("index2" , minNumDocsReplicated );
344
+ internalCluster ().stopRandomNonMasterNode ();
360
345
logger .info ("waiting for at least [{}] documents to be indexed" , maxNumDocsReplicated );
361
346
atLeastDocsIndexed ("index2" , maxNumDocsReplicated );
362
347
run .set (false );
@@ -546,7 +531,7 @@ private void unfollowIndex(String index) throws Exception {
546
531
}
547
532
}
548
533
assertThat (numNodeTasks , equalTo (0 ));
549
- });
534
+ }, 30 , TimeUnit . SECONDS );
550
535
}
551
536
552
537
private CheckedRunnable <Exception > assertExpectedDocumentRunnable (final int value ) {
@@ -658,7 +643,7 @@ private void atLeastDocsIndexed(String index, long numDocsReplicated) throws Int
658
643
request .source (new SearchSourceBuilder ().size (0 ));
659
644
SearchResponse response = client ().search (request ).actionGet ();
660
645
return response .getHits ().getTotalHits () >= numDocsReplicated ;
661
- }, 30 , TimeUnit .SECONDS );
646
+ }, 60 , TimeUnit .SECONDS );
662
647
}
663
648
664
649
private void assertSameDocCount (String index1 , String index2 ) throws Exception {
@@ -672,7 +657,7 @@ private void assertSameDocCount(String index1, String index2) throws Exception {
672
657
request2 .source (new SearchSourceBuilder ().size (0 ));
673
658
SearchResponse response2 = client ().search (request2 ).actionGet ();
674
659
assertThat (response2 .getHits ().getTotalHits (), equalTo (response1 .getHits ().getTotalHits ()));
675
- });
660
+ }, 60 , TimeUnit . SECONDS );
676
661
}
677
662
678
663
public static FollowIndexAction .Request createFollowRequest (String leaderIndex , String followIndex ) {
0 commit comments