Skip to content

Commit

Permalink
Make TestDirectory use testsuite class instead to not allow parallel …
Browse files Browse the repository at this point in the history
…execution
  • Loading branch information
klaren committed Aug 30, 2017
1 parent 611f8d8 commit 4cd9e8d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 30 deletions.
Expand Up @@ -45,17 +45,18 @@ public class PageCacheAndDependenciesRule implements TestRule

public PageCacheAndDependenciesRule()
{
this( () -> new EphemeralFileSystemRule() );
this( EphemeralFileSystemRule::new, null );
}

/**
* @param fsSupplier as {@link Supplier} to make it clear that it is this class that owns the created
* {@link FileSystemRule} instance.
* @param clazz class to make distinctions for test directories
*/
public PageCacheAndDependenciesRule( Supplier<FileSystemRule<? extends FileSystemAbstraction>> fsSupplier )
public PageCacheAndDependenciesRule( Supplier<FileSystemRule<? extends FileSystemAbstraction>> fsSupplier, Class<?> clazz )
{
this.fs = fsSupplier.get();
this.directory = TestDirectory.testDirectory( fs );
this.directory = TestDirectory.testDirectory( clazz, fs );
this.chain = RuleChain.outerRule( fs ).around( directory ).around( pageCacheRule );
}

Expand Down
Expand Up @@ -53,7 +53,7 @@ public abstract class IndexProviderCompatibilityTestSuite
public abstract static class Compatibility
{
@Rule
public PageCacheAndDependenciesRule pageCacheAndDependenciesRule = new PageCacheAndDependenciesRule( DefaultFileSystemRule::new );
public final PageCacheAndDependenciesRule pageCacheAndDependenciesRule;

protected File graphDbDir;
protected FileSystemAbstraction fs;
Expand All @@ -74,6 +74,7 @@ public Compatibility( IndexProviderCompatibilityTestSuite testSuite, IndexDescri
{
this.testSuite = testSuite;
this.descriptor = descriptor;
pageCacheAndDependenciesRule = new PageCacheAndDependenciesRule( DefaultFileSystemRule::new, testSuite.getClass() );
}

protected void withPopulator( IndexPopulator populator, ThrowingConsumer<IndexPopulator,Exception> runWithPopulator ) throws Exception
Expand Down
Expand Up @@ -24,10 +24,9 @@
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;

import java.io.File;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
Expand All @@ -53,15 +52,11 @@
import org.neo4j.kernel.internal.GraphDatabaseAPI;
import org.neo4j.kernel.lifecycle.Lifecycle;
import org.neo4j.test.TestGraphDatabaseFactory;
import org.neo4j.test.rule.TestDirectory;

import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;

import static java.util.Arrays.asList;

import static org.neo4j.kernel.impl.locking.LockService.LockType;

@Ignore( "Not a test. This is a compatibility suite that provides test cases for verifying" +
Expand Down Expand Up @@ -133,6 +128,20 @@ public UniqueConstraintCompatibility( IndexProviderCompatibilityTestSuite testSu
* There's a lot of work to be done here.
*/

@Before
public void setUp()
{
TestGraphDatabaseFactory dbFactory = new TestGraphDatabaseFactory();
dbFactory.setKernelExtensions( Collections.singletonList( new PredefinedSchemaIndexProviderFactory( indexProvider ) ) );
db = dbFactory.newImpermanentDatabase( graphDbDir );
}

@After
public void tearDown()
{
db.shutdown();
}

// -- Tests:

@Test
Expand Down Expand Up @@ -982,26 +991,6 @@ private static void awaitUninterruptibly( CountDownLatch latch )
}
}

// -- Set Up: Environment parts

@Rule
public TestDirectory testDirectory = TestDirectory.testDirectory( getClass() );

@Before
public void setUp()
{
File storeDir = testDirectory.graphDbDir();
TestGraphDatabaseFactory dbfactory = new TestGraphDatabaseFactory();
dbfactory.setKernelExtensions( asList( new PredefinedSchemaIndexProviderFactory( indexProvider ) ) );
db = dbfactory.newImpermanentDatabase( storeDir );
}

@After
public void tearDown()
{
db.shutdown();
}

private static class PredefinedSchemaIndexProviderFactory extends KernelExtensionFactory<PredefinedSchemaIndexProviderFactory.NoDeps>
{
private final SchemaIndexProvider indexProvider;
Expand Down

0 comments on commit 4cd9e8d

Please sign in to comment.