3232import java .util .HashMap ;
3333import java .util .List ;
3434import java .util .Map ;
35+ import java .util .Objects ;
3536
3637import static org .elasticsearch .cluster .block .ClusterBlocks .EMPTY_CLUSTER_BLOCK ;
3738import static org .elasticsearch .test .ClusterServiceUtils .setState ;
3839import static org .elasticsearch .test .hamcrest .ElasticsearchAssertions .assertHitCount ;
40+ import static org .elasticsearch .test .hamcrest .ElasticsearchAssertions .assertResponse ;
3941
4042public class SearchWithIndexBlocksIT extends ESIntegTestCase {
4143
@@ -52,7 +54,7 @@ public void testSearchIndicesWithIndexRefreshBlocks() {
5254 assertHitCount (prepareSearch ().setQuery (QueryBuilders .matchAllQuery ()), expectedHits );
5355 }
5456
55- public void testOpenPITWithIndexRefreshBlock () {
57+ public void testOpenPITOnIndicesWithIndexRefreshBlocks () {
5658 List <String > indices = createIndices ();
5759 Map <String , Integer > numDocsPerIndex = indexDocuments (indices );
5860 List <String > unblockedIndices = addIndexRefreshBlockToSomeIndices (indices );
@@ -79,6 +81,28 @@ public void testOpenPITWithIndexRefreshBlock() {
7981 }
8082 }
8183
84+ public void testMultiSearchIndicesWithIndexRefreshBlocks () {
85+ List <String > indices = createIndices ();
86+ Map <String , Integer > numDocsPerIndex = indexDocuments (indices );
87+ List <String > unblockedIndices = addIndexRefreshBlockToSomeIndices (indices );
88+
89+ int expectedHits = 0 ;
90+ for (String index : unblockedIndices ) {
91+ expectedHits += numDocsPerIndex .get (index );
92+ }
93+
94+ final long expectedHitsL = expectedHits ;
95+ assertResponse (
96+ client ().prepareMultiSearch ()
97+ .add (prepareSearch ().setQuery (QueryBuilders .matchAllQuery ()))
98+ .add (prepareSearch ().setQuery (QueryBuilders .termQuery ("field" , "blah" ))),
99+ response -> {
100+ assertHitCount (Objects .requireNonNull (response .getResponses ()[0 ].getResponse ()), expectedHitsL );
101+ assertHitCount (Objects .requireNonNull (response .getResponses ()[1 ].getResponse ()), 0 );
102+ }
103+ );
104+ }
105+
82106 private List <String > createIndices () {
83107 int numIndices = randomIntBetween (1 , 3 );
84108 List <String > indices = new ArrayList <>();
0 commit comments