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