9
9
10
10
import org .elasticsearch .client .Request ;
11
11
import org .elasticsearch .client .Response ;
12
- import org .elasticsearch .cluster .metadata .DataStream ;
13
12
import org .elasticsearch .cluster .metadata .IndexMetadata ;
14
13
import org .elasticsearch .cluster .metadata .Template ;
15
14
import org .elasticsearch .common .xcontent .XContentHelper ;
@@ -80,20 +79,15 @@ public void testRolloverAction() throws Exception {
80
79
81
80
indexDocument (client (), dataStream , true );
82
81
83
- assertBusy (() -> assertTrue (indexExists (DataStream .getDefaultBackingIndexName (dataStream , 2 ))));
84
- assertBusy (
85
- () -> assertTrue (
86
- Boolean .parseBoolean (
87
- (String ) getIndexSettingsAsMap (DataStream .getDefaultBackingIndexName (dataStream , 2 )).get ("index.hidden" )
88
- )
89
- )
90
- );
91
- assertBusy (
92
- () -> assertThat (
93
- getStepKeyForIndex (client (), DataStream .getDefaultBackingIndexName (dataStream , 1 )),
94
- equalTo (PhaseCompleteStep .finalStep ("hot" ).getKey ())
95
- )
96
- );
82
+ assertBusy (() -> {
83
+ final var backingIndices = getBackingIndices (client (), dataStream );
84
+ assertEquals (2 , backingIndices .size ());
85
+ assertTrue (Boolean .parseBoolean ((String ) getIndexSettingsAsMap (backingIndices .get (1 )).get ("index.hidden" )));
86
+ });
87
+ assertBusy (() -> {
88
+ final var backingIndices = getBackingIndices (client (), dataStream );
89
+ assertEquals (PhaseCompleteStep .finalStep ("hot" ).getKey (), getStepKeyForIndex (client (), backingIndices .get (0 )));
90
+ });
97
91
}
98
92
99
93
public void testRolloverIsSkippedOnManualDataStreamRollover () throws Exception {
@@ -103,15 +97,18 @@ public void testRolloverIsSkippedOnManualDataStreamRollover() throws Exception {
103
97
104
98
indexDocument (client (), dataStream , true );
105
99
106
- String firstGenerationIndex = DataStream . getDefaultBackingIndexName ( dataStream , 1 );
100
+ String firstGenerationIndex = getBackingIndices ( client (), dataStream ). get ( 0 );
107
101
assertBusy (
108
102
() -> assertThat (getStepKeyForIndex (client (), firstGenerationIndex ).name (), equalTo (WaitForRolloverReadyStep .NAME )),
109
103
30 ,
110
104
TimeUnit .SECONDS
111
105
);
112
106
113
107
rolloverMaxOneDocCondition (client (), dataStream );
114
- assertBusy (() -> assertThat (indexExists (DataStream .getDefaultBackingIndexName (dataStream , 2 )), is (true )), 30 , TimeUnit .SECONDS );
108
+ assertBusy (() -> {
109
+ final var backingIndices = getBackingIndices (client (), dataStream );
110
+ assertEquals (2 , backingIndices .size ());
111
+ }, 30 , TimeUnit .SECONDS );
115
112
116
113
// even though the first index doesn't have 2 documents to fulfill the rollover condition, it should complete the rollover action
117
114
// because it's not the write index anymore
@@ -128,7 +125,7 @@ public void testShrinkActionInPolicyWithoutHotPhase() throws Exception {
128
125
createComposableTemplate (client (), template , dataStream + "*" , getTemplate (policyName ));
129
126
indexDocument (client (), dataStream , true );
130
127
131
- String backingIndexName = DataStream . getDefaultBackingIndexName ( dataStream , 1 );
128
+ String backingIndexName = getBackingIndices ( client (), dataStream ). get ( 0 );
132
129
assertBusy (
133
130
() -> assertThat (
134
131
"original index must wait in the " + CheckNotDataStreamWriteIndexStep .NAME + " until it is not the write index anymore" ,
@@ -142,8 +139,11 @@ public void testShrinkActionInPolicyWithoutHotPhase() throws Exception {
142
139
// Manual rollover the original index such that it's not the write index in the data stream anymore
143
140
rolloverMaxOneDocCondition (client (), dataStream );
144
141
// Wait for rollover to happen
145
- String rolloverIndex = DataStream .getDefaultBackingIndexName (dataStream , 2 );
146
- assertBusy (() -> assertTrue ("the rollover action created the rollover index" , indexExists (rolloverIndex )), 30 , TimeUnit .SECONDS );
142
+ assertBusy (
143
+ () -> assertEquals ("the rollover action created the rollover index" , 2 , getBackingIndices (client (), dataStream ).size ()),
144
+ 30 ,
145
+ TimeUnit .SECONDS
146
+ );
147
147
148
148
String shrunkenIndex = waitAndGetShrinkIndexName (client (), backingIndexName );
149
149
assertBusy (() -> assertTrue (indexExists (shrunkenIndex )), 30 , TimeUnit .SECONDS );
@@ -159,7 +159,7 @@ public void testSearchableSnapshotAction() throws Exception {
159
159
createComposableTemplate (client (), template , dataStream + "*" , getTemplate (policyName ));
160
160
indexDocument (client (), dataStream , true );
161
161
162
- String backingIndexName = DataStream . getDefaultBackingIndexName ( dataStream , 1 );
162
+ String backingIndexName = getBackingIndices ( client (), dataStream ). get ( 0 );
163
163
String restoredIndexName = SearchableSnapshotAction .FULL_RESTORED_INDEX_PREFIX + backingIndexName ;
164
164
165
165
assertBusy (
@@ -190,7 +190,7 @@ public void testReadOnlyAction() throws Exception {
190
190
createComposableTemplate (client (), template , dataStream + "*" , getTemplate (policyName ));
191
191
indexDocument (client (), dataStream , true );
192
192
193
- String backingIndexName = DataStream . getDefaultBackingIndexName ( dataStream , 1 );
193
+ String backingIndexName = getBackingIndices ( client (), dataStream ). get ( 0 );
194
194
assertBusy (
195
195
() -> assertThat (
196
196
"index must wait in the " + CheckNotDataStreamWriteIndexStep .NAME + " until it is not the write index anymore" ,
@@ -220,7 +220,7 @@ public void testFreezeAction() throws Exception {
220
220
createComposableTemplate (client (), template , dataStream + "*" , getTemplate (policyName ));
221
221
indexDocument (client (), dataStream , true );
222
222
223
- String backingIndexName = DataStream . getDefaultBackingIndexName ( dataStream , 1 );
223
+ String backingIndexName = getBackingIndices ( client (), dataStream ). get ( 0 );
224
224
assertBusy (
225
225
() -> assertThat (
226
226
"index must wait in the " + CheckNotDataStreamWriteIndexStep .NAME + " until it is not the write index anymore" ,
@@ -249,7 +249,7 @@ public void checkForceMergeAction(String codec) throws Exception {
249
249
createComposableTemplate (client (), template , dataStream + "*" , getTemplate (policyName ));
250
250
indexDocument (client (), dataStream , true );
251
251
252
- String backingIndexName = DataStream . getDefaultBackingIndexName ( dataStream , 1 );
252
+ String backingIndexName = getBackingIndices ( client (), dataStream ). get ( 0 );
253
253
assertBusy (
254
254
() -> assertThat (
255
255
"index must wait in the " + CheckNotDataStreamWriteIndexStep .NAME + " until it is not the write index anymore" ,
0 commit comments