Skip to content

Commit

Permalink
Exclude partially cached .cfs file from SearchableSnapshotDirectorySt…
Browse files Browse the repository at this point in the history
…atsTests (#70006) (#70018)

Since #69861 CFS files read from FrozenIndexInput create 
dedicated frozen shared cache files when they are sliced. 
This does not play well with some tests that use the 
randomReadAndSlice to read files: this method can create 
overlapping slice/clone reads operations which makes it 
difficult to assert anything about CFS files with partial cache.

This commit prevent the tests to generate a .cfs file name 
when the partial cache is randomly picked up. As a follow 
up we should rework those test to make them more realistic 
with the new behavior.

Closes #70000
  • Loading branch information
tlrx authored Mar 5, 2021
1 parent e45db43 commit 26fa9d3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ protected byte[] randomReadAndSlice(IndexInput indexInput, int length) throws IO
case 3:
// Read using slice
len = randomIntBetween(1, length - readPos);
IndexInput slice = indexInput.slice(randomAlphaOfLength(10) + randomFileExtension(), readPos, len);
final String sliceExtension = randomValueOtherThan(".cfs", ESIndexInputTestCase::randomFileExtension);
IndexInput slice = indexInput.slice(randomAlphaOfLength(10) + sliceExtension, readPos, len);
temp = randomReadAndSlice(slice, len);
// assert that position in the original input didn't change
assertEquals(readPos, indexInput.getFilePointer());
Expand Down Expand Up @@ -121,7 +122,8 @@ protected void doRun() throws Exception {
clone = indexInput.clone();
} else {
final int sliceEnd = between(readEnd, length);
clone = indexInput.slice("slice" + randomAlphaOfLength(10) + randomFileExtension(), 0L, sliceEnd);
final String sliceExtension = randomValueOtherThan(".cfs", ESIndexInputTestCase::randomFileExtension);
clone = indexInput.slice("slice" + randomAlphaOfLength(10) + sliceExtension, 0L, sliceEnd);
}
startLatch.countDown();
startLatch.await();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.elasticsearch.common.TriConsumer;
import org.elasticsearch.common.UUIDs;
import org.elasticsearch.common.blobstore.BlobContainer;
import org.elasticsearch.common.lucene.store.ESIndexInputTestCase;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeUnit;
import org.elasticsearch.common.unit.ByteSizeValue;
Expand Down Expand Up @@ -605,8 +606,14 @@ private void executeTestCase(
final TriConsumer<String, byte[], SearchableSnapshotDirectory> test
) throws Exception {

final String fileName;
if (SearchableSnapshots.SNAPSHOT_PARTIAL_SETTING.get(indexSettings)) {
fileName = randomAlphaOfLength(10) + randomValueOtherThan(".cfs", ESIndexInputTestCase::randomFileExtension);
} else {
fileName = randomAlphaOfLength(10) + randomFileExtension();
}

final byte[] fileContent = randomByteArrayOfLength(randomIntBetween(10, MAX_FILE_LENGTH));
final String fileName = randomAlphaOfLength(10) + randomFileExtension();
final SnapshotId snapshotId = new SnapshotId("_name", "_uuid");
final IndexId indexId = new IndexId("_name", "_uuid");
final ShardId shardId = new ShardId("_name", "_uuid", 0);
Expand Down

0 comments on commit 26fa9d3

Please sign in to comment.