|
17 | 17 | import org.elasticsearch.cluster.metadata.IndexMetadata; |
18 | 18 | import org.elasticsearch.common.settings.Settings; |
19 | 19 | import org.elasticsearch.common.util.concurrent.EsExecutors; |
| 20 | +import org.elasticsearch.index.IndexNotFoundException; |
20 | 21 | import org.elasticsearch.indices.IndicesService; |
21 | 22 | import org.elasticsearch.test.ESIntegTestCase; |
22 | 23 | import org.elasticsearch.threadpool.ThreadPool; |
|
25 | 26 | import java.util.Locale; |
26 | 27 | import java.util.stream.IntStream; |
27 | 28 |
|
| 29 | +import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; |
28 | 30 | import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures; |
29 | 31 | import static org.hamcrest.Matchers.equalTo; |
30 | 32 | import static org.hamcrest.Matchers.lessThan; |
@@ -113,6 +115,34 @@ public void testShardCloseWhenDiskSpaceInsufficient() throws Exception { |
113 | 115 | .toArray(IndexRequestBuilder[]::new) |
114 | 116 | ); |
115 | 117 | } |
| 118 | + // now delete the index in this state, i.e. with merges enqueued |
| 119 | + assertAcked(indicesAdmin().prepareDelete(indexName).get()); |
| 120 | + // index should be gone |
| 121 | + assertBusy(() -> { |
| 122 | + expectThrows( |
| 123 | + IndexNotFoundException.class, |
| 124 | + () -> indicesAdmin().prepareGetIndex(TEST_REQUEST_TIMEOUT).setIndices(indexName).get() |
| 125 | + ); |
| 126 | + }); |
| 127 | + assertBusy(() -> { |
| 128 | + // merge thread pool should be done with the enqueue merge tasks |
| 129 | + NodesStatsResponse nodesStatsResponse = client().admin().cluster().prepareNodesStats().setThreadPool(true).get(); |
| 130 | + assertThat( |
| 131 | + nodesStatsResponse.getNodes() |
| 132 | + .getFirst() |
| 133 | + .getThreadPool() |
| 134 | + .stats() |
| 135 | + .stream() |
| 136 | + .filter(s -> ThreadPool.Names.MERGE.equals(s.name())) |
| 137 | + .findAny() |
| 138 | + .get() |
| 139 | + .queue(), |
| 140 | + equalTo(0) |
| 141 | + ); |
| 142 | + // and the merge executor should also report that merging id done now |
| 143 | + assertFalse(indicesService.getThreadPoolMergeExecutorService().isMergingBlockedDueToInsufficientDiskSpace()); |
| 144 | + assertTrue(indicesService.getThreadPoolMergeExecutorService().allDone()); |
| 145 | + }); |
116 | 146 | } |
117 | 147 |
|
118 | 148 | public void setTotalSpace(String dataNodeName, long totalSpace) { |
|
0 commit comments