Skip to content

Commit

Permalink
Rename test directory and databases rules methods to better represent
Browse files Browse the repository at this point in the history
what they providing, introduce database directory helper methods.
  • Loading branch information
MishaDemianenko committed Jul 23, 2018
1 parent 029019a commit 58631f6
Show file tree
Hide file tree
Showing 140 changed files with 373 additions and 350 deletions.
Expand Up @@ -72,7 +72,7 @@ public void shouldShutdownCorrectlyWhenCheckPointingOnShutdownFails() throws Exc


try try
{ {
factory.newEmbeddedDatabase( testDirectory.graphDbDir() ).shutdown(); factory.newEmbeddedDatabase( testDirectory.databaseDir() ).shutdown();
fail( "Should have thrown" ); fail( "Should have thrown" );
} }
catch ( LifecycleException ex ) catch ( LifecycleException ex )
Expand Down
Expand Up @@ -51,7 +51,7 @@ public void startTheDatabaseWithWrongVersionShouldFailWithUpgradeNotAllowed() th
{ {
// given // given
// create a store // create a store
File storeDir = testDirectory.directory(); File storeDir = testDirectory.storeDir();
GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabase( storeDir ); GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabase( storeDir );
try ( Transaction tx = db.beginTx() ) try ( Transaction tx = db.beginTx() )
{ {
Expand All @@ -64,7 +64,7 @@ public void startTheDatabaseWithWrongVersionShouldFailWithUpgradeNotAllowed() th
try ( FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(); try ( FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
PageCache pageCache = StandalonePageCacheFactory.createPageCache( fileSystem ) ) PageCache pageCache = StandalonePageCacheFactory.createPageCache( fileSystem ) )
{ {
MetaDataStore.setRecord( pageCache, new File( testDirectory.graphDbDir(), MetaDataStore.DEFAULT_NAME ), MetaDataStore.setRecord( pageCache, new File( testDirectory.databaseDir(), MetaDataStore.DEFAULT_NAME ),
MetaDataStore.Position.STORE_VERSION, MetaDataStore.versionStringToLong( "bad" )); MetaDataStore.Position.STORE_VERSION, MetaDataStore.versionStringToLong( "bad" ));
} }


Expand All @@ -88,7 +88,7 @@ public void startTheDatabaseWithWrongVersionShouldFailAlsoWhenUpgradeIsAllowed()
{ {
// given // given
// create a store // create a store
File storeDir = testDirectory.directory(); File storeDir = testDirectory.storeDir();
GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabase( storeDir ); GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabase( storeDir );
try ( Transaction tx = db.beginTx() ) try ( Transaction tx = db.beginTx() )
{ {
Expand All @@ -102,7 +102,7 @@ public void startTheDatabaseWithWrongVersionShouldFailAlsoWhenUpgradeIsAllowed()
try ( FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(); try ( FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
PageCache pageCache = StandalonePageCacheFactory.createPageCache( fileSystem ) ) PageCache pageCache = StandalonePageCacheFactory.createPageCache( fileSystem ) )
{ {
MetaDataStore.setRecord( pageCache, new File( testDirectory.graphDbDir(), MetaDataStore.DEFAULT_NAME ), MetaDataStore.setRecord( pageCache, new File( testDirectory.databaseDir(), MetaDataStore.DEFAULT_NAME ),
MetaDataStore.Position.STORE_VERSION, MetaDataStore.versionStringToLong( badStoreVersion ) ); MetaDataStore.Position.STORE_VERSION, MetaDataStore.versionStringToLong( badStoreVersion ) );
} }


Expand Down
Expand Up @@ -41,7 +41,6 @@
import org.neo4j.kernel.impl.store.format.standard.StandardV2_3; import org.neo4j.kernel.impl.store.format.standard.StandardV2_3;
import org.neo4j.kernel.impl.storemigration.StoreUpgrader; import org.neo4j.kernel.impl.storemigration.StoreUpgrader;
import org.neo4j.kernel.impl.storemigration.StoreVersionCheck; import org.neo4j.kernel.impl.storemigration.StoreVersionCheck;
import org.neo4j.kernel.impl.transaction.state.DataSourceManager;
import org.neo4j.test.TestGraphDatabaseFactory; import org.neo4j.test.TestGraphDatabaseFactory;
import org.neo4j.test.rule.PageCacheRule; import org.neo4j.test.rule.PageCacheRule;
import org.neo4j.test.rule.TestDirectory; import org.neo4j.test.rule.TestDirectory;
Expand Down Expand Up @@ -87,8 +86,8 @@ public void setup() throws IOException
{ {
fileSystem = fileSystemRule.get(); fileSystem = fileSystemRule.get();
PageCache pageCache = pageCacheRule.getPageCache( fileSystem ); PageCache pageCache = pageCacheRule.getPageCache( fileSystem );
workingStoreDir = testDir.directory( "working_" + version ); workingStoreDir = testDir.storeDir( "working_" + version );
workingDatabaseDirectory = new File( workingStoreDir, DataSourceManager.DEFAULT_DATABASE_NAME ); workingDatabaseDirectory = testDir.databaseDir( workingStoreDir );
check = new StoreVersionCheck( pageCache ); check = new StoreVersionCheck( pageCache );
File prepareDirectory = testDir.directory( "prepare_" + version ); File prepareDirectory = testDir.directory( "prepare_" + version );
prepareSampleLegacyDatabase( version, fileSystem, workingDatabaseDirectory, prepareDirectory ); prepareSampleLegacyDatabase( version, fileSystem, workingDatabaseDirectory, prepareDirectory );
Expand Down
Expand Up @@ -55,7 +55,6 @@
import org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader; import org.neo4j.kernel.impl.transaction.log.entry.VersionAwareLogEntryReader;
import org.neo4j.kernel.impl.transaction.log.files.LogFiles; import org.neo4j.kernel.impl.transaction.log.files.LogFiles;
import org.neo4j.kernel.impl.transaction.log.files.LogFilesBuilder; import org.neo4j.kernel.impl.transaction.log.files.LogFilesBuilder;
import org.neo4j.kernel.impl.transaction.state.DataSourceManager;
import org.neo4j.kernel.impl.util.monitoring.ProgressReporter; import org.neo4j.kernel.impl.util.monitoring.ProgressReporter;
import org.neo4j.kernel.monitoring.Monitors; import org.neo4j.kernel.monitoring.Monitors;
import org.neo4j.kernel.recovery.LogTailScanner; import org.neo4j.kernel.recovery.LogTailScanner;
Expand Down Expand Up @@ -102,8 +101,8 @@ public static Collection<String> versions()
@Before @Before
public void setUpLabelScanStore() public void setUpLabelScanStore()
{ {
workingDirectory = directory.directory( "working" ); workingDirectory = directory.storeDir( "working" );
workingDatabaseDirectory = new File( workingDirectory, DataSourceManager.DEFAULT_DATABASE_NAME ); workingDatabaseDirectory = directory.databaseDir( workingDirectory );
prepareDirectory = directory.directory( "prepare" ); prepareDirectory = directory.directory( "prepare" );
} }


Expand Down
Expand Up @@ -160,7 +160,7 @@ public void shouldNotReportDuplicateForHugeLongValues() throws Exception
// given // given
ConsistencyCheckService service = new ConsistencyCheckService(); ConsistencyCheckService service = new ConsistencyCheckService();
Config configuration = Config.defaults( settings() ); Config configuration = Config.defaults( settings() );
GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( testDirectory.graphDbDir() ) GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( testDirectory.databaseDir() )
.setConfig( GraphDatabaseSettings.record_format, getRecordFormatName() ) .setConfig( GraphDatabaseSettings.record_format, getRecordFormatName() )
.setConfig( "dbms.backup.enabled", "false" ) .setConfig( "dbms.backup.enabled", "false" )
.newGraphDatabase(); .newGraphDatabase();
Expand Down Expand Up @@ -215,7 +215,7 @@ public void shouldAllowGraphCheckDisabled() throws ConsistencyCheckIncompleteExc
public void shouldReportMissingSchemaIndex() throws Exception public void shouldReportMissingSchemaIndex() throws Exception
{ {
// given // given
File databaseDirectory = testDirectory.graphDbDir(); File databaseDirectory = testDirectory.databaseDir();
GraphDatabaseService gds = getGraphDatabaseService( testDirectory.directory() ); GraphDatabaseService gds = getGraphDatabaseService( testDirectory.directory() );


Label label = Label.label( "label" ); Label label = Label.label( "label" );
Expand Down Expand Up @@ -246,7 +246,7 @@ public void shouldReportMissingSchemaIndex() throws Exception
@Test @Test
public void oldLuceneSchemaIndexShouldBeConsideredConsistentWithFusionProvider() throws Exception public void oldLuceneSchemaIndexShouldBeConsideredConsistentWithFusionProvider() throws Exception
{ {
File storeDir = testDirectory.graphDbDir(); File storeDir = testDirectory.databaseDir();
String defaultSchemaProvider = GraphDatabaseSettings.default_schema_provider.name(); String defaultSchemaProvider = GraphDatabaseSettings.default_schema_provider.name();
Label label = Label.label( "label" ); Label label = Label.label( "label" );
String propKey = "propKey"; String propKey = "propKey";
Expand Down
Expand Up @@ -218,7 +218,7 @@ public void failWhenStoreWasNonCleanlyShutdown() throws Exception
{ {
createGraphDbAndKillIt( Config.defaults() ); createGraphDbAndKillIt( Config.defaults() );


runConsistencyCheckToolWith( fs.get(), testDirectory.graphDbDir().getAbsolutePath() ); runConsistencyCheckToolWith( fs.get(), testDirectory.databaseDir().getAbsolutePath() );
} }


@Test( expected = ToolFailureException.class ) @Test( expected = ToolFailureException.class )
Expand All @@ -228,7 +228,7 @@ public void failOnNotCleanlyShutdownStoreWithLogsInCustomRelativeLocation() thro
Config customConfig = Config.defaults( logical_logs_location, "otherLocation" ); Config customConfig = Config.defaults( logical_logs_location, "otherLocation" );
createGraphDbAndKillIt( customConfig ); createGraphDbAndKillIt( customConfig );
MapUtil.store( customConfig.getRaw(), customConfigFile ); MapUtil.store( customConfig.getRaw(), customConfigFile );
String[] args = {testDirectory.graphDbDir().getPath(), "-config", customConfigFile.getPath()}; String[] args = {testDirectory.databaseDir().getPath(), "-config", customConfigFile.getPath()};


runConsistencyCheckToolWith( fs.get(), args ); runConsistencyCheckToolWith( fs.get(), args );
} }
Expand All @@ -241,7 +241,7 @@ public void failOnNotCleanlyShutdownStoreWithLogsInCustomAbsoluteLocation() thro
Config customConfig = Config.defaults( logical_logs_location, otherLocation.getAbsolutePath() ); Config customConfig = Config.defaults( logical_logs_location, otherLocation.getAbsolutePath() );
createGraphDbAndKillIt( customConfig ); createGraphDbAndKillIt( customConfig );
MapUtil.store( customConfig.getRaw(), customConfigFile ); MapUtil.store( customConfig.getRaw(), customConfigFile );
String[] args = {testDirectory.graphDbDir().getPath(), "-config", customConfigFile.getPath()}; String[] args = {testDirectory.databaseDir().getPath(), "-config", customConfigFile.getPath()};


runConsistencyCheckToolWith( fs.get(), args ); runConsistencyCheckToolWith( fs.get(), args );
} }
Expand Down
Expand Up @@ -88,7 +88,7 @@ public void mustReportSuccessfulForConsistentLabelScanStore() throws Exception
@Test @Test
public void reportNotCleanLabelIndex() throws IOException, ConsistencyCheckIncompleteException public void reportNotCleanLabelIndex() throws IOException, ConsistencyCheckIncompleteException
{ {
File databaseDirectory = db.getTestDirectory().graphDbDir(); File databaseDirectory = db.databaseDirectory();
someData(); someData();
db.resolveDependency( CheckPointer.class ).forceCheckPoint( new SimpleTriggerInfo( "forcedCheckpoint" ) ); db.resolveDependency( CheckPointer.class ).forceCheckPoint( new SimpleTriggerInfo( "forcedCheckpoint" ) );
File labelIndexFileCopy = new File( databaseDirectory, "label_index_copy" ); File labelIndexFileCopy = new File( databaseDirectory, "label_index_copy" );
Expand All @@ -113,7 +113,7 @@ public void reportNotCleanLabelIndex() throws IOException, ConsistencyCheckIncom
@Test @Test
public void reportNotCleanLabelIndexWithCorrectData() throws IOException, ConsistencyCheckIncompleteException public void reportNotCleanLabelIndexWithCorrectData() throws IOException, ConsistencyCheckIncompleteException
{ {
File databaseDirectory = db.getTestDirectory().graphDbDir(); File databaseDirectory = db.databaseDirectory();
someData(); someData();
db.resolveDependency( CheckPointer.class ).forceCheckPoint( new SimpleTriggerInfo( "forcedCheckpoint" ) ); db.resolveDependency( CheckPointer.class ).forceCheckPoint( new SimpleTriggerInfo( "forcedCheckpoint" ) );
File labelIndexFileCopy = new File( databaseDirectory, "label_index_copy" ); File labelIndexFileCopy = new File( databaseDirectory, "label_index_copy" );
Expand Down Expand Up @@ -268,15 +268,15 @@ private void replaceLabelIndexWithCopy( File labelIndexFileCopy ) throws IOExcep
{ {
db.restartDatabase( ( fs, directory ) -> db.restartDatabase( ( fs, directory ) ->
{ {
File databaseDirectory = db.getTestDirectory().graphDbDir(); File databaseDirectory = db.databaseDirectory();
fs.deleteFile( new File( databaseDirectory, NativeLabelScanStore.FILE_NAME ) ); fs.deleteFile( new File( databaseDirectory, NativeLabelScanStore.FILE_NAME ) );
fs.copyFile( labelIndexFileCopy, new File( databaseDirectory, NativeLabelScanStore.FILE_NAME ) ); fs.copyFile( labelIndexFileCopy, new File( databaseDirectory, NativeLabelScanStore.FILE_NAME ) );
} ); } );
} }


private File copyLabelIndexFile() throws IOException private File copyLabelIndexFile() throws IOException
{ {
File databaseDirectory = db.getTestDirectory().graphDbDir(); File databaseDirectory = db.databaseDirectory();
File labelIndexFileCopy = new File( databaseDirectory, "label_index_copy" ); File labelIndexFileCopy = new File( databaseDirectory, "label_index_copy" );
db.restartDatabase( ( fs, directory ) -> db.restartDatabase( ( fs, directory ) ->
fs.copyFile( new File( databaseDirectory, NativeLabelScanStore.FILE_NAME ), labelIndexFileCopy ) ); fs.copyFile( new File( databaseDirectory, NativeLabelScanStore.FILE_NAME ), labelIndexFileCopy ) );
Expand Down Expand Up @@ -373,7 +373,7 @@ private ConsistencyCheckService.Result fullConsistencyCheck()
{ {
ConsistencyCheckService service = new ConsistencyCheckService(); ConsistencyCheckService service = new ConsistencyCheckService();
Config config = Config.defaults(); Config config = Config.defaults();
return service.runFullConsistencyCheck( db.getTestDirectory().graphDbDir(), config, NONE, log, fsa, true, return service.runFullConsistencyCheck( db.databaseDirectory(), config, NONE, log, fsa, true,
new ConsistencyFlags( config ) ); new ConsistencyFlags( config ) );
} }
} }
Expand Down
Expand Up @@ -165,7 +165,7 @@ public DirectStoreAccess directStoreAccess()
Config config = Config.defaults(); Config config = Config.defaults();
DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory( fileSystem ); DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory( fileSystem );
StoreFactory storeFactory = new StoreFactory( StoreFactory storeFactory = new StoreFactory(
directory.graphDbDir(), config, idGeneratorFactory, pageCache, fileSystem, logProvider, EmptyVersionContextSupplier.EMPTY ); directory.databaseDir(), config, idGeneratorFactory, pageCache, fileSystem, logProvider, EmptyVersionContextSupplier.EMPTY );
neoStore = storeFactory.openAllNeoStores(); neoStore = storeFactory.openAllNeoStores();
StoreAccess nativeStores; StoreAccess nativeStores;
if ( keepStatistics ) if ( keepStatistics )
Expand All @@ -187,7 +187,7 @@ public DirectStoreAccess directStoreAccess()


Monitors monitors = new Monitors(); Monitors monitors = new Monitors();
LabelScanStore labelScanStore = startLabelScanStore( pageCache, indexStoreView, monitors ); LabelScanStore labelScanStore = startLabelScanStore( pageCache, indexStoreView, monitors );
IndexProviderMap indexes = createIndexes( pageCache, fileSystem, directory.graphDbDir(), config, logProvider, monitors); IndexProviderMap indexes = createIndexes( pageCache, fileSystem, directory.databaseDir(), config, logProvider, monitors);
directStoreAccess = new DirectStoreAccess( nativeStores, labelScanStore, indexes ); directStoreAccess = new DirectStoreAccess( nativeStores, labelScanStore, indexes );
} }
return directStoreAccess; return directStoreAccess;
Expand All @@ -196,7 +196,7 @@ public DirectStoreAccess directStoreAccess()
private LabelScanStore startLabelScanStore( PageCache pageCache, IndexStoreView indexStoreView, Monitors monitors ) private LabelScanStore startLabelScanStore( PageCache pageCache, IndexStoreView indexStoreView, Monitors monitors )
{ {
NativeLabelScanStore labelScanStore = NativeLabelScanStore labelScanStore =
new NativeLabelScanStore( pageCache, directory.graphDbDir(), fileSystem, new FullLabelStream( indexStoreView ), false, monitors, new NativeLabelScanStore( pageCache, directory.databaseDir(), fileSystem, new FullLabelStream( indexStoreView ), false, monitors,
RecoveryCleanupWorkCollector.IMMEDIATE ); RecoveryCleanupWorkCollector.IMMEDIATE );
try try
{ {
Expand All @@ -221,7 +221,7 @@ private IndexProviderMap createIndexes( PageCache pageCache, FileSystemAbstracti


public File databaseDirectory() public File databaseDirectory()
{ {
return directory.graphDbDir(); return directory.databaseDir();
} }


public Statistics getAccessStatistics() public Statistics getAccessStatistics()
Expand Down Expand Up @@ -571,7 +571,7 @@ public void evaluate() throws Throwable
try try
{ {
generateInitialData(); generateInitialData();
start( GraphStoreFixture.this.directory.graphDbDir() ); start( GraphStoreFixture.this.directory.databaseDir() );
try try
{ {
base.evaluate(); base.evaluate();
Expand Down
Expand Up @@ -76,7 +76,7 @@ public class IndexConsistencyIT
@Test @Test
public void reportNotCleanNativeIndex() throws IOException, ConsistencyCheckIncompleteException public void reportNotCleanNativeIndex() throws IOException, ConsistencyCheckIncompleteException
{ {
File databaseDirectory = db.getTestDirectory().graphDbDir(); File databaseDirectory = db.databaseDirectory();
someData(); someData();
resolveComponent( CheckPointer.class ).forceCheckPoint( new SimpleTriggerInfo( "forcedCheckpoint" ) ); resolveComponent( CheckPointer.class ).forceCheckPoint( new SimpleTriggerInfo( "forcedCheckpoint" ) );
File indexesCopy = new File( databaseDirectory, "indexesCopy" ); File indexesCopy = new File( databaseDirectory, "indexesCopy" );
Expand Down Expand Up @@ -238,7 +238,7 @@ private ConsistencyCheckService.Result fullConsistencyCheck()
{ {
ConsistencyCheckService service = new ConsistencyCheckService(); ConsistencyCheckService service = new ConsistencyCheckService();
Config config = Config.defaults(); Config config = Config.defaults();
return service.runFullConsistencyCheck( db.getTestDirectory().graphDbDir(), config, NONE, log, fsa, true ); return service.runFullConsistencyCheck( db.databaseDirectory(), config, NONE, log, fsa, true );
} }
} }
} }
Expand Up @@ -149,7 +149,7 @@ public void shouldDetectSabotagedRelationshipWhereEverItIs() throws Exception
private StoreFactory newStoreFactory( PageCache pageCache ) private StoreFactory newStoreFactory( PageCache pageCache )
{ {
FileSystemAbstraction fileSystem = fileSystemRule.get(); FileSystemAbstraction fileSystem = fileSystemRule.get();
return new StoreFactory( directory.graphDbDir(), getTuningConfiguration(), return new StoreFactory( directory.databaseDir(), getTuningConfiguration(),
new DefaultIdGeneratorFactory( fileSystem ), pageCache, fileSystem, NullLogProvider.getInstance(), new DefaultIdGeneratorFactory( fileSystem ), pageCache, fileSystem, NullLogProvider.getInstance(),
EmptyVersionContextSupplier.EMPTY ); EmptyVersionContextSupplier.EMPTY );
} }
Expand Down
Expand Up @@ -148,7 +148,7 @@ private StoreAccess createStoreWithOneHighDegreeNodeAndSeveralDegreeTwoNodes( in
} }
database.shutdown(); database.shutdown();
PageCache pageCache = pageCacheRule.getPageCache( fileSystemRule.get() ); PageCache pageCache = pageCacheRule.getPageCache( fileSystemRule.get() );
StoreAccess storeAccess = new StoreAccess( fileSystemRule.get(), pageCache, testDirectory.graphDbDir(), StoreAccess storeAccess = new StoreAccess( fileSystemRule.get(), pageCache, testDirectory.databaseDir(),
Config.defaults() ); Config.defaults() );
return storeAccess.initialize(); return storeAccess.initialize();
} }
Expand Down
Expand Up @@ -113,7 +113,7 @@ public void removesOldMessagesLog() throws Exception


assertTrue( oldMessagesLog.createNewFile() ); assertTrue( oldMessagesLog.createNewFile() );


File destination = testDir.graphDbDir(); File destination = testDir.databaseDir();


String[] arguments = {"--mode=database", "--database=bar", "--from=" + from.getAbsolutePath()}; String[] arguments = {"--mode=database", "--database=bar", "--from=" + from.getAbsolutePath()};
DatabaseImporter importer = DatabaseImporter importer =
Expand Down
Expand Up @@ -60,7 +60,7 @@ public class DiagnosticsReportCommandIT
@Before @Before
public void setUp() public void setUp()
{ {
database = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder( testDirectory.graphDbDir() ) database = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder( testDirectory.databaseDir() )
.newGraphDatabase(); .newGraphDatabase();
} }


Expand Down

0 comments on commit 58631f6

Please sign in to comment.