Search in sources :

Example 1 with RandomPageCacheTestHarness

use of org.neo4j.io.pagecache.randomharness.RandomPageCacheTestHarness 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 RandomPageCacheTestHarness

use of org.neo4j.io.pagecache.randomharness.RandomPageCacheTestHarness 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 RandomPageCacheTestHarness

use of org.neo4j.io.pagecache.randomharness.RandomPageCacheTestHarness 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 RandomPageCacheTestHarness

use of org.neo4j.io.pagecache.randomharness.RandomPageCacheTestHarness in project neo4j by neo4j.

the class LinearHistoryPageCacheTracerTest method makeSomeTestOutput.

@Ignore("This test is only here for checking that the output from the LinearHistoryPageCacheTracer looks good. " + "This is pretty subjective and requires manual inspection. Therefore there's no point in running it " + "automatically in all our builds. Instead, run it as needed when you make changes to the printout code.")
@Test
public void makeSomeTestOutput() throws Exception {
    LinearTracers linearTracers = LinearHistoryTracerFactory.pageCacheTracer();
    try (RandomPageCacheTestHarness harness = new RandomPageCacheTestHarness()) {
        harness.setUseAdversarialIO(true);
        harness.setTracer(linearTracers.getPageCacheTracer());
        harness.setCursorTracerSupplier(linearTracers.getCursorTracerSupplier());
        harness.setCommandCount(100);
        harness.setConcurrencyLevel(2);
        harness.setPreparation((pageCache, fs, files) -> linearTracers.processHistory(hEvent -> {
        }));
        harness.run(1, TimeUnit.MINUTES);
        linearTracers.printHistory(System.out);
    }
}
Also used : TimeUnit(java.util.concurrent.TimeUnit) Ignore(org.junit.Ignore) Test(org.junit.Test) RandomPageCacheTestHarness(org.neo4j.io.pagecache.randomharness.RandomPageCacheTestHarness) RandomPageCacheTestHarness(org.neo4j.io.pagecache.randomharness.RandomPageCacheTestHarness) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with RandomPageCacheTestHarness

use of org.neo4j.io.pagecache.randomharness.RandomPageCacheTestHarness in project neo4j by neo4j.

the class PageCacheHarnessTest method concurrentPageFaultingMustNotPutInterleavedDataIntoPages.

@Test(timeout = LONG_TIMEOUT_MILLIS)
public void concurrentPageFaultingMustNotPutInterleavedDataIntoPages() throws Exception {
    final int filePageCount = 11;
    final RecordFormat recordFormat = new PageCountRecordFormat();
    try (RandomPageCacheTestHarness harness = new RandomPageCacheTestHarness()) {
        harness.setConcurrencyLevel(11);
        harness.setUseAdversarialIO(false);
        harness.setCachePageCount(3);
        harness.setCachePageSize(pageCachePageSize);
        harness.setFilePageCount(filePageCount);
        harness.setFilePageSize(pageCachePageSize);
        harness.setInitialMappedFiles(1);
        harness.setCommandCount(10000);
        harness.setRecordFormat(recordFormat);
        harness.setFileSystem(fs);
        harness.disableCommands(FlushCache, FlushFile, MapFile, UnmapFile, WriteRecord, WriteMulti);
        harness.setPreparation((pageCache1, fs1, filesTouched) -> {
            File file = filesTouched.iterator().next();
            try (PagedFile pf = pageCache1.map(file, pageCachePageSize);
                PageCursor cursor = pf.io(0, PF_SHARED_WRITE_LOCK)) {
                for (int pageId = 0; pageId < filePageCount; pageId++) {
                    cursor.next();
                    recordFormat.fillWithRecords(cursor);
                }
            }
        });
        harness.run(LONG_TIMEOUT_MILLIS, MILLISECONDS);
    }
}
Also used : PagedFile(org.neo4j.io.pagecache.PagedFile) 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) PageCountRecordFormat(org.neo4j.io.pagecache.randomharness.PageCountRecordFormat) FlushFile(org.neo4j.io.pagecache.randomharness.Command.FlushFile) PagedFile(org.neo4j.io.pagecache.PagedFile) MapFile(org.neo4j.io.pagecache.randomharness.Command.MapFile) File(java.io.File) UnmapFile(org.neo4j.io.pagecache.randomharness.Command.UnmapFile) PageCursor(org.neo4j.io.pagecache.PageCursor) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 RandomPageCacheTestHarness (org.neo4j.io.pagecache.randomharness.RandomPageCacheTestHarness)6 StandardRecordFormat (org.neo4j.io.pagecache.randomharness.StandardRecordFormat)5 PageCountRecordFormat (org.neo4j.io.pagecache.randomharness.PageCountRecordFormat)4 RecordFormat (org.neo4j.io.pagecache.randomharness.RecordFormat)4 File (java.io.File)1 TimeUnit (java.util.concurrent.TimeUnit)1 Ignore (org.junit.Ignore)1 PageCursor (org.neo4j.io.pagecache.PageCursor)1 PagedFile (org.neo4j.io.pagecache.PagedFile)1 FlushFile (org.neo4j.io.pagecache.randomharness.Command.FlushFile)1 MapFile (org.neo4j.io.pagecache.randomharness.Command.MapFile)1 UnmapFile (org.neo4j.io.pagecache.randomharness.Command.UnmapFile)1