Search in sources :

Example 1 with StandardRecordFormat

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);
    }
}
Also used : RandomPageCacheTestHarness(org.neo4j.io.pagecache.randomharness.RandomPageCacheTestHarness) RecordFormat(org.neo4j.io.pagecache.randomharness.RecordFormat) PageCountRecordFormat(org.neo4j.io.pagecache.randomharness.PageCountRecordFormat) StandardRecordFormat(org.neo4j.io.pagecache.randomharness.StandardRecordFormat) StandardRecordFormat(org.neo4j.io.pagecache.randomharness.StandardRecordFormat) Test(org.junit.Test)

Example 2 with StandardRecordFormat

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);
    }
}
Also used : RandomPageCacheTestHarness(org.neo4j.io.pagecache.randomharness.RandomPageCacheTestHarness) StandardRecordFormat(org.neo4j.io.pagecache.randomharness.StandardRecordFormat) Test(org.junit.Test)

Example 3 with StandardRecordFormat

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);
    }
}
Also used : RandomPageCacheTestHarness(org.neo4j.io.pagecache.randomharness.RandomPageCacheTestHarness) RecordFormat(org.neo4j.io.pagecache.randomharness.RecordFormat) PageCountRecordFormat(org.neo4j.io.pagecache.randomharness.PageCountRecordFormat) StandardRecordFormat(org.neo4j.io.pagecache.randomharness.StandardRecordFormat) StandardRecordFormat(org.neo4j.io.pagecache.randomharness.StandardRecordFormat) Test(org.junit.Test)

Example 4 with StandardRecordFormat

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));
        }
    }
}
Also used : AdversarialPagedFile(org.neo4j.adversaries.pagecache.AdversarialPagedFile) StoreChannel(org.neo4j.io.fs.StoreChannel) DelegatingStoreChannel(org.neo4j.graphdb.mockfs.DelegatingStoreChannel) StandardRecordFormat(org.neo4j.io.pagecache.randomharness.StandardRecordFormat) Record(org.neo4j.io.pagecache.randomharness.Record) AdversarialPagedFile(org.neo4j.adversaries.pagecache.AdversarialPagedFile) File(java.io.File) Test(org.junit.Test)

Example 5 with StandardRecordFormat

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);
    }
}
Also used : RandomPageCacheTestHarness(org.neo4j.io.pagecache.randomharness.RandomPageCacheTestHarness) RecordFormat(org.neo4j.io.pagecache.randomharness.RecordFormat) PageCountRecordFormat(org.neo4j.io.pagecache.randomharness.PageCountRecordFormat) StandardRecordFormat(org.neo4j.io.pagecache.randomharness.StandardRecordFormat) StandardRecordFormat(org.neo4j.io.pagecache.randomharness.StandardRecordFormat) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 StandardRecordFormat (org.neo4j.io.pagecache.randomharness.StandardRecordFormat)5 RandomPageCacheTestHarness (org.neo4j.io.pagecache.randomharness.RandomPageCacheTestHarness)4 PageCountRecordFormat (org.neo4j.io.pagecache.randomharness.PageCountRecordFormat)3 RecordFormat (org.neo4j.io.pagecache.randomharness.RecordFormat)3 File (java.io.File)1 AdversarialPagedFile (org.neo4j.adversaries.pagecache.AdversarialPagedFile)1 DelegatingStoreChannel (org.neo4j.graphdb.mockfs.DelegatingStoreChannel)1 StoreChannel (org.neo4j.io.fs.StoreChannel)1 Record (org.neo4j.io.pagecache.randomharness.Record)1