Tests: two corruptions can fix a file
In some of our tests we corrupt multiple places in a file randomly. If we corrupt the same place twice, we shouldn't fix the file by mistake.
This commit is contained in:
parent
45d3842214
commit
fb39caa8d4
|
@ -35,7 +35,6 @@ import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
|
|||
import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
|
||||
import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
|
||||
import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotResponse;
|
||||
import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse;
|
||||
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
|
||||
import org.elasticsearch.action.count.CountResponse;
|
||||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||
|
@ -493,9 +492,10 @@ public class CorruptedFileTest extends ElasticsearchIntegrationTest {
|
|||
long filePointer = raf.getFilePointer();
|
||||
byte b = raf.readByte();
|
||||
raf.seek(filePointer);
|
||||
raf.writeByte(~b);
|
||||
int corruptedValue = (b + 1) & 0xff;
|
||||
raf.writeByte(corruptedValue);
|
||||
raf.getFD().sync();
|
||||
logger.info("Corrupting file for shard {} -- flipping at position {} from {} to {} file: {}", shardRouting, filePointer, Integer.toHexString(b), Integer.toHexString(~b), fileToCorrupt.getName());
|
||||
logger.info("Corrupting file for shard {} -- flipping at position {} from {} to {} file: {}", shardRouting, filePointer, Integer.toHexString(b), Integer.toHexString(corruptedValue), fileToCorrupt.getName());
|
||||
}
|
||||
long checksumAfterCorruption;
|
||||
long actualChecksumAfterCorruption;
|
||||
|
|
|
@ -139,9 +139,10 @@ public class CorruptedTranslogTests extends ElasticsearchIntegrationTest {
|
|||
long filePointer = raf.getFilePointer();
|
||||
byte b = raf.readByte();
|
||||
raf.seek(filePointer);
|
||||
raf.writeByte(~b);
|
||||
int corruptedValue = (b + 1) & 0xff;
|
||||
raf.writeByte(corruptedValue);
|
||||
raf.getFD().sync();
|
||||
logger.info("--> corrupting file {} -- flipping at position {} from {} to {} file: {}", fileToCorrupt.getName(), filePointer, Integer.toHexString(b), Integer.toHexString(~b), fileToCorrupt);
|
||||
logger.info("--> corrupting file {} -- flipping at position {} from {} to {} file: {}", fileToCorrupt.getName(), filePointer, Integer.toHexString(b), Integer.toHexString(corruptedValue), fileToCorrupt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue