@@ -113,13 +113,14 @@ public void testCreateAndRestoreSnapshot() throws IOException {
113
113
final String repoName = getTestName ();
114
114
try (RestHighLevelClient client = new RestHighLevelClient (RestClient .builder (adminClient ().getNodes ().toArray (new Node [0 ])))) {
115
115
final int shards = 3 ;
116
- createIndex (client , "test-index" , shards );
116
+ final String index = "test-index" ;
117
+ createIndex (client , index , shards );
117
118
createRepository (client , repoName , false );
118
- createSnapshot (client , repoName , "snapshot-" + TEST_STEP );
119
+ createSnapshot (client , repoName , "snapshot-" + TEST_STEP , index );
119
120
final String snapshotToDeleteName = "snapshot-to-delete" ;
120
121
// Create a snapshot and delete it right away again to test the impact of each version's cleanup functionality that is run
121
122
// as part of the snapshot delete
122
- createSnapshot (client , repoName , snapshotToDeleteName );
123
+ createSnapshot (client , repoName , snapshotToDeleteName , index );
123
124
final List <Map <String , Object >> snapshotsIncludingToDelete = listSnapshots (repoName );
124
125
// Every step creates one snapshot and we have to add one more for the temporary snapshot
125
126
assertThat (snapshotsIncludingToDelete , hasSize (TEST_STEP .ordinal () + 1 + 1 ));
@@ -160,9 +161,10 @@ public void testReadOnlyRepo() throws IOException {
160
161
final int shards = 3 ;
161
162
final boolean readOnly = TEST_STEP .ordinal () > 1 ; // only restore from read-only repo in steps 3 and 4
162
163
createRepository (client , repoName , readOnly );
164
+ final String index = "test-index" ;
163
165
if (readOnly == false ) {
164
- createIndex (client , "test- index" , shards );
165
- createSnapshot (client , repoName , "snapshot-" + TEST_STEP );
166
+ createIndex (client , index , shards );
167
+ createSnapshot (client , repoName , "snapshot-" + TEST_STEP , index );
166
168
}
167
169
final List <Map <String , Object >> snapshots = listSnapshots (repoName );
168
170
switch (TEST_STEP ) {
@@ -194,11 +196,12 @@ public void testUpgradeMovesRepoToNewMetaVersion() throws IOException {
194
196
final String repoName = getTestName ();
195
197
try (RestHighLevelClient client = new RestHighLevelClient (RestClient .builder (adminClient ().getNodes ().toArray (new Node [0 ])))) {
196
198
final int shards = 3 ;
197
- createIndex (client , "test-index" , shards );
199
+ final String index = "test-index" ;
200
+ createIndex (client , index , shards );
198
201
createRepository (client , repoName , false );
199
202
// only create some snapshots in the first two steps
200
203
if (TEST_STEP == TestStep .STEP1_OLD_CLUSTER || TEST_STEP == TestStep .STEP2_NEW_CLUSTER ) {
201
- createSnapshot (client , repoName , "snapshot-" + TEST_STEP );
204
+ createSnapshot (client , repoName , "snapshot-" + TEST_STEP , index );
202
205
final List <Map <String , Object >> snapshots = listSnapshots (repoName );
203
206
// Every step creates one snapshot
204
207
assertThat (snapshots , hasSize (TEST_STEP .ordinal () + 1 ));
@@ -209,10 +212,10 @@ public void testUpgradeMovesRepoToNewMetaVersion() throws IOException {
209
212
} else {
210
213
deleteSnapshot (client , repoName , "snapshot-" + TestStep .STEP1_OLD_CLUSTER );
211
214
ensureSnapshotRestoreWorks (repoName , "snapshot-" + TestStep .STEP2_NEW_CLUSTER , shards );
212
- createSnapshot (client , repoName , "snapshot-1" );
215
+ createSnapshot (client , repoName , "snapshot-1" , index );
213
216
ensureSnapshotRestoreWorks (repoName , "snapshot-1" , shards );
214
217
deleteSnapshot (client , repoName , "snapshot-" + TestStep .STEP2_NEW_CLUSTER );
215
- createSnapshot (client , repoName , "snapshot-2" );
218
+ createSnapshot (client , repoName , "snapshot-2" , index );
216
219
ensureSnapshotRestoreWorks (repoName , "snapshot-2" , shards );
217
220
}
218
221
} else {
@@ -223,7 +226,7 @@ public void testUpgradeMovesRepoToNewMetaVersion() throws IOException {
223
226
expectThrowsAnyOf (expectedExceptions , () -> listSnapshots (repoName ));
224
227
expectThrowsAnyOf (expectedExceptions , () -> deleteSnapshot (client , repoName , "snapshot-1" ));
225
228
expectThrowsAnyOf (expectedExceptions , () -> deleteSnapshot (client , repoName , "snapshot-2" ));
226
- expectThrowsAnyOf (expectedExceptions , () -> createSnapshot (client , repoName , "snapshot-impossible" ));
229
+ expectThrowsAnyOf (expectedExceptions , () -> createSnapshot (client , repoName , "snapshot-impossible" , index ));
227
230
} else {
228
231
assertThat (listSnapshots (repoName ), hasSize (2 ));
229
232
if (TEST_STEP == TestStep .STEP4_NEW_CLUSTER ) {
@@ -287,8 +290,8 @@ private static void createRepository(RestHighLevelClient client, String repoName
287
290
is (true ));
288
291
}
289
292
290
- private static void createSnapshot (RestHighLevelClient client , String repoName , String name ) throws IOException {
291
- client .snapshot ().create (new CreateSnapshotRequest (repoName , name ).waitForCompletion (true ), RequestOptions .DEFAULT );
293
+ private static void createSnapshot (RestHighLevelClient client , String repoName , String name , String index ) throws IOException {
294
+ client .snapshot ().create (new CreateSnapshotRequest (repoName , name ).waitForCompletion (true ). indices ( index ) , RequestOptions .DEFAULT );
292
295
}
293
296
294
297
private void createIndex (RestHighLevelClient client , String name , int shards ) throws IOException {
0 commit comments