|
6 | 6 | package org.elasticsearch.integration; |
7 | 7 |
|
8 | 8 | import org.elasticsearch.action.admin.cluster.snapshots.status.SnapshotsStatusResponse; |
| 9 | +import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest; |
9 | 10 | import org.elasticsearch.client.Request; |
10 | 11 | import org.elasticsearch.cluster.SnapshotsInProgress; |
11 | 12 | import org.elasticsearch.common.Strings; |
12 | 13 | import org.elasticsearch.common.settings.SecureString; |
13 | 14 | import org.elasticsearch.common.settings.Settings; |
14 | 15 | import org.elasticsearch.xpack.core.security.authc.support.Hasher; |
| 16 | +import org.hamcrest.Matchers; |
15 | 17 | import org.junit.AfterClass; |
16 | 18 | import org.junit.BeforeClass; |
17 | 19 |
|
@@ -139,7 +141,6 @@ public void testThatClusterPrivilegesWorkAsExpectedViaHttp() throws Exception { |
139 | 141 | assertAccessIsDenied("user_d", "PUT", "/_cluster/settings", "{ \"transient\" : { \"search.default_search_timeout\": \"1m\" } }"); |
140 | 142 | } |
141 | 143 |
|
142 | | - @AwaitsFix( bugUrl = "https://github.com/elastic/elasticsearch/issues/38030") |
143 | 144 | public void testThatSnapshotAndRestore() throws Exception { |
144 | 145 | String repoJson = Strings.toString(jsonBuilder().startObject().field("type", "fs").startObject("settings").field("location", |
145 | 146 | repositoryLocation.toString()).endObject().endObject()); |
@@ -203,6 +204,11 @@ private void waitForSnapshotToFinish(String repo, String snapshot) throws Except |
203 | 204 | assertBusy(() -> { |
204 | 205 | SnapshotsStatusResponse response = client().admin().cluster().prepareSnapshotStatus(repo).setSnapshots(snapshot).get(); |
205 | 206 | assertThat(response.getSnapshots().get(0).getState(), is(SnapshotsInProgress.State.SUCCESS)); |
| 207 | + // The status of the snapshot in the repository can become SUCCESS before it is fully finalized in the cluster state so wait for |
| 208 | + // it to disappear from the cluster state as well |
| 209 | + SnapshotsInProgress snapshotsInProgress = |
| 210 | + client().admin().cluster().state(new ClusterStateRequest()).get().getState().custom(SnapshotsInProgress.TYPE); |
| 211 | + assertThat(snapshotsInProgress.entries(), Matchers.empty()); |
206 | 212 | }); |
207 | 213 | } |
208 | 214 | } |
0 commit comments