6
6
7
7
package org .elasticsearch .xpack .slm ;
8
8
9
- import org .apache .lucene .util .LuceneTestCase ;
10
9
import org .elasticsearch .action .ActionFuture ;
11
10
import org .elasticsearch .action .admin .cluster .snapshots .get .GetSnapshotsResponse ;
12
11
import org .elasticsearch .action .admin .cluster .snapshots .status .SnapshotStatus ;
@@ -124,7 +123,6 @@ public void testSnapshotInProgress() throws Exception {
124
123
}
125
124
}
126
125
127
- @ LuceneTestCase .AwaitsFix (bugUrl = "https://github.com/elastic/elasticsearch/issues/48441" )
128
126
public void testRetentionWhileSnapshotInProgress () throws Exception {
129
127
final String indexName = "test" ;
130
128
final String policyId = "slm-policy" ;
@@ -144,8 +142,7 @@ public void testRetentionWhileSnapshotInProgress() throws Exception {
144
142
logger .info ("--> kicked off snapshot {}" , completedSnapshotName );
145
143
assertBusy (() -> {
146
144
try {
147
- SnapshotsStatusResponse s =
148
- client ().admin ().cluster ().prepareSnapshotStatus (REPO ).setSnapshots (completedSnapshotName ).get ();
145
+ SnapshotsStatusResponse s = getSnapshotStatus (completedSnapshotName );
149
146
assertThat ("expected a snapshot but none were returned" , s .getSnapshots ().size (), equalTo (1 ));
150
147
SnapshotStatus status = s .getSnapshots ().get (0 );
151
148
logger .info ("--> waiting for snapshot {} to be completed, got: {}" , completedSnapshotName , status .getState ());
@@ -213,13 +210,8 @@ public void testRetentionWhileSnapshotInProgress() throws Exception {
213
210
client ().admin ().cluster ().prepareReroute ().get ();
214
211
logger .info ("--> waiting for snapshot to be deleted" );
215
212
try {
216
- SnapshotsStatusResponse s =
217
- client ().admin ().cluster ().prepareSnapshotStatus (REPO ).setSnapshots (completedSnapshotName ).get ();
213
+ SnapshotsStatusResponse s = getSnapshotStatus (completedSnapshotName );
218
214
assertNull ("expected no snapshot but one was returned" , s .getSnapshots ().get (0 ));
219
- } catch (RepositoryException e ) {
220
- // Concurrent status calls and write operations may lead to failures in determining the current repository generation
221
- // TODO: Remove this hack once tracking the current repository generation has been made consistent
222
- throw new AssertionError (e );
223
215
} catch (SnapshotMissingException e ) {
224
216
// Great, we wanted it to be deleted!
225
217
}
@@ -383,6 +375,18 @@ private void testUnsuccessfulSnapshotRetention(boolean partialSuccess) throws Ex
383
375
}
384
376
}
385
377
378
+ private SnapshotsStatusResponse getSnapshotStatus (String snapshotName ) {
379
+ try {
380
+ return client ().admin ().cluster ().prepareSnapshotStatus (REPO ).setSnapshots (snapshotName ).get ();
381
+ } catch (RepositoryException e ) {
382
+ // Convert this to an AssertionError so that it can be retried in an assertBusy - this is often a transient error because
383
+ // concurrent status calls and write operations may lead to failures in determining the current repository generation
384
+ // TODO: Remove this hack once tracking the current repository generation has been made consistent
385
+ logger .warn (e );
386
+ throw new AssertionError (e );
387
+ }
388
+ }
389
+
386
390
private void createAndPopulateIndex (String indexName ) throws InterruptedException {
387
391
logger .info ("--> creating and populating index [{}]" , indexName );
388
392
assertAcked (prepareCreate (indexName , 0 , Settings .builder ()
0 commit comments