@@ -129,7 +129,20 @@ public void testCreateAndRestoreSnapshot() throws IOException {
129
129
deleteSnapshot (client , repoName , snapshotToDeleteName );
130
130
final List <Map <String , Object >> snapshots = listSnapshots (repoName );
131
131
assertThat (snapshots , hasSize (TEST_STEP .ordinal () + 1 ));
132
- assertSnapshotStatusSuccessful (client , repoName , snapshots );
132
+ switch (TEST_STEP ) {
133
+ case STEP2_NEW_CLUSTER :
134
+ case STEP4_NEW_CLUSTER :
135
+ assertSnapshotStatusSuccessful (client , repoName ,
136
+ snapshots .stream ().map (sn -> (String ) sn .get ("snapshot" )).toArray (String []::new ));
137
+ break ;
138
+ case STEP1_OLD_CLUSTER :
139
+ assertSnapshotStatusSuccessful (client , repoName , "snapshot-" + TEST_STEP );
140
+ break ;
141
+ case STEP3_OLD_CLUSTER :
142
+ assertSnapshotStatusSuccessful (
143
+ client , repoName , "snapshot-" + TEST_STEP , "snapshot-" + TestStep .STEP3_OLD_CLUSTER );
144
+ break ;
145
+ }
133
146
if (TEST_STEP == TestStep .STEP3_OLD_CLUSTER ) {
134
147
ensureSnapshotRestoreWorks (client , repoName , "snapshot-" + TestStep .STEP1_OLD_CLUSTER , shards );
135
148
} else if (TEST_STEP == TestStep .STEP4_NEW_CLUSTER ) {
@@ -163,7 +176,12 @@ public void testReadOnlyRepo() throws IOException {
163
176
assertThat (snapshots , hasSize (2 ));
164
177
break ;
165
178
}
166
- assertSnapshotStatusSuccessful (client , repoName , snapshots );
179
+ if (TEST_STEP == TestStep .STEP1_OLD_CLUSTER || TEST_STEP == TestStep .STEP3_OLD_CLUSTER ) {
180
+ assertSnapshotStatusSuccessful (client , repoName , "snapshot-" + TestStep .STEP1_OLD_CLUSTER );
181
+ } else {
182
+ assertSnapshotStatusSuccessful (client , repoName ,
183
+ "snapshot-" + TestStep .STEP1_OLD_CLUSTER , "snapshot-" + TestStep .STEP2_NEW_CLUSTER );
184
+ }
167
185
if (TEST_STEP == TestStep .STEP3_OLD_CLUSTER ) {
168
186
ensureSnapshotRestoreWorks (client , repoName , "snapshot-" + TestStep .STEP1_OLD_CLUSTER , shards );
169
187
} else if (TEST_STEP == TestStep .STEP4_NEW_CLUSTER ) {
@@ -187,7 +205,8 @@ public void testUpgradeMovesRepoToNewMetaVersion() throws IOException {
187
205
final List <Map <String , Object >> snapshots = listSnapshots (repoName );
188
206
// Every step creates one snapshot
189
207
assertThat (snapshots , hasSize (TEST_STEP .ordinal () + 1 ));
190
- assertSnapshotStatusSuccessful (client , repoName , snapshots );
208
+ assertSnapshotStatusSuccessful (client , repoName ,
209
+ snapshots .stream ().map (sn -> (String ) sn .get ("snapshot" )).toArray (String []::new ));
191
210
if (TEST_STEP == TestStep .STEP1_OLD_CLUSTER ) {
192
211
ensureSnapshotRestoreWorks (client , repoName , "snapshot-" + TestStep .STEP1_OLD_CLUSTER , shards );
193
212
} else {
@@ -205,9 +224,9 @@ public void testUpgradeMovesRepoToNewMetaVersion() throws IOException {
205
224
}
206
225
207
226
private static void assertSnapshotStatusSuccessful (RestHighLevelClient client , String repoName ,
208
- List < Map < String , Object >> snapshots ) throws IOException {
209
- final SnapshotsStatusResponse statusResponse = client .snapshot (). status ( new SnapshotsStatusRequest ( repoName ,
210
- snapshots . stream (). map ( sn -> ( String ) sn . get ( "snapshot" )). toArray ( String []:: new ) ), RequestOptions .DEFAULT );
227
+ String ... snapshots ) throws IOException {
228
+ final SnapshotsStatusResponse statusResponse = client .snapshot ()
229
+ . status ( new SnapshotsStatusRequest ( repoName , snapshots ), RequestOptions .DEFAULT );
211
230
for (SnapshotStatus status : statusResponse .getSnapshots ()) {
212
231
assertThat (status .getShardsStats ().getFailedShards (), is (0 ));
213
232
}
0 commit comments