@@ -271,7 +271,8 @@ public void testSnapshotAndRestoreInPlace() {
271
271
RolloverRequest rolloverRequest = new RolloverRequest ("ds" , null );
272
272
RolloverResponse rolloverResponse = client .admin ().indices ().rolloverIndex (rolloverRequest ).actionGet ();
273
273
assertThat (rolloverResponse .isRolledOver (), is (true ));
274
- assertThat (rolloverResponse .getNewIndex (), equalTo (DataStream .getDefaultBackingIndexName ("ds" , 2 )));
274
+ String backingIndexAfterSnapshot = DataStream .getDefaultBackingIndexName ("ds" , 2 );
275
+ assertThat (rolloverResponse .getNewIndex (), equalTo (backingIndexAfterSnapshot ));
275
276
276
277
// Close all backing indices of ds data stream:
277
278
CloseIndexRequest closeIndexRequest = new CloseIndexRequest (".ds-ds-*" );
@@ -302,7 +303,7 @@ public void testSnapshotAndRestoreInPlace() {
302
303
assertThat (backingIndices .stream ().map (Index ::getName ).collect (Collectors .toList ()), contains (equalTo (dsBackingIndexName )));
303
304
304
305
// The backing index created as part of rollover should still exist (but just not part of the data stream)
305
- assertThat (indexExists (DataStream . getDefaultBackingIndexName ( "ds" , 2 ) ), is (true ));
306
+ assertThat (indexExists (backingIndexAfterSnapshot ), is (true ));
306
307
// An additional rollover should create a new backing index (3th generation) and leave .ds-ds-...-2 index as is:
307
308
rolloverRequest = new RolloverRequest ("ds" , null );
308
309
rolloverResponse = client .admin ().indices ().rolloverIndex (rolloverRequest ).actionGet ();
@@ -883,6 +884,11 @@ public void testDeleteDataStreamDuringSnapshot() throws Exception {
883
884
}
884
885
refresh ();
885
886
assertDocCount (dataStream , 100L );
887
+ // Resolve backing index name after the data stream has been created because it has a date component,
888
+ // and running around midnight could lead to test failures otherwise
889
+ GetDataStreamAction .Request getDataStreamRequest = new GetDataStreamAction .Request (new String [] { dataStream });
890
+ GetDataStreamAction .Response getDataStreamResponse = client .execute (GetDataStreamAction .INSTANCE , getDataStreamRequest ).actionGet ();
891
+ String backingIndexName = getDataStreamResponse .getDataStreams ().get (0 ).getDataStream ().getIndices ().get (0 ).getName ();
886
892
887
893
logger .info ("--> snapshot" );
888
894
ActionFuture <CreateSnapshotResponse > future = client1 .admin ()
@@ -913,7 +919,7 @@ public void testDeleteDataStreamDuringSnapshot() throws Exception {
913
919
SnapshotInfo snapshotInfo = createSnapshotResponse .getSnapshotInfo ();
914
920
assertThat (snapshotInfo .state (), equalTo ((SnapshotState .SUCCESS )));
915
921
assertThat (snapshotInfo .dataStreams (), contains (dataStream ));
916
- assertThat (snapshotInfo .indices (), contains (DataStream . getDefaultBackingIndexName ( dataStream , 1 ) ));
922
+ assertThat (snapshotInfo .indices (), contains (backingIndexName ));
917
923
}
918
924
919
925
public void testCloneSnapshotThatIncludesDataStream () throws Exception {
0 commit comments