@@ -564,7 +564,7 @@ public void testCloseLeaderIndex() throws Exception {
564564 client ().execute (CreateAndFollowIndexAction .INSTANCE , createAndFollowRequest ).get ();
565565
566566 client ().prepareIndex ("index1" , "doc" , "1" ).setSource ("{}" , XContentType .JSON ).get ();
567- atLeastDocsIndexed ( "index2" , 1L );
567+ assertBusy (() -> assertThat ( client (). prepareSearch ( "index2" ). get (). getHits (). totalHits , equalTo ( 1L )) );
568568
569569 client ().admin ().indices ().close (new CloseIndexRequest ("index1" )).actionGet ();
570570 assertBusy (() -> {
@@ -581,7 +581,7 @@ public void testCloseLeaderIndex() throws Exception {
581581
582582 client ().admin ().indices ().open (new OpenIndexRequest ("index1" )).actionGet ();
583583 client ().prepareIndex ("index1" , "doc" , "2" ).setSource ("{}" , XContentType .JSON ).get ();
584- atLeastDocsIndexed ( "index2" , 2L );
584+ assertBusy (() -> assertThat ( client (). prepareSearch ( "index2" ). get (). getHits (). totalHits , equalTo ( 2L )) );
585585
586586 unfollowIndex ("index2" );
587587 }
@@ -599,7 +599,7 @@ public void testCloseFollowIndex() throws Exception {
599599 client ().execute (CreateAndFollowIndexAction .INSTANCE , createAndFollowRequest ).get ();
600600
601601 client ().prepareIndex ("index1" , "doc" , "1" ).setSource ("{}" , XContentType .JSON ).get ();
602- atLeastDocsIndexed ( "index2" , 1L );
602+ assertBusy (() -> assertThat ( client (). prepareSearch ( "index2" ). get (). getHits (). totalHits , equalTo ( 1L )) );
603603
604604 client ().admin ().indices ().close (new CloseIndexRequest ("index2" )).actionGet ();
605605 client ().prepareIndex ("index1" , "doc" , "2" ).setSource ("{}" , XContentType .JSON ).get ();
@@ -611,7 +611,7 @@ public void testCloseFollowIndex() throws Exception {
611611 assertThat (response .getStatsResponses ().get (0 ).status ().numberOfFailedBulkOperations (), greaterThanOrEqualTo (1L ));
612612 });
613613 client ().admin ().indices ().open (new OpenIndexRequest ("index2" )).actionGet ();
614- atLeastDocsIndexed ( "index2" , 2L );
614+ assertBusy (() -> assertThat ( client (). prepareSearch ( "index2" ). get (). getHits (). totalHits , equalTo ( 2L )) );
615615
616616 unfollowIndex ("index2" );
617617 }
@@ -629,7 +629,7 @@ public void testDeleteLeaderIndex() throws Exception {
629629 client ().execute (CreateAndFollowIndexAction .INSTANCE , createAndFollowRequest ).get ();
630630
631631 client ().prepareIndex ("index1" , "doc" , "1" ).setSource ("{}" , XContentType .JSON ).get ();
632- atLeastDocsIndexed ( "index2" , 1L );
632+ assertBusy (() -> assertThat ( client (). prepareSearch ( "index2" ). get (). getHits (). totalHits , equalTo ( 1L )) );
633633
634634 client ().admin ().indices ().delete (new DeleteIndexRequest ("index1" )).actionGet ();
635635 ensureNoCcrTasks ();
@@ -648,7 +648,7 @@ public void testDeleteFollowerIndex() throws Exception {
648648 client ().execute (CreateAndFollowIndexAction .INSTANCE , createAndFollowRequest ).get ();
649649
650650 client ().prepareIndex ("index1" , "doc" , "1" ).setSource ("{}" , XContentType .JSON ).get ();
651- atLeastDocsIndexed ( "index2" , 1L );
651+ assertBusy (() -> assertThat ( client (). prepareSearch ( "index2" ). get (). getHits (). totalHits , equalTo ( 1L )) );
652652
653653 client ().admin ().indices ().delete (new DeleteIndexRequest ("index2" )).actionGet ();
654654 client ().prepareIndex ("index1" , "doc" , "2" ).setSource ("{}" , XContentType .JSON ).get ();
0 commit comments