Skip to content

Commit 7aedb2a

Browse files
author
Ali Beyad
committed
[TEST] Propertly cleans up failing restore test
The SharedClusterSnapshotRestoreIT#testDataFileCorruptionDuringRestore would fail sporadically because it tried to simulate restoring a corrupted index. The test would wait until the restore is finished (and marked as failed) before exiting. However, in the background, the cluster still continues to retry allocation of the failed shards, despite the restore operation being marked as completed, which in turn generates cluster states to process. The end of every ESIntegTestCase verifies that none of the nodes have any pending cluster states to process. Hence, this check sometimes fails on this particular test. This commit solves the issue by ensuring the index is deleted before exiting the test.
1 parent 5490c7a commit 7aedb2a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,11 @@ public void testDataFileCorruptionDuringRestore() throws Exception {
817817
RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setWaitForCompletion(true).execute().actionGet();
818818
assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0));
819819
assertThat(restoreSnapshotResponse.getRestoreInfo().failedShards(), equalTo(restoreSnapshotResponse.getRestoreInfo().totalShards()));
820+
// we have to delete the index here manually, otherwise the cluster will keep
821+
// trying to allocate the shards for the index, even though the restore operation
822+
// is completed and marked as failed, which can lead to nodes having pending
823+
// cluster states to process in their queue when the test is finished
824+
client.admin().indices().prepareDelete("test-idx").get();
820825
}
821826

822827
public void testDeletionOfFailingToRecoverIndexShouldStopRestore() throws Exception {

0 commit comments

Comments
 (0)