private void createGraphDbAndKillIt() { final GraphDatabaseService db = new TestGraphDatabaseFactory() .setFileSystem( fs.get() ) .newImpermanentDatabaseBuilder( storeDirectory.graphDbDir() ) .newGraphDatabase(); try ( Transaction tx = db.beginTx() ) { db.createNode( label( "FOO" ) ); db.createNode( label( "BAR" ) ); tx.success(); } fs.snapshot( shutdownDbAction( db ) ); }
@Test public void shouldExecuteRecoveryWhenStoreWasNonCleanlyShutdown() throws Exception { // Given createGraphDbAndKillIt(); Monitors monitors = new Monitors(); Recovery.Monitor listener = mock( Recovery.Monitor.class ); monitors.addMonitorListener( listener ); ConsistencyCheckTool consistencyCheckTool = newConsistencyCheckToolWith( monitors, mock( ConsistencyCheckTool.ExitHandle.class ), fs.get() ); // When consistencyCheckTool.run( "-recovery", storeDirectory.graphDbDir().getAbsolutePath() ); // Then verify( listener ).recoveryRequired( any( LogPosition.class ) ); verify( listener ).recoveryCompleted( anyInt() ); }
private EphemeralFileSystemAbstraction createDataBaseWithStateThatNeedsRecovery( File storeDir ) { EphemeralFileSystemAbstraction fileSystem = fs.get(); final GraphDatabaseService db = new TestGraphDatabaseFactory().setFileSystem( fileSystem ).newImpermanentDatabase( storeDir ); try ( Transaction tx = db.beginTx() ) { db.createNode(); tx.success(); } EphemeralFileSystemAbstraction snapshot = fileSystem.snapshot(); db.shutdown(); return snapshot; }