Skip to content

Commit 8892408

Browse files
SNAPSHOT: Fix Leaking Snapshot Task in IT (#35657)
* SNAPSHOT: Fix Leaking Snapshot Task in IT * If the test randomization causes the request to not wait for snapshot completion then the deleting of the still in progress snapshot could fail in the after hook * Fixed by deleting the snapshot in the test * Closes #35642
1 parent 844483a commit 8892408

File tree

1 file changed

+8
-0
lines changed
  • client/rest-high-level/src/test/java/org/elasticsearch/client

1 file changed

+8
-0
lines changed

client/rest-high-level/src/test/java/org/elasticsearch/client/SnapshotIT.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@ public void testCreateSnapshot() throws IOException {
144144

145145
CreateSnapshotResponse response = createTestSnapshot(request);
146146
assertEquals(waitForCompletion ? RestStatus.OK : RestStatus.ACCEPTED, response.status());
147+
if (waitForCompletion == false) {
148+
// If we don't wait for the snapshot to complete we have to cancel it to not leak the snapshot task
149+
AcknowledgedResponse deleteResponse = execute(
150+
new DeleteSnapshotRequest(repository, snapshot),
151+
highLevelClient().snapshot()::delete, highLevelClient().snapshot()::deleteAsync
152+
);
153+
assertTrue(deleteResponse.isAcknowledged());
154+
}
147155
}
148156

149157
public void testGetSnapshots() throws IOException {

0 commit comments

Comments
 (0)