use of org.neo4j.io.pagecache.randomharness.StandardRecordFormat in project neo4j by neo4j.
the class PageCacheHarnessTest method concurrentFlushingWithMischiefMustNotPutInterleavedDataIntoFile.
@Test(timeout = LONG_TIMEOUT_MILLIS)
public void concurrentFlushingWithMischiefMustNotPutInterleavedDataIntoFile() throws Exception {
final RecordFormat recordFormat = new StandardRecordFormat();
final int filePageCount = 2_000;
try (RandomPageCacheTestHarness harness = new RandomPageCacheTestHarness()) {
harness.setConcurrencyLevel(16);
harness.setUseAdversarialIO(true);
harness.setMischiefRate(0.5);
harness.setFailureRate(0.0);
harness.setErrorRate(0.0);
harness.setCachePageCount(filePageCount / 2);
harness.setFilePageCount(filePageCount);
harness.setCachePageSize(pageCachePageSize);
harness.setFilePageSize(pageCachePageSize);
harness.setInitialMappedFiles(3);
harness.setCommandCount(15_000);
harness.setFileSystem(fs);
harness.disableCommands(MapFile, UnmapFile, ReadRecord, ReadMulti);
harness.setVerification(filesAreCorrectlyWrittenVerification(recordFormat, filePageCount));
harness.run(LONG_TIMEOUT_MILLIS, MILLISECONDS);
}
}
use of org.neo4j.io.pagecache.randomharness.StandardRecordFormat in project neo4j by neo4j.
the class PageCacheHarnessTest method readsAndWritesMustBeMutuallyConsistent.
@RepeatRule.Repeat(times = 10)
@Test(timeout = SEMI_LONG_TIMEOUT_MILLIS)
public void readsAndWritesMustBeMutuallyConsistent() throws Exception {
int filePageCount = 100;
try (RandomPageCacheTestHarness harness = new RandomPageCacheTestHarness()) {
harness.disableCommands(FlushCache, FlushFile, MapFile, UnmapFile);
harness.setCommandProbabilityFactor(ReadRecord, 0.5);
harness.setCommandProbabilityFactor(WriteRecord, 0.5);
harness.setConcurrencyLevel(8);
harness.setFilePageCount(filePageCount);
harness.setInitialMappedFiles(1);
harness.setCachePageSize(pageCachePageSize);
harness.setFilePageSize(pageCachePageSize);
harness.setVerification(filesAreCorrectlyWrittenVerification(new StandardRecordFormat(), filePageCount));
harness.run(SEMI_LONG_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
}
}
use of org.neo4j.io.pagecache.randomharness.StandardRecordFormat in project neo4j by neo4j.
the class PageCacheHarnessTest method concurrentFlushingWithFailuresMustNotPutInterleavedDataIntoFile.
@Test(timeout = LONG_TIMEOUT_MILLIS)
public void concurrentFlushingWithFailuresMustNotPutInterleavedDataIntoFile() throws Exception {
final RecordFormat recordFormat = new StandardRecordFormat();
final int filePageCount = 20_000;
try (RandomPageCacheTestHarness harness = new RandomPageCacheTestHarness()) {
harness.setConcurrencyLevel(16);
harness.setUseAdversarialIO(true);
harness.setMischiefRate(0.0);
harness.setFailureRate(0.5);
harness.setErrorRate(0.0);
harness.setCachePageCount(filePageCount / 2);
harness.setFilePageCount(filePageCount);
harness.setCachePageSize(pageCachePageSize);
harness.setFilePageSize(pageCachePageSize);
harness.setInitialMappedFiles(3);
harness.setCommandCount(150_000);
harness.setFileSystem(fs);
harness.disableCommands(MapFile, UnmapFile, ReadRecord, ReadMulti);
harness.setVerification(filesAreCorrectlyWrittenVerification(recordFormat, filePageCount));
harness.run(LONG_TIMEOUT_MILLIS, MILLISECONDS);
}
}
use of org.neo4j.io.pagecache.randomharness.StandardRecordFormat in project neo4j by neo4j.
the class PageCacheTest method mustReadZerosFromBeyondEndOfFile.
@Test(timeout = SEMI_LONG_TIMEOUT_MILLIS)
public void mustReadZerosFromBeyondEndOfFile() throws Exception {
StandardRecordFormat recordFormat = new StandardRecordFormat();
File[] files = { file("1"), file("2"), file("3"), file("4"), file("5"), file("6"), file("7"), file("8"), file("9"), file("0"), file("A"), file("B") };
for (int fileId = 0; fileId < files.length; fileId++) {
File file = files[fileId];
StoreChannel channel = fs.open(file, "rw");
for (int recordId = 0; recordId < fileId + 1; recordId++) {
Record record = recordFormat.createRecord(file, recordId);
recordFormat.writeRecord(record, channel);
}
channel.close();
}
int pageSize = nextPowerOf2(recordFormat.getRecordSize() * (files.length + 1));
getPageCache(fs, 2, pageSize, PageCacheTracer.NULL, PageCursorTracerSupplier.NULL);
int fileId = files.length;
while (fileId-- > 0) {
File file = files[fileId];
try (PagedFile pf = pageCache.map(file, pageSize);
PageCursor cursor = pf.io(0, PF_SHARED_READ_LOCK)) {
int pageCount = 0;
while (cursor.next()) {
pageCount++;
recordFormat.assertRecordsWrittenCorrectly(cursor);
}
assertThat("pages in file " + file, pageCount, greaterThan(0));
}
}
}
use of org.neo4j.io.pagecache.randomharness.StandardRecordFormat in project neo4j by neo4j.
the class PageCacheHarnessTest method concurrentFlushingMustNotPutInterleavedDataIntoFile.
@Test(timeout = LONG_TIMEOUT_MILLIS)
public void concurrentFlushingMustNotPutInterleavedDataIntoFile() throws Exception {
final RecordFormat recordFormat = new StandardRecordFormat();
final int filePageCount = 2_000;
try (RandomPageCacheTestHarness harness = new RandomPageCacheTestHarness()) {
harness.setConcurrencyLevel(16);
harness.setUseAdversarialIO(false);
harness.setCachePageCount(filePageCount / 2);
harness.setFilePageCount(filePageCount);
harness.setCachePageSize(pageCachePageSize);
harness.setFilePageSize(pageCachePageSize);
harness.setInitialMappedFiles(3);
harness.setCommandCount(15_000);
harness.setFileSystem(fs);
harness.disableCommands(MapFile, UnmapFile, ReadRecord, ReadMulti);
harness.setVerification(filesAreCorrectlyWrittenVerification(recordFormat, filePageCount));
harness.run(LONG_TIMEOUT_MILLIS, MILLISECONDS);
}
}
Aggregations