|
9 | 9 |
|
10 | 10 | package org.elasticsearch.search; |
11 | 11 |
|
| 12 | +import com.carrotsearch.randomizedtesting.annotations.Repeat; |
| 13 | + |
12 | 14 | import org.elasticsearch.action.index.IndexRequestBuilder; |
13 | 15 | import org.elasticsearch.action.search.ClosePointInTimeRequest; |
14 | 16 | import org.elasticsearch.action.search.OpenPointInTimeRequest; |
15 | 17 | import org.elasticsearch.action.search.SearchRequest; |
| 18 | +import org.elasticsearch.action.search.SearchShardsGroup; |
| 19 | +import org.elasticsearch.action.search.SearchShardsRequest; |
16 | 20 | import org.elasticsearch.action.search.TransportClosePointInTimeAction; |
17 | 21 | import org.elasticsearch.action.search.TransportOpenPointInTimeAction; |
| 22 | +import org.elasticsearch.action.search.TransportSearchShardsAction; |
| 23 | +import org.elasticsearch.action.support.IndicesOptions; |
18 | 24 | import org.elasticsearch.cluster.ClusterState; |
19 | 25 | import org.elasticsearch.cluster.block.ClusterBlocks; |
20 | 26 | import org.elasticsearch.cluster.metadata.IndexMetadata; |
|
23 | 29 | import org.elasticsearch.cluster.service.ClusterService; |
24 | 30 | import org.elasticsearch.common.bytes.BytesReference; |
25 | 31 | import org.elasticsearch.core.TimeValue; |
| 32 | +import org.elasticsearch.index.query.MatchAllQueryBuilder; |
26 | 33 | import org.elasticsearch.index.query.QueryBuilders; |
27 | 34 | import org.elasticsearch.search.builder.PointInTimeBuilder; |
28 | 35 | import org.elasticsearch.search.builder.SearchSourceBuilder; |
@@ -103,6 +110,29 @@ public void testMultiSearchIndicesWithIndexRefreshBlocks() { |
103 | 110 | ); |
104 | 111 | } |
105 | 112 |
|
| 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 | + |
106 | 136 | private List<String> createIndices() { |
107 | 137 | int numIndices = randomIntBetween(1, 3); |
108 | 138 | List<String> indices = new ArrayList<>(); |
|
0 commit comments