Skip to content

Commit 1d0e50e

Browse files
committed
Ensure to release async search iterator in tests
We need to close an async search response iterator to release the related point in time if the test uses pit.
1 parent 5d68866 commit 1d0e50e

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

x-pack/plugin/async-search/src/internalClusterTest/java/org/elasticsearch/xpack/search/AsyncSearchActionIT.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -197,23 +197,25 @@ public void testRestartAfterCompletion() throws Exception {
197197

198198
public void testDeleteCancelRunningTask() throws Exception {
199199
final AsyncSearchResponse initial;
200-
SearchResponseIterator it =
201-
assertBlockingIterator(indexName, numShards, new SearchSourceBuilder(), randomBoolean() ? 1 : 0, 2);
202-
initial = it.next();
203-
deleteAsyncSearch(initial.getId());
204-
it.close();
205-
ensureTaskCompletion(initial.getId());
206-
ensureTaskRemoval(initial.getId());
200+
try (SearchResponseIterator it =
201+
assertBlockingIterator(indexName, numShards, new SearchSourceBuilder(), randomBoolean() ? 1 : 0, 2)) {
202+
initial = it.next();
203+
deleteAsyncSearch(initial.getId());
204+
it.close();
205+
ensureTaskCompletion(initial.getId());
206+
ensureTaskRemoval(initial.getId());
207+
}
207208
}
208209

209210
public void testDeleteCleanupIndex() throws Exception {
210-
SearchResponseIterator it =
211-
assertBlockingIterator(indexName, numShards, new SearchSourceBuilder(), randomBoolean() ? 1 : 0, 2);
212-
AsyncSearchResponse response = it.next();
213-
deleteAsyncSearch(response.getId());
214-
it.close();
215-
ensureTaskCompletion(response.getId());
216-
ensureTaskRemoval(response.getId());
211+
try (SearchResponseIterator it =
212+
assertBlockingIterator(indexName, numShards, new SearchSourceBuilder(), randomBoolean() ? 1 : 0, 2)) {
213+
AsyncSearchResponse response = it.next();
214+
deleteAsyncSearch(response.getId());
215+
it.close();
216+
ensureTaskCompletion(response.getId());
217+
ensureTaskRemoval(response.getId());
218+
}
217219
}
218220

219221
public void testCleanupOnFailure() throws Exception {
@@ -233,7 +235,6 @@ public void testCleanupOnFailure() throws Exception {
233235
ensureTaskRemoval(initial.getId());
234236
}
235237

236-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/61790")
237238
public void testInvalidId() throws Exception {
238239
try (SearchResponseIterator it =
239240
assertBlockingIterator(indexName, numShards, new SearchSourceBuilder(), randomBoolean() ? 1 : 0, 2)) {

0 commit comments

Comments
 (0)