Skip to content
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 @@ -139,7 +141,6 @@ public void testThatClusterPrivilegesWorkAsExpectedViaHttp() throws Exception {
assertAccessIsDenied("user_d", "PUT", "/_cluster/settings", "{ \"transient\" : { \"search.default_search_timeout\": \"1m\" } }");
}

@AwaitsFix( bugUrl = "https://github.com/elastic/elasticsearch/issues/38030")
public void testThatSnapshotAndRestore() throws Exception {
String repoJson = Strings.toString(jsonBuilder().startObject().field("type", "fs").startObject("settings").field("location",
repositoryLocation.toString()).endObject().endObject());
Expand Down Expand Up @@ -203,6 +204,11 @@ private void waitForSnapshotToFinish(String repo, String snapshot) throws Except
assertBusy(() -> {
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
SnapshotsInProgress snapshotsInProgress =
client().admin().cluster().state(new ClusterStateRequest()).get().getState().custom(SnapshotsInProgress.TYPE);
assertThat(snapshotsInProgress.entries(), Matchers.empty());
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@original-brownbear you've got my rubber stamp LGTM , but shouldn't we fix the prepareSnapshotStatus(repo).setSnapshots(snapshot) API to not return SUCCESS if there is still an SnapshotsInProgress.TYPE entry?

}
}