Skip to content

Commit

Permalink
Fix Gradle check
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitkala committed Jun 7, 2023
1 parent 35ae04a commit e3c48fe
Showing 1 changed file with 0 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,57 +48,4 @@ public void testReplicaSyncingFromRemoteStore() throws IOException {
assertDocs(replicaShard, "1", "2");
closeShards(primaryShard, replicaShard);
}

public void testReplicaSyncingFromRemoteStoreWithMissingSegmentFile() throws IOException {
Path remotePath = createTempDir();
ReplicationGroup shards = createGroup(1, settings, indexMapping, new NRTReplicationEngineFactory(), remotePath);
final IndexShard primaryShard = shards.getPrimary();
final IndexShard replicaShard = shards.getReplicas().get(0);
shards.startPrimary();
shards.startAll();
// Ingest docs into primary
indexDoc(primaryShard, "_doc", "1");
indexDoc(primaryShard, "_doc", "2");
primaryShard.refresh("test");
assertDocs(primaryShard, "1", "2");

// Copy the metadata file
Directory remoteFSDirectory = new NIOFSDirectory(remotePath.resolve("indices/_na_/0/index/"));
String metadataFile = Arrays.stream(remoteFSDirectory.listAll())
.filter(f -> f.startsWith("metadata"))
.max(Comparator.comparing(String::valueOf))
.get();
logger.info("Copying metadata from {}", metadataFile);
byte[] metadataBytes;
try (IndexInput indexInput = remoteFSDirectory.openInput(metadataFile, IOContext.DEFAULT)) {
metadataBytes = new byte[(int) indexInput.length()];
indexInput.readBytes(metadataBytes, 0, (int) indexInput.length());
}

// Add more docs to primary and refresh
indexDoc(primaryShard, "_doc", "3");
indexDoc(primaryShard, "_doc", "4");
primaryShard.refresh("test");
assertDocs(primaryShard, "1", "2", "3", "4");

// Override the metadata file with older content to simulate the race condition
metadataFile = Arrays.stream(remoteFSDirectory.listAll())
.filter(f -> f.startsWith("metadata"))
.max(Comparator.comparing(String::valueOf))
.get();
logger.info("Overriding metadata content for {}", metadataFile);
remoteFSDirectory.deleteFile(metadataFile);
IndexOutput output = remoteFSDirectory.createOutput(metadataFile, IOContext.DEFAULT);
output.writeBytes(metadataBytes, metadataBytes.length);
output.close();
assertThrows(IndexShardRecoveryException.class, () -> replicaShard.syncSegmentsFromRemoteSegmentStore(true, true, false));

indexDoc(primaryShard, "_doc", "5");
indexDoc(primaryShard, "_doc", "6");
primaryShard.refresh("test");
assertDocs(primaryShard, "1", "2", "3", "4", "5", "6");
replicaShard.syncSegmentsFromRemoteSegmentStore(true, true, false);
assertDocs(replicaShard, "1", "2", "3", "4", "5", "6");
closeShards(primaryShard, replicaShard);
}
}

0 comments on commit e3c48fe

Please sign in to comment.