Просмотр исходного кода

[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.
Ali Beyad 8 лет назад
Родитель
Сommit
e72d287382

+ 5 - 1
core/src/test/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java

@@ -806,7 +806,6 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
         logger.info("--> total number of simulated failures during restore: [{}]", getFailureCount("test-repo"));
     }
 
-    @TestLogging("org.elasticsearch.snapshots:TRACE,org.elasticsearch.cluster:TRACE")
     public void testDataFileCorruptionDuringRestore() throws Exception {
         Path repositoryLocation = randomRepoPath();
         Client client = client();
@@ -846,6 +845,11 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
         RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setWaitForCompletion(true).execute().actionGet();
         assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0));
         assertThat(restoreSnapshotResponse.getRestoreInfo().failedShards(), equalTo(restoreSnapshotResponse.getRestoreInfo().totalShards()));
+        // we have to delete the index here manually, otherwise the cluster will keep
+        // trying to allocate the shards for the index, even though the restore operation
+        // is completed and marked as failed, which can lead to nodes having pending
+        // cluster states to process in their queue when the test is finished
+        client.admin().indices().prepareDelete("test-idx").get();
     }
 
     public void testDeletionOfFailingToRecoverIndexShouldStopRestore() throws Exception {