Skip to content

Commit

Permalink
Safer Wait for Snapshot Success in ClusterPrivilegeTests
Browse files Browse the repository at this point in the history
* The snapshot state returned by the API might become SUCCESS before it's fully removed from the cluster state.
  * We should fix this race in the transport API but it's not trivial and will be part of the incoming big round of rafactoring the repository interaction, this added check fixes the test for now
* closes elastic#38030
  • Loading branch information
original-brownbear committed Apr 8, 2019
1 parent 675bf3c commit b3871f3
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
package org.elasticsearch.integration;

import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotsStatusResponse;
import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest;
import org.elasticsearch.client.Request;
import org.elasticsearch.cluster.SnapshotsInProgress;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.xpack.core.security.authc.support.Hasher;
import org.hamcrest.Matchers;
import org.junit.AfterClass;
import org.junit.BeforeClass;

Expand Down Expand Up @@ -203,5 +205,12 @@ private void waitForSnapshotToFinish(String repo, String snapshot) throws Except
SnapshotsStatusResponse response = client().admin().cluster().prepareSnapshotStatus(repo).setSnapshots(snapshot).get();
assertThat(response.getSnapshots().get(0).getState(), is(SnapshotsInProgress.State.SUCCESS));
});
// The status of the snapshot in the repository can become SUCCESS before it is fully finalized in the cluster state so wait for
// it to disappear from the cluster state as well
assertBusy(() -> {
SnapshotsInProgress response =
client().admin().cluster().state(new ClusterStateRequest()).get().getState().custom(SnapshotsInProgress.TYPE);
assertThat(response.entries(), Matchers.empty());
});
}
}

0 comments on commit b3871f3

Please sign in to comment.