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
This commit is contained in:
Armin Braun 2018-11-20 14:09:15 +01:00 committed by GitHub
parent 844483a99a
commit 8892408edd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -144,6 +144,14 @@ public class SnapshotIT extends ESRestHighLevelClientTestCase {
CreateSnapshotResponse response = createTestSnapshot(request); CreateSnapshotResponse response = createTestSnapshot(request);
assertEquals(waitForCompletion ? RestStatus.OK : RestStatus.ACCEPTED, response.status()); assertEquals(waitForCompletion ? RestStatus.OK : RestStatus.ACCEPTED, response.status());
if (waitForCompletion == false) {
// If we don't wait for the snapshot to complete we have to cancel it to not leak the snapshot task
AcknowledgedResponse deleteResponse = execute(
new DeleteSnapshotRequest(repository, snapshot),
highLevelClient().snapshot()::delete, highLevelClient().snapshot()::deleteAsync
);
assertTrue(deleteResponse.isAcknowledged());
}
} }
public void testGetSnapshots() throws IOException { public void testGetSnapshots() throws IOException {