From 5578499d61f7838d732cee8075740e0797d4f0ef Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Mon, 11 May 2015 10:34:26 +0200 Subject: [PATCH] [TEST] Only corrupt translog header today we can't detecte truncation corruption --- .../org/elasticsearch/index/store/CorruptedTranslogTests.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/elasticsearch/index/store/CorruptedTranslogTests.java b/src/test/java/org/elasticsearch/index/store/CorruptedTranslogTests.java index 13962d8d159..9b55cf2cb2e 100644 --- a/src/test/java/org/elasticsearch/index/store/CorruptedTranslogTests.java +++ b/src/test/java/org/elasticsearch/index/store/CorruptedTranslogTests.java @@ -35,6 +35,7 @@ import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.translog.Translog; +import org.elasticsearch.index.translog.TranslogStreams; import org.elasticsearch.monitor.fs.FsStats; import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.elasticsearch.test.engine.MockEngineSupport; @@ -149,7 +150,7 @@ public class CorruptedTranslogTests extends ElasticsearchIntegrationTest { fileToCorrupt = RandomPicks.randomFrom(getRandom(), files); try (FileChannel raf = FileChannel.open(fileToCorrupt, StandardOpenOption.READ, StandardOpenOption.WRITE)) { // read - raf.position(randomIntBetween(0, (int) Math.min(Integer.MAX_VALUE, raf.size() - 1))); + raf.position(randomIntBetween(0, (int) Math.min(TranslogStreams.LATEST.headerLength(), raf.size() - 1))); // only corrupt the header to ensure we actually fail long filePointer = raf.position(); ByteBuffer bb = ByteBuffer.wrap(new byte[1]); raf.read(bb);