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