@@ -470,7 +470,7 @@ protected void sendRequest(Connection connection, long requestId, String action,
470
470
* TODO once checksum verification on snapshotting is implemented this test needs to be fixed or split into several
471
471
* parts... We should also corrupt files on the actual snapshot and check that we don't restore the corrupted shard.
472
472
*/
473
- @ TestLogging ("org.elasticsearch.monitor.fs:DEBUG " )
473
+ @ TestLogging ("org.elasticsearch.repositories:TRACE,org.elasticsearch.snapshots:TRACE " )
474
474
public void testCorruptFileThenSnapshotAndRestore () throws ExecutionException , InterruptedException , IOException {
475
475
int numDocs = scaledRandomIntBetween (100 , 1000 );
476
476
internalCluster ().ensureAtLeastNumDataNodes (2 );
@@ -494,6 +494,7 @@ public void testCorruptFileThenSnapshotAndRestore() throws ExecutionException, I
494
494
assertHitCount (countResponse , numDocs );
495
495
496
496
ShardRouting shardRouting = corruptRandomPrimaryFile (false );
497
+ logger .info ("--> shard {} has a corrupted file" , shardRouting );
497
498
// we don't corrupt segments.gen since S/R doesn't snapshot this file
498
499
// the other problem here why we can't corrupt segments.X files is that the snapshot flushes again before
499
500
// it snapshots and that will write a new segments.X+1 file
@@ -504,9 +505,12 @@ public void testCorruptFileThenSnapshotAndRestore() throws ExecutionException, I
504
505
.put ("compress" , randomBoolean ())
505
506
.put ("chunk_size" , randomIntBetween (100 , 1000 ), ByteSizeUnit .BYTES )));
506
507
logger .info ("--> snapshot" );
507
- CreateSnapshotResponse createSnapshotResponse = client ().admin ().cluster ().prepareCreateSnapshot ("test-repo" , "test-snap" ).setWaitForCompletion (true ).setIndices ("test" ).get ();
508
- assertThat (createSnapshotResponse .getSnapshotInfo ().state (), equalTo (SnapshotState .PARTIAL ));
509
- logger .info ("failed during snapshot -- maybe SI file got corrupted" );
508
+ final CreateSnapshotResponse createSnapshotResponse = client ().admin ().cluster ().prepareCreateSnapshot ("test-repo" , "test-snap" )
509
+ .setWaitForCompletion (true )
510
+ .setIndices ("test" )
511
+ .get ();
512
+ final SnapshotState snapshotState = createSnapshotResponse .getSnapshotInfo ().state ();
513
+ logger .info ("--> snapshot terminated with state " + snapshotState );
510
514
final List <Path > files = listShardFiles (shardRouting );
511
515
Path corruptedFile = null ;
512
516
for (Path file : files ) {
@@ -515,6 +519,11 @@ public void testCorruptFileThenSnapshotAndRestore() throws ExecutionException, I
515
519
break ;
516
520
}
517
521
}
522
+ if (snapshotState != SnapshotState .PARTIAL ) {
523
+ logger .info ("--> listing shard files for investigation" );
524
+ files .forEach (f -> logger .info ("path: {}" , f .toAbsolutePath ()));
525
+ }
526
+ assertThat (createSnapshotResponse .getSnapshotInfo ().state (), equalTo (SnapshotState .PARTIAL ));
518
527
assertThat (corruptedFile , notNullValue ());
519
528
}
520
529
0 commit comments