Skip to content

Commit

Permalink
Faster RecordFormatTest
Browse files Browse the repository at this point in the history
by using static PageCache and also reduces iterations to 100k from 1M,
we'll get full coverage anyway statistically.
  • Loading branch information
tinwelint committed Sep 19, 2016
1 parent 518c33c commit 3db72d8
Showing 1 changed file with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
package org.neo4j.kernel.impl.store.format;

import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.RuleChain;
import org.junit.rules.TestName;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -58,20 +60,22 @@ public abstract class RecordFormatTest
private static final int PAGE_SIZE = (int) kibiBytes( 1 );

// Whoever is hit first
private static final long TEST_ITERATIONS = 1_000_000;
private static final long TEST_ITERATIONS = 100_000;
private static final long TEST_TIME = 1000;
private static final int DATA_SIZE = 100;
protected static final long NULL = Record.NULL_REFERENCE.intValue();

@ClassRule
public static final RandomRule random = new RandomRule();

private final EphemeralFileSystemRule fsRule = new EphemeralFileSystemRule();
private final PageCacheRule pageCacheRule = new PageCacheRule();
private final SuppressOutput suppressOutput = SuppressOutput.suppressAll();

private static final RandomRule random = new RandomRule();
private static final EphemeralFileSystemRule fsRule = new EphemeralFileSystemRule();
private static final PageCacheRule pageCacheRule = new PageCacheRule();
@Rule
public final RuleChain ruleChain = RuleChain.outerRule( pageCacheRule ).around( fsRule ).around( suppressOutput );
public final SuppressOutput suppressOutput = SuppressOutput.suppressAll();
@Rule
public final TestName name = new TestName();

@ClassRule
public static final RuleChain ruleChain = RuleChain.outerRule( pageCacheRule ).around( fsRule ).around( random );
private static PageCache pageCache;

public RecordKeys keys = FullyCoveringRecordKeys.INSTANCE;

Expand All @@ -87,6 +91,12 @@ protected RecordFormatTest( RecordFormats formats, int entityBits, int propertyB
this.propertyBits = propertyBits;
}

@BeforeClass
public static void setupPageCache()
{
pageCache = pageCacheRule.getPageCache( fsRule.get() );
}

@Before
public void before()
{
Expand Down Expand Up @@ -148,8 +158,7 @@ private <R extends AbstractBaseRecord> void verifyWriteAndRead(
Supplier<RecordKey<R>> keySupplier ) throws IOException
{
// GIVEN
PageCache pageCache = pageCacheRule.getPageCache( fsRule.get() );
try ( PagedFile storeFile = pageCache.map( new File( "store" ), PAGE_SIZE, CREATE ) )
try ( PagedFile storeFile = pageCache.map( new File( "store-" + name.getMethodName() ), PAGE_SIZE, CREATE ) )
{
RecordFormat<R> format = formatSupplier.get();
RecordKey<R> key = keySupplier.get();
Expand Down

0 comments on commit 3db72d8

Please sign in to comment.