@@ -113,13 +113,14 @@ public void testCreateAndRestoreSnapshot() throws IOException {
113113 final String repoName = getTestName ();
114114 try (RestHighLevelClient client = new RestHighLevelClient (RestClient .builder (adminClient ().getNodes ().toArray (new Node [0 ])))) {
115115 final int shards = 3 ;
116- createIndex (client , "test-index" , shards );
116+ final String index = "test-index" ;
117+ createIndex (client , index , shards );
117118 createRepository (client , repoName , false );
118- createSnapshot (client , repoName , "snapshot-" + TEST_STEP );
119+ createSnapshot (client , repoName , "snapshot-" + TEST_STEP , index );
119120 final String snapshotToDeleteName = "snapshot-to-delete" ;
120121 // Create a snapshot and delete it right away again to test the impact of each version's cleanup functionality that is run
121122 // as part of the snapshot delete
122- createSnapshot (client , repoName , snapshotToDeleteName );
123+ createSnapshot (client , repoName , snapshotToDeleteName , index );
123124 final List <Map <String , Object >> snapshotsIncludingToDelete = listSnapshots (repoName );
124125 // Every step creates one snapshot and we have to add one more for the temporary snapshot
125126 assertThat (snapshotsIncludingToDelete , hasSize (TEST_STEP .ordinal () + 1 + 1 ));
@@ -160,9 +161,10 @@ public void testReadOnlyRepo() throws IOException {
160161 final int shards = 3 ;
161162 final boolean readOnly = TEST_STEP .ordinal () > 1 ; // only restore from read-only repo in steps 3 and 4
162163 createRepository (client , repoName , readOnly );
164+ final String index = "test-index" ;
163165 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 );
166168 }
167169 final List <Map <String , Object >> snapshots = listSnapshots (repoName );
168170 switch (TEST_STEP ) {
@@ -194,11 +196,12 @@ public void testUpgradeMovesRepoToNewMetaVersion() throws IOException {
194196 final String repoName = getTestName ();
195197 try (RestHighLevelClient client = new RestHighLevelClient (RestClient .builder (adminClient ().getNodes ().toArray (new Node [0 ])))) {
196198 final int shards = 3 ;
197- createIndex (client , "test-index" , shards );
199+ final String index = "test-index" ;
200+ createIndex (client , index , shards );
198201 createRepository (client , repoName , false );
199202 // only create some snapshots in the first two steps
200203 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 );
202205 final List <Map <String , Object >> snapshots = listSnapshots (repoName );
203206 // Every step creates one snapshot
204207 assertThat (snapshots , hasSize (TEST_STEP .ordinal () + 1 ));
@@ -209,10 +212,10 @@ public void testUpgradeMovesRepoToNewMetaVersion() throws IOException {
209212 } else {
210213 deleteSnapshot (client , repoName , "snapshot-" + TestStep .STEP1_OLD_CLUSTER );
211214 ensureSnapshotRestoreWorks (repoName , "snapshot-" + TestStep .STEP2_NEW_CLUSTER , shards );
212- createSnapshot (client , repoName , "snapshot-1" );
215+ createSnapshot (client , repoName , "snapshot-1" , index );
213216 ensureSnapshotRestoreWorks (repoName , "snapshot-1" , shards );
214217 deleteSnapshot (client , repoName , "snapshot-" + TestStep .STEP2_NEW_CLUSTER );
215- createSnapshot (client , repoName , "snapshot-2" );
218+ createSnapshot (client , repoName , "snapshot-2" , index );
216219 ensureSnapshotRestoreWorks (repoName , "snapshot-2" , shards );
217220 }
218221 } else {
@@ -223,7 +226,7 @@ public void testUpgradeMovesRepoToNewMetaVersion() throws IOException {
223226 expectThrowsAnyOf (expectedExceptions , () -> listSnapshots (repoName ));
224227 expectThrowsAnyOf (expectedExceptions , () -> deleteSnapshot (client , repoName , "snapshot-1" ));
225228 expectThrowsAnyOf (expectedExceptions , () -> deleteSnapshot (client , repoName , "snapshot-2" ));
226- expectThrowsAnyOf (expectedExceptions , () -> createSnapshot (client , repoName , "snapshot-impossible" ));
229+ expectThrowsAnyOf (expectedExceptions , () -> createSnapshot (client , repoName , "snapshot-impossible" , index ));
227230 } else {
228231 assertThat (listSnapshots (repoName ), hasSize (2 ));
229232 if (TEST_STEP == TestStep .STEP4_NEW_CLUSTER ) {
@@ -287,8 +290,8 @@ private static void createRepository(RestHighLevelClient client, String repoName
287290 is (true ));
288291 }
289292
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 );
292295 }
293296
294297 private void createIndex (RestHighLevelClient client , String name , int shards ) throws IOException {
0 commit comments