Skip to content

Commit 61d40c4

Browse files
committed
Add _msearch test case
1 parent d72600b commit 61d40c4

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

server/src/internalClusterTest/java/org/elasticsearch/search/SearchWithIndexBlocksIT.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@
3232
import java.util.HashMap;
3333
import java.util.List;
3434
import java.util.Map;
35+
import java.util.Objects;
3536

3637
import static org.elasticsearch.cluster.block.ClusterBlocks.EMPTY_CLUSTER_BLOCK;
3738
import static org.elasticsearch.test.ClusterServiceUtils.setState;
3839
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
40+
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertResponse;
3941

4042
public 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

Comments
 (0)