From 7703183cef3ae8f903bd8680ff4c93a6c326fe81 Mon Sep 17 00:00:00 2001 From: Igor Motov Date: Tue, 11 Mar 2014 17:17:36 -0400 Subject: [PATCH] [TEST] Make sure that a snapshot is completed before trying to modify repository --- .../snapshots/AbstractSnapshotTests.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/elasticsearch/snapshots/AbstractSnapshotTests.java b/src/test/java/org/elasticsearch/snapshots/AbstractSnapshotTests.java index 9114e8cc4e6..27620c993fa 100644 --- a/src/test/java/org/elasticsearch/snapshots/AbstractSnapshotTests.java +++ b/src/test/java/org/elasticsearch/snapshots/AbstractSnapshotTests.java @@ -20,10 +20,12 @@ package org.elasticsearch.snapshots; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; +import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; +import org.elasticsearch.cluster.metadata.SnapshotId; +import org.elasticsearch.cluster.metadata.SnapshotMetaData; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.repositories.RepositoriesService; -import org.elasticsearch.repositories.RepositoryMissingException; import org.elasticsearch.snapshots.mockstore.MockRepository; import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.junit.Ignore; @@ -85,11 +87,17 @@ public abstract class AbstractSnapshotTests extends ElasticsearchIntegrationTest public SnapshotInfo waitForCompletion(String repository, String snapshot, TimeValue timeout) throws InterruptedException { long start = System.currentTimeMillis(); + SnapshotId snapshotId = new SnapshotId(repository, snapshot); while (System.currentTimeMillis() - start < timeout.millis()) { ImmutableList snapshotInfos = client().admin().cluster().prepareGetSnapshots(repository).setSnapshots(snapshot).get().getSnapshots(); assertThat(snapshotInfos.size(), equalTo(1)); if (snapshotInfos.get(0).state().completed()) { - return snapshotInfos.get(0); + // Make sure that snapshot clean up operations are finished + ClusterStateResponse stateResponse = client().admin().cluster().prepareState().get(); + SnapshotMetaData snapshotMetaData = stateResponse.getState().getMetaData().custom(SnapshotMetaData.TYPE); + if (snapshotMetaData == null || snapshotMetaData.snapshot(snapshotId) == null) { + return snapshotInfos.get(0); + } } Thread.sleep(100); }