Skip to content

Commit e10d59b

Browse files
committed
Add search shards test
1 parent b33a14f commit e10d59b

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@
99

1010
package org.elasticsearch.search;
1111

12+
import com.carrotsearch.randomizedtesting.annotations.Repeat;
13+
1214
import org.elasticsearch.action.index.IndexRequestBuilder;
1315
import org.elasticsearch.action.search.ClosePointInTimeRequest;
1416
import org.elasticsearch.action.search.OpenPointInTimeRequest;
1517
import org.elasticsearch.action.search.SearchRequest;
18+
import org.elasticsearch.action.search.SearchShardsGroup;
19+
import org.elasticsearch.action.search.SearchShardsRequest;
1620
import org.elasticsearch.action.search.TransportClosePointInTimeAction;
1721
import org.elasticsearch.action.search.TransportOpenPointInTimeAction;
22+
import org.elasticsearch.action.search.TransportSearchShardsAction;
23+
import org.elasticsearch.action.support.IndicesOptions;
1824
import org.elasticsearch.cluster.ClusterState;
1925
import org.elasticsearch.cluster.block.ClusterBlocks;
2026
import org.elasticsearch.cluster.metadata.IndexMetadata;
@@ -23,6 +29,7 @@
2329
import org.elasticsearch.cluster.service.ClusterService;
2430
import org.elasticsearch.common.bytes.BytesReference;
2531
import org.elasticsearch.core.TimeValue;
32+
import org.elasticsearch.index.query.MatchAllQueryBuilder;
2633
import org.elasticsearch.index.query.QueryBuilders;
2734
import org.elasticsearch.search.builder.PointInTimeBuilder;
2835
import org.elasticsearch.search.builder.SearchSourceBuilder;
@@ -103,6 +110,29 @@ public void testMultiSearchIndicesWithIndexRefreshBlocks() {
103110
);
104111
}
105112

113+
@Repeat(iterations = 100)
114+
public void testSearchShardsOnIndicesWithIndexRefreshBlocks() {
115+
List<String> indices = createIndices();
116+
indexDocuments(indices);
117+
List<String> unblockedIndices = addIndexRefreshBlockToSomeIndices(indices);
118+
119+
var resp = client().execute(
120+
TransportSearchShardsAction.TYPE,
121+
new SearchShardsRequest(
122+
indices.toArray(new String[0]),
123+
IndicesOptions.DEFAULT,
124+
new MatchAllQueryBuilder(),
125+
null,
126+
null,
127+
true,
128+
null
129+
)
130+
).actionGet();
131+
for (SearchShardsGroup group : resp.getGroups()) {
132+
assertTrue(unblockedIndices.contains(group.shardId().getIndex().getName()));
133+
}
134+
}
135+
106136
private List<String> createIndices() {
107137
int numIndices = randomIntBetween(1, 3);
108138
List<String> indices = new ArrayList<>();

server/src/test/java/org/elasticsearch/action/search/TransportSearchActionTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1813,7 +1813,7 @@ public void onFailure(Exception ex) {
18131813
}
18141814
}
18151815

1816-
public void testIgnoreBlockedIndices() {
1816+
public void testIgnoreIndicesWithIndexRefreshBlock() {
18171817
int numIndices = randomIntBetween(1, 10);
18181818
String[] concreteIndices = new String[numIndices];
18191819
for (int i = 0; i < numIndices; i++) {

0 commit comments

Comments
 (0)