From e0f73c96f73083f8ea52bd682191ba2828602ece Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Wed, 21 Oct 2020 15:33:12 +0200 Subject: [PATCH] Fix testStartCloneWithSuccessfulShardSnapshotPendingFinalization (#63966) (#64000) We have to wait for no more operations here not for `1`. This mostly worked because the test thread would add the listener quickly enough so that it sees the state where either the snapshot or clone but not both have already finished but randomly the test thread would be slow and time out on a state without snaphots in it. --- .../java/org/elasticsearch/snapshots/CloneSnapshotIT.java | 2 +- .../org/elasticsearch/snapshots/ConcurrentSnapshotsIT.java | 4 ---- .../snapshots/AbstractSnapshotIntegTestCase.java | 4 ++++ 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/CloneSnapshotIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/CloneSnapshotIT.java index 56fab0f7337..84b15048317 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/CloneSnapshotIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/CloneSnapshotIT.java @@ -559,7 +559,7 @@ public class CloneSnapshotIT extends AbstractSnapshotIntegTestCase { } finally { unblockNode(repoName, masterName); } - awaitNumberOfSnapshotsInProgress(1); + awaitNoMoreRunningOperations(); awaitMasterFinishRepoOperations(); diff --git a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/ConcurrentSnapshotsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/ConcurrentSnapshotsIT.java index c5180611bf1..fd45f40730e 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/snapshots/ConcurrentSnapshotsIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/snapshots/ConcurrentSnapshotsIT.java @@ -1298,10 +1298,6 @@ public class ConcurrentSnapshotsIT extends AbstractSnapshotIntegTestCase { return snapshotNames; } - private void awaitNoMoreRunningOperations() throws Exception { - awaitNoMoreRunningOperations(internalCluster().getMasterName()); - } - private ActionFuture startDeleteFromNonMasterClient(String repoName, String snapshotName) { logger.info("--> deleting snapshot [{}] from repo [{}] from non master client", snapshotName, repoName); return internalCluster().nonMasterClient().admin().cluster().prepareDeleteSnapshot(repoName, snapshotName).execute(); diff --git a/test/framework/src/main/java/org/elasticsearch/snapshots/AbstractSnapshotIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/snapshots/AbstractSnapshotIntegTestCase.java index 3edbb13c768..2d78e1ec40c 100644 --- a/test/framework/src/main/java/org/elasticsearch/snapshots/AbstractSnapshotIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/snapshots/AbstractSnapshotIntegTestCase.java @@ -467,6 +467,10 @@ public abstract class AbstractSnapshotIntegTestCase extends ESIntegTestCase { SnapshotsService.OLD_SNAPSHOT_FORMAT, Function.identity(), f)); } + protected void awaitNoMoreRunningOperations() throws Exception { + awaitNoMoreRunningOperations(internalCluster().getMasterName()); + } + protected void awaitNoMoreRunningOperations(String viaNode) throws Exception { logger.info("--> verify no more operations in the cluster state"); awaitClusterState(viaNode, state -> state.custom(SnapshotsInProgress.TYPE, SnapshotsInProgress.EMPTY).entries().isEmpty() &&