Skip to content

Commit

Permalink
More tests passing and cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
MishaDemianenko committed Jul 23, 2018
1 parent 1782f6d commit 78ce3c8
Show file tree
Hide file tree
Showing 25 changed files with 90 additions and 89 deletions.
Expand Up @@ -49,7 +49,7 @@
public class DynamicIndexStoreViewIT public class DynamicIndexStoreViewIT
{ {
private final SuppressOutput suppressOutput = SuppressOutput.suppressAll(); private final SuppressOutput suppressOutput = SuppressOutput.suppressAll();
private final TestDirectory testDirectory = TestDirectory.testDirectory( getClass() ); private final TestDirectory testDirectory = TestDirectory.testDirectory();


@Rule @Rule
public RuleChain ruleChain = RuleChain.outerRule( testDirectory ).around( suppressOutput ); public RuleChain ruleChain = RuleChain.outerRule( testDirectory ).around( suppressOutput );
Expand Down
Expand Up @@ -46,7 +46,7 @@ public abstract class KernelExtensionFactoryContractTest
private final String key; private final String key;


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


public KernelExtensionFactoryContractTest( String key, Class<? extends KernelExtensionFactory<?>> extClass ) public KernelExtensionFactoryContractTest( String key, Class<? extends KernelExtensionFactory<?>> extClass )
{ {
Expand Down
Expand Up @@ -57,10 +57,10 @@
public class CheckConsistencyCommandTest public class CheckConsistencyCommandTest
{ {
@Rule @Rule
public TestDirectory testDir = TestDirectory.testDirectory( getClass() ); public final TestDirectory testDir = TestDirectory.testDirectory();


@Rule @Rule
public ExpectedException expect = ExpectedException.none(); public final ExpectedException expect = ExpectedException.none();


@Test @Test
public void runsConsistencyChecker() throws Exception public void runsConsistencyChecker() throws Exception
Expand Down
Expand Up @@ -19,7 +19,6 @@
*/ */
package org.neo4j.io; package org.neo4j.io;


import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;


public class NullOutputStream extends OutputStream public class NullOutputStream extends OutputStream
Expand Down
Expand Up @@ -48,7 +48,7 @@


public class NativeLabelScanStoreIT public class NativeLabelScanStoreIT
{ {
private final TestDirectory directory = TestDirectory.testDirectory( getClass() ); private final TestDirectory directory = TestDirectory.testDirectory();
private final PageCacheRule pageCacheRule = new PageCacheRule(); private final PageCacheRule pageCacheRule = new PageCacheRule();
private final LifeRule life = new LifeRule( true ); private final LifeRule life = new LifeRule( true );
private final RandomRule random = new RandomRule(); private final RandomRule random = new RandomRule();
Expand Down
Expand Up @@ -90,7 +90,7 @@ public abstract static class Compatibility
public OtherThreadRule<Void> threadC = new OtherThreadRule<>(); public OtherThreadRule<Void> threadC = new OtherThreadRule<>();


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


protected final LockingCompatibilityTestSuite suite; protected final LockingCompatibilityTestSuite suite;


Expand Down
Expand Up @@ -43,7 +43,7 @@
public class StoreVersionCheckTest public class StoreVersionCheckTest
{ {
private final DefaultFileSystemRule fileSystemRule = new DefaultFileSystemRule(); private final DefaultFileSystemRule fileSystemRule = new DefaultFileSystemRule();
private final TestDirectory directory = TestDirectory.testDirectory( getClass() ); private final TestDirectory directory = TestDirectory.testDirectory();
private final PageCacheRule pageCacheRule = new PageCacheRule(); private final PageCacheRule pageCacheRule = new PageCacheRule();


@Rule @Rule
Expand Down
Expand Up @@ -58,7 +58,7 @@
*/ */
public class TransactionLogFileRotateAndReadRaceIT public class TransactionLogFileRotateAndReadRaceIT
{ {
private final TestDirectory directory = TestDirectory.testDirectory( getClass() ); private final TestDirectory directory = TestDirectory.testDirectory();
private final LifeRule life = new LifeRule( true ); private final LifeRule life = new LifeRule( true );
private final DefaultFileSystemRule fileSystemRule = new DefaultFileSystemRule(); private final DefaultFileSystemRule fileSystemRule = new DefaultFileSystemRule();
private final OtherThreadRule<Void> t2 = new OtherThreadRule<>( getClass().getName() + "-T2" ); private final OtherThreadRule<Void> t2 = new OtherThreadRule<>( getClass().getName() + "-T2" );
Expand Down
Expand Up @@ -102,7 +102,7 @@ public static Collection<Boolean> data()
@Rule @Rule
public final RandomRule random = new RandomRule(); public final RandomRule random = new RandomRule();
@Rule @Rule
public final TestDirectory directory = TestDirectory.testDirectory( getClass() ); public final TestDirectory directory = TestDirectory.testDirectory();
private final Extractors extractors = new Extractors( ',' ); private final Extractors extractors = new Extractors( ',' );
@Parameter @Parameter
public Boolean allowMultilineFields; public Boolean allowMultilineFields;
Expand Down
Expand Up @@ -59,11 +59,11 @@
public class BackupToolIT public class BackupToolIT
{ {
@Rule @Rule
public TestDirectory testDirectory = TestDirectory.testDirectory( getClass()); public final TestDirectory testDirectory = TestDirectory.testDirectory();
@Rule @Rule
public ExpectedException expected = ExpectedException.none(); public final ExpectedException expected = ExpectedException.none();
@Rule @Rule
public EmbeddedDatabaseRule dbRule = new EmbeddedDatabaseRule().startLazily(); public final EmbeddedDatabaseRule dbRule = new EmbeddedDatabaseRule().startLazily();


private DefaultFileSystemAbstraction fs; private DefaultFileSystemAbstraction fs;
private PageCache pageCache; private PageCache pageCache;
Expand Down
Expand Up @@ -42,7 +42,7 @@
public class TestConfiguration public class TestConfiguration
{ {
public SuppressOutput suppressOutput = SuppressOutput.suppressAll(); public SuppressOutput suppressOutput = SuppressOutput.suppressAll();
public TestDirectory dir = TestDirectory.testDirectory( TestConfiguration.class ); public TestDirectory dir = TestDirectory.testDirectory();
@Rule @Rule
public RuleChain rules = RuleChain.outerRule( dir ).around( suppressOutput ); public RuleChain rules = RuleChain.outerRule( dir ).around( suppressOutput );


Expand Down
Expand Up @@ -75,7 +75,7 @@ public StoreFilesTest()


protected void createRules() protected void createRules()
{ {
testDirectory = TestDirectory.testDirectory( StoreFilesTest.class ); testDirectory = TestDirectory.testDirectory();
EphemeralFileSystemRule ephemeralFileSystemRule = new EphemeralFileSystemRule(); EphemeralFileSystemRule ephemeralFileSystemRule = new EphemeralFileSystemRule();
fileSystemRule = ephemeralFileSystemRule; fileSystemRule = ephemeralFileSystemRule;
pageCacheRule = new PageCacheRule(); pageCacheRule = new PageCacheRule();
Expand Down
Expand Up @@ -33,7 +33,7 @@ public class StoreFilesWithRealFileSystemTest extends StoreFilesTest
@Override @Override
protected void createRules() protected void createRules()
{ {
testDirectory = TestDirectory.testDirectory( StoreFilesWithRealFileSystemTest.class ); testDirectory = TestDirectory.testDirectory();
DefaultFileSystemRule defaultFileSystemRule = new DefaultFileSystemRule(); DefaultFileSystemRule defaultFileSystemRule = new DefaultFileSystemRule();
fileSystemRule = defaultFileSystemRule; fileSystemRule = defaultFileSystemRule;
pageCacheRule = new PageCacheRule( ); pageCacheRule = new PageCacheRule( );
Expand Down
Expand Up @@ -33,7 +33,6 @@
import org.neo4j.adversaries.CountingAdversary; import org.neo4j.adversaries.CountingAdversary;
import org.neo4j.adversaries.MethodGuardedAdversary; import org.neo4j.adversaries.MethodGuardedAdversary;
import org.neo4j.adversaries.fs.AdversarialFileSystemAbstraction; import org.neo4j.adversaries.fs.AdversarialFileSystemAbstraction;
import org.neo4j.causalclustering.messaging.EndOfStreamException;
import org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction; import org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction;
import org.neo4j.graphdb.mockfs.SelectiveFileSystemAbstraction; import org.neo4j.graphdb.mockfs.SelectiveFileSystemAbstraction;
import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.io.fs.FileSystemAbstraction;
Expand All @@ -54,7 +53,7 @@
public class DurableStateStorageIT public class DurableStateStorageIT
{ {


private final TestDirectory testDir = TestDirectory.testDirectory( getClass() ); private final TestDirectory testDir = TestDirectory.testDirectory();
private final EphemeralFileSystemRule fileSystemRule = new EphemeralFileSystemRule(); private final EphemeralFileSystemRule fileSystemRule = new EphemeralFileSystemRule();


@Rule @Rule
Expand Down
Expand Up @@ -45,18 +45,16 @@


public class CompositeConstraintIT public class CompositeConstraintIT
{ {

@Rule @Rule
public TestDirectory testDirectory = TestDirectory.testDirectory(); public final TestDirectory testDirectory = TestDirectory.testDirectory();
@Rule @Rule
public SuppressOutput suppressOutput = SuppressOutput.suppressAll(); public final SuppressOutput suppressOutput = SuppressOutput.suppressAll();


@Test @Test
public void compositeNodeKeyConstraintUpdate() throws Exception public void compositeNodeKeyConstraintUpdate() throws Exception
{ {
File storeDir = testDirectory.graphDbDir();
GraphDatabaseService database = new EnterpriseGraphDatabaseFactory() GraphDatabaseService database = new EnterpriseGraphDatabaseFactory()
.newEmbeddedDatabaseBuilder( storeDir ) .newEmbeddedDatabaseBuilder( testDirectory.directory() )
.setConfig( OnlineBackupSettings.online_backup_enabled, Settings.FALSE ) .setConfig( OnlineBackupSettings.online_backup_enabled, Settings.FALSE )
.newGraphDatabase(); .newGraphDatabase();


Expand All @@ -72,8 +70,7 @@ public void compositeNodeKeyConstraintUpdate() throws Exception


try ( Transaction transaction = database.beginTx() ) try ( Transaction transaction = database.beginTx() )
{ {
String query = String query = format( "CREATE CONSTRAINT ON (n:%s) ASSERT (n.%s,n.%s) IS NODE KEY", label.name(), "a", "b" );
format( "CREATE CONSTRAINT ON (n:%s) ASSERT (n.%s,n.%s) IS NODE KEY", label.name(), "a", "b" );
database.execute( query ); database.execute( query );
transaction.success(); transaction.success();
} }
Expand All @@ -89,15 +86,14 @@ public void compositeNodeKeyConstraintUpdate() throws Exception
} }
database.shutdown(); database.shutdown();


ConsistencyCheckService.Result consistencyCheckResult = checkDbConsistency( storeDir ); ConsistencyCheckService.Result consistencyCheckResult = checkDbConsistency( testDirectory.graphDbDir() );
assertTrue( "Database is consistent", consistencyCheckResult.isSuccessful() ); assertTrue( "Database is consistent", consistencyCheckResult.isSuccessful() );
} }


private static ConsistencyCheckService.Result checkDbConsistency( File storeDir ) private static ConsistencyCheckService.Result checkDbConsistency( File databaseDirectory )
throws ConsistencyCheckTool.ToolFailureException throws ConsistencyCheckTool.ToolFailureException
{ {
return ConsistencyCheckTool.runConsistencyCheckTool( new String[]{storeDir.getAbsolutePath()}, return ConsistencyCheckTool.runConsistencyCheckTool( new String[]{databaseDirectory.getAbsolutePath()}, System.out, System.err );
System.out, System.err );
} }


private static void awaitIndex( GraphDatabaseService database ) private static void awaitIndex( GraphDatabaseService database )
Expand Down
Expand Up @@ -41,7 +41,7 @@ public class CausalClusterInProcessRunnerIT
@Test @Test
public void shouldBootAndShutdownCluster() throws Exception public void shouldBootAndShutdownCluster() throws Exception
{ {
Path clusterPath = testDirectory.absolutePath().toPath(); Path clusterPath = testDirectory.directory().toPath().toAbsolutePath();
CausalClusterInProcessBuilder.PortPickingStrategy portPickingStrategy = new CausalClusterInProcessBuilder.PortPickingStrategy() CausalClusterInProcessBuilder.PortPickingStrategy portPickingStrategy = new CausalClusterInProcessBuilder.PortPickingStrategy()
{ {
Map<Integer, Integer> cache = new HashMap<>(); Map<Integer, Integer> cache = new HashMap<>();
Expand Down
Expand Up @@ -22,20 +22,20 @@
*/ */
package org.neo4j.kernel.impl.query; package org.neo4j.kernel.impl.query;


import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.List;

import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TestRule; import org.junit.rules.TestRule;
import org.junit.runners.model.Statement; import org.junit.runners.model.Statement;


import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.List;

import org.neo4j.graphdb.Result; import org.neo4j.graphdb.Result;
import org.neo4j.graphdb.Transaction; import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseBuilder; import org.neo4j.graphdb.factory.GraphDatabaseBuilder;
Expand Down Expand Up @@ -63,7 +63,7 @@
public class ShellQueryLoggingIT public class ShellQueryLoggingIT
{ {
private final EphemeralFileSystemRule fs = new EphemeralFileSystemRule(); private final EphemeralFileSystemRule fs = new EphemeralFileSystemRule();
private final TestDirectory dir = TestDirectory.testDirectory( getClass() ); private final TestDirectory dir = TestDirectory.testDirectory();
private final DatabaseRule db = new ImpermanentDatabaseRule() private final DatabaseRule db = new ImpermanentDatabaseRule()
{ {
@Override @Override
Expand Down
Expand Up @@ -67,32 +67,32 @@


import static org.neo4j.server.configuration.ServerSettings.jmx_module_enabled; import static org.neo4j.server.configuration.ServerSettings.jmx_module_enabled;
import static org.neo4j.server.database.LifecycleManagingDatabase.lifecycleManagingDatabase; import static org.neo4j.server.database.LifecycleManagingDatabase.lifecycleManagingDatabase;
import static org.neo4j.server.rest.discovery.CommunityDiscoverableURIs.communityDiscoverableURIs;


public class OpenEnterpriseNeoServer extends CommunityNeoServer public class OpenEnterpriseNeoServer extends CommunityNeoServer
{ {


// TODO:
private static final GraphFactory HA_FACTORY = ( config, dependencies ) -> private static final GraphFactory HA_FACTORY = ( config, dependencies ) ->
{ {
File storeDir = config.get( GraphDatabaseSettings.database_path ); File storeDir = config.get( GraphDatabaseSettings.database_path ).getParentFile();
return new HighlyAvailableGraphDatabase( storeDir, config, dependencies ); return new HighlyAvailableGraphDatabase( storeDir, config, dependencies );
}; };


private static final GraphFactory ENTERPRISE_FACTORY = ( config, dependencies ) -> private static final GraphFactory ENTERPRISE_FACTORY = ( config, dependencies ) ->
{ {
File storeDir = config.get( GraphDatabaseSettings.database_path ); File storeDir = config.get( GraphDatabaseSettings.database_path ).getParentFile();
return new EnterpriseGraphDatabase( storeDir, config, dependencies ); return new EnterpriseGraphDatabase( storeDir, config, dependencies );
}; };


private static final GraphFactory CORE_FACTORY = ( config, dependencies ) -> private static final GraphFactory CORE_FACTORY = ( config, dependencies ) ->
{ {
File storeDir = config.get( GraphDatabaseSettings.database_path ); File storeDir = config.get( GraphDatabaseSettings.database_path ).getParentFile();
return new CoreGraphDatabase( storeDir, config, dependencies ); return new CoreGraphDatabase( storeDir, config, dependencies );
}; };


private static final GraphFactory READ_REPLICA_FACTORY = ( config, dependencies ) -> private static final GraphFactory READ_REPLICA_FACTORY = ( config, dependencies ) ->
{ {
File storeDir = config.get( GraphDatabaseSettings.database_path ); File storeDir = config.get( GraphDatabaseSettings.database_path ).getParentFile();
return new ReadReplicaGraphDatabase( storeDir, config, dependencies ); return new ReadReplicaGraphDatabase( storeDir, config, dependencies );
}; };


Expand Down
Expand Up @@ -122,7 +122,7 @@ public void shouldExecuteReadAndWritesWhenDriverSuppliedWithAddressOfFollower()
assertEquals( 1, count ); assertEquals( 1, count );
} }


private int executeWriteAndReadThroughBolt( CoreClusterMember core ) throws TimeoutException private static int executeWriteAndReadThroughBolt( CoreClusterMember core ) throws TimeoutException
{ {
try ( Driver driver = GraphDatabase.driver( core.routingURI(), AuthTokens.basic( "neo4j", "neo4j" ) ) ) try ( Driver driver = GraphDatabase.driver( core.routingURI(), AuthTokens.basic( "neo4j", "neo4j" ) ) )
{ {
Expand Down Expand Up @@ -747,7 +747,7 @@ public void transactionsShouldNotAppearOnTheReadReplicaWhilePollingIsPaused() th
assertEquals( numberOfRequests, happyCount ); assertEquals( numberOfRequests, happyCount );
} }


private void executeReadQuery( Session session ) private static void executeReadQuery( Session session )
{ {
try ( Transaction tx = session.beginTransaction() ) try ( Transaction tx = session.beginTransaction() )
{ {
Expand All @@ -756,7 +756,7 @@ private void executeReadQuery( Session session )
} }
} }


private <T> T inExpirableSession( Driver driver, Function<Driver,Session> acquirer, Function<Session,T> op ) private static <T> T inExpirableSession( Driver driver, Function<Driver,Session> acquirer, Function<Session,T> op )
throws TimeoutException throws TimeoutException
{ {
long endTime = System.currentTimeMillis() + DEFAULT_TIMEOUT_MS; long endTime = System.currentTimeMillis() + DEFAULT_TIMEOUT_MS;
Expand Down
Expand Up @@ -43,6 +43,7 @@
import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.impl.store.format.highlimit.HighLimit; import org.neo4j.kernel.impl.store.format.highlimit.HighLimit;
import org.neo4j.kernel.impl.store.format.standard.Standard; import org.neo4j.kernel.impl.store.format.standard.Standard;
import org.neo4j.kernel.impl.transaction.state.DataSourceManager;
import org.neo4j.restore.RestoreDatabaseCommand; import org.neo4j.restore.RestoreDatabaseCommand;
import org.neo4j.test.causalclustering.ClusterRule; import org.neo4j.test.causalclustering.ClusterRule;


Expand Down Expand Up @@ -86,8 +87,9 @@ public void shouldReplicateTransactionToCoreMembers() throws Throwable
{ {
for ( CoreClusterMember core : cluster.coreMembers() ) for ( CoreClusterMember core : cluster.coreMembers() )
{ {
new RestoreDatabaseCommand( fileSystem, classicNeo4jStore, core.config(), core.settingValue( //TODO: looks strange
GraphDatabaseSettings.active_database.name() ), true ).execute(); new RestoreDatabaseCommand( fileSystem, new File( classicNeo4jStore, DataSourceManager.DEFAULT_DATABASE_NAME ), core.config(),
core.settingValue( GraphDatabaseSettings.active_database.name() ), true ).execute();
} }
} }


Expand Down
Expand Up @@ -56,7 +56,7 @@ public class HalfCreatedConstraintIT
@Test @Test
public void uniqueIndexWithoutOwningConstraintIsIgnoredDuringCheck() throws ConsistencyCheckTool.ToolFailureException, IOException public void uniqueIndexWithoutOwningConstraintIsIgnoredDuringCheck() throws ConsistencyCheckTool.ToolFailureException, IOException
{ {
File storeDir = testDirectory.graphDbDir(); File storeDir = testDirectory.directory();
Label marker = Label.label( "MARKER" ); Label marker = Label.label( "MARKER" );
String property = "property"; String property = "property";


Expand All @@ -72,12 +72,12 @@ public void uniqueIndexWithoutOwningConstraintIsIgnoredDuringCheck() throws Cons
database.shutdown(); database.shutdown();
} }


ConsistencyCheckService.Result checkResult = ConsistencyCheckService.Result checkResult = ConsistencyCheckTool.runConsistencyCheckTool( new String[]{testDirectory.graphDbDir().getAbsolutePath()},
ConsistencyCheckTool.runConsistencyCheckTool( new String[]{storeDir.getAbsolutePath()}, emptyPrintStream(), emptyPrintStream() ); emptyPrintStream(), emptyPrintStream() );
assertTrue( String.join( System.lineSeparator(), Files.readAllLines( checkResult.reportFile().toPath() ) ), checkResult.isSuccessful() ); assertTrue( String.join( System.lineSeparator(), Files.readAllLines( checkResult.reportFile().toPath() ) ), checkResult.isSuccessful() );
} }


private void waitForIndexPopulationFailure( GraphDatabaseService database ) private static void waitForIndexPopulationFailure( GraphDatabaseService database )
{ {
try ( Transaction ignored = database.beginTx() ) try ( Transaction ignored = database.beginTx() )
{ {
Expand All @@ -90,7 +90,7 @@ private void waitForIndexPopulationFailure( GraphDatabaseService database )
} }
} }


private void addIndex( GraphDatabaseService database ) private static void addIndex( GraphDatabaseService database )
{ {
try ( Transaction transaction = database.beginTx() ) try ( Transaction transaction = database.beginTx() )
{ {
Expand All @@ -103,7 +103,7 @@ private void addIndex( GraphDatabaseService database )
} }
} }


private void createNodes( Label marker, String property, GraphDatabaseService database ) private static void createNodes( Label marker, String property, GraphDatabaseService database )
{ {
try ( Transaction transaction = database.beginTx() ) try ( Transaction transaction = database.beginTx() )
{ {
Expand Down
Expand Up @@ -23,6 +23,7 @@
package org.neo4j.ha; package org.neo4j.ha;


import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.experimental.runners.Enclosed; import org.junit.experimental.runners.Enclosed;
Expand Down Expand Up @@ -57,6 +58,7 @@
import static org.neo4j.values.virtual.VirtualValues.EMPTY_MAP; import static org.neo4j.values.virtual.VirtualValues.EMPTY_MAP;


@RunWith( Enclosed.class ) @RunWith( Enclosed.class )
@Ignore
public class HAClusterStartupIT public class HAClusterStartupIT
{ {
public static class SimpleCluster public static class SimpleCluster
Expand Down
Expand Up @@ -40,7 +40,7 @@
public class SelfSignedCertificatesIT public class SelfSignedCertificatesIT
{ {
@Rule @Rule
public TestDirectory testDirectory = TestDirectory.testDirectory( getClass() ); public final TestDirectory testDirectory = TestDirectory.testDirectory();


@Test @Test
public void createSelfSignedCertificateWithCorrectPermissions() throws Exception public void createSelfSignedCertificateWithCorrectPermissions() throws Exception
Expand Down

0 comments on commit 78ce3c8

Please sign in to comment.