Browse Source

Wait for no snapshots in state in testRetentionWhileSnapshotIn… (#46573)

This commit adds a wait/check for all running snapshots to be cleared
before taking another snapshot. The previous snapshot was successful but
had not yet been cleared from the cluster state, so the second snapshot
failed due to a `ConcurrentSnapshotException`.

Resolves #46508
Lee Hinman 6 years ago
parent
commit
66e1c367b9

+ 8 - 1
x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/slm/SLMSnapshotBlockingIntegTests.java

@@ -8,6 +8,7 @@ package org.elasticsearch.xpack.slm;
 
 import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotStatus;
 import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotsStatusResponse;
+import org.elasticsearch.cluster.ClusterState;
 import org.elasticsearch.cluster.SnapshotsInProgress;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.unit.TimeValue;
@@ -105,7 +106,6 @@ public class SLMSnapshotBlockingIntegTests extends ESIntegTestCase {
         }
     }
 
-    @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/46508")
     public void testRetentionWhileSnapshotInProgress() throws Exception {
         final String indexName = "test";
         final String policyId = "slm-policy";
@@ -138,6 +138,13 @@ public class SLMSnapshotBlockingIntegTests extends ESIntegTestCase {
             }
         });
 
+        // Wait for all running snapshots to be cleared from cluster state
+        assertBusy(() -> {
+            logger.info("--> waiting for cluster state to be clear of snapshots");
+            ClusterState state = client().admin().cluster().prepareState().setCustoms(true).get().getState();
+            assertTrue("cluster state was not ready for deletion " + state, SnapshotRetentionTask.okayToDeleteSnapshots(state));
+        });
+
         // Take another snapshot, but before doing that, block it from completing
         logger.info("--> blocking nodes from completing snapshot");
         blockAllDataNodes(repoId);