@@ -66,14 +66,11 @@ public void testConcurrentlyChangeRepositoryContents() throws Exception {
66
66
67
67
Path repo = randomRepoPath ();
68
68
final String repoName = "test-repo" ;
69
- logger .info ("--> creating repository at {}" , repo .toAbsolutePath ());
70
- assertAcked (client .admin ().cluster ().preparePutRepository (repoName )
71
- .setType ("fs" ).setSettings (Settings .builder ()
72
- .put ("location" , repo )
73
- .put ("compress" , false )
74
- // Don't cache repository data because the test manually modifies the repository data
75
- .put (BlobStoreRepository .CACHE_REPOSITORY_DATA .getKey (), false )
76
- .put ("chunk_size" , randomIntBetween (100 , 1000 ), ByteSizeUnit .BYTES )));
69
+ createRepository (repoName , "fs" , Settings .builder ()
70
+ .put ("location" , repo ).put ("compress" , false )
71
+ // Don't cache repository data because the test manually modifies the repository data
72
+ .put (BlobStoreRepository .CACHE_REPOSITORY_DATA .getKey (), false )
73
+ .put ("chunk_size" , randomIntBetween (100 , 1000 ), ByteSizeUnit .BYTES ));
77
74
78
75
createIndex ("test-idx-1" , "test-idx-2" );
79
76
logger .info ("--> indexing some data" );
@@ -125,12 +122,9 @@ public void testConcurrentlyChangeRepositoryContents() throws Exception {
125
122
public void testFindDanglingLatestGeneration () throws Exception {
126
123
Path repo = randomRepoPath ();
127
124
final String repoName = "test-repo" ;
128
- logger .info ("--> creating repository at {}" , repo .toAbsolutePath ());
129
- assertAcked (client ().admin ().cluster ().preparePutRepository (repoName )
130
- .setType ("fs" ).setSettings (Settings .builder ()
131
- .put ("location" , repo )
132
- .put ("compress" , false )
133
- .put ("chunk_size" , randomIntBetween (100 , 1000 ), ByteSizeUnit .BYTES )));
125
+ createRepository (repoName , "fs" , Settings .builder ()
126
+ .put ("location" , repo ).put ("compress" , false )
127
+ .put ("chunk_size" , randomIntBetween (100 , 1000 ), ByteSizeUnit .BYTES ));
134
128
135
129
createIndex ("test-idx-1" , "test-idx-2" );
136
130
logger .info ("--> indexing some data" );
@@ -200,14 +194,12 @@ public void clusterStateProcessed(String source, ClusterState oldState, ClusterS
200
194
public void testHandlingMissingRootLevelSnapshotMetadata () throws Exception {
201
195
Path repo = randomRepoPath ();
202
196
final String repoName = "test-repo" ;
203
- logger .info ("--> creating repository at {}" , repo .toAbsolutePath ());
204
- assertAcked (client ().admin ().cluster ().preparePutRepository (repoName )
205
- .setType ("fs" ).setSettings (Settings .builder ()
206
- .put ("location" , repo )
207
- .put ("compress" , false )
208
- // Don't cache repository data because the test manually modifies the repository data
209
- .put (BlobStoreRepository .CACHE_REPOSITORY_DATA .getKey (), false )
210
- .put ("chunk_size" , randomIntBetween (100 , 1000 ), ByteSizeUnit .BYTES )));
197
+ createRepository (repoName , "fs" , Settings .builder ()
198
+ .put ("location" , repo )
199
+ .put ("compress" , false )
200
+ // Don't cache repository data because the test manually modifies the repository data
201
+ .put (BlobStoreRepository .CACHE_REPOSITORY_DATA .getKey (), false )
202
+ .put ("chunk_size" , randomIntBetween (100 , 1000 ), ByteSizeUnit .BYTES ));
211
203
212
204
final String snapshotPrefix = "test-snap-" ;
213
205
final int snapshots = randomIntBetween (1 , 2 );
@@ -268,13 +260,11 @@ public void testMountCorruptedRepositoryData() throws Exception {
268
260
269
261
Path repo = randomRepoPath ();
270
262
final String repoName = "test-repo" ;
271
- logger .info ("--> creating repository at {}" , repo .toAbsolutePath ());
272
- assertAcked (client .admin ().cluster ().preparePutRepository (repoName )
273
- .setType ("fs" ).setSettings (Settings .builder ()
274
- .put ("location" , repo )
275
- // Don't cache repository data because the test manually modifies the repository data
276
- .put (BlobStoreRepository .CACHE_REPOSITORY_DATA .getKey (), false )
277
- .put ("compress" , false )));
263
+ createRepository (repoName , "fs" , Settings .builder ()
264
+ .put ("location" , repo )
265
+ // Don't cache repository data because the test manually modifies the repository data
266
+ .put (BlobStoreRepository .CACHE_REPOSITORY_DATA .getKey (), false )
267
+ .put ("compress" , false ));
278
268
279
269
final String snapshot = "test-snap" ;
280
270
@@ -292,12 +282,9 @@ public void testMountCorruptedRepositoryData() throws Exception {
292
282
logger .info ("--> verify loading repository data throws RepositoryException" );
293
283
expectThrows (RepositoryException .class , () -> getRepositoryData (repository ));
294
284
295
- logger .info ("--> mount repository path in a new repository" );
296
285
final String otherRepoName = "other-repo" ;
297
- assertAcked (client .admin ().cluster ().preparePutRepository (otherRepoName )
298
- .setType ("fs" ).setSettings (Settings .builder ()
299
- .put ("location" , repo )
300
- .put ("compress" , false )));
286
+ createRepository (otherRepoName , "fs" , Settings .builder ()
287
+ .put ("location" , repo ).put ("compress" , false ));
301
288
final Repository otherRepo = internalCluster ().getCurrentMasterNodeInstance (RepositoriesService .class ).repository (otherRepoName );
302
289
303
290
logger .info ("--> verify loading repository data from newly mounted repository throws RepositoryException" );
@@ -317,7 +304,7 @@ public void testHandleSnapshotErrorWithBwCFormat() throws IOException {
317
304
final String indexName = "test-index" ;
318
305
createIndex (indexName );
319
306
320
- assertCreateSnapshotSuccess (repoName , "snapshot-1" );
307
+ createFullSnapshot (repoName , "snapshot-1" );
321
308
322
309
// In the old metadata version the shard level metadata could be moved to the next generation for all sorts of reasons, this should
323
310
// not break subsequent repository operations
@@ -331,7 +318,7 @@ public void testHandleSnapshotErrorWithBwCFormat() throws IOException {
331
318
logger .info ("--> delete old version snapshot" );
332
319
client ().admin ().cluster ().prepareDeleteSnapshot (repoName , oldVersionSnapshot ).get ();
333
320
334
- assertCreateSnapshotSuccess (repoName , "snapshot-2" );
321
+ createFullSnapshot (repoName , "snapshot-2" );
335
322
}
336
323
337
324
public void testRepairBrokenShardGenerations () throws IOException {
@@ -347,7 +334,7 @@ public void testRepairBrokenShardGenerations() throws IOException {
347
334
final String indexName = "test-index" ;
348
335
createIndex (indexName );
349
336
350
- assertCreateSnapshotSuccess (repoName , "snapshot-1" );
337
+ createFullSnapshot (repoName , "snapshot-1" );
351
338
352
339
logger .info ("--> delete old version snapshot" );
353
340
client ().admin ().cluster ().prepareDeleteSnapshot (repoName , oldVersionSnapshot ).get ();
@@ -381,17 +368,7 @@ public void testRepairBrokenShardGenerations() throws IOException {
381
368
client ().admin ().cluster ().prepareDeleteRepository (repoName ).get ();
382
369
createRepository (repoName , "fs" , repoPath );
383
370
384
- assertCreateSnapshotSuccess (repoName , "snapshot-2" );
385
- }
386
-
387
- private void assertCreateSnapshotSuccess (String repoName , String snapshotName ) {
388
- logger .info ("--> create another snapshot" );
389
- final SnapshotInfo snapshotInfo = client ().admin ().cluster ().prepareCreateSnapshot (repoName , snapshotName )
390
- .setWaitForCompletion (true ).get ().getSnapshotInfo ();
391
- assertThat (snapshotInfo .state (), is (SnapshotState .SUCCESS ));
392
- final int successfulShards = snapshotInfo .successfulShards ();
393
- assertThat (successfulShards , greaterThan (0 ));
394
- assertThat (successfulShards , equalTo (snapshotInfo .totalShards ()));
371
+ createFullSnapshot (repoName , "snapshot-2" );
395
372
}
396
373
397
374
private void assertRepositoryBlocked (Client client , String repo , String existingSnapshot ) {
0 commit comments