@Test public void shouldAbortOnNonCleanlyShutdown() throws Throwable { // given removeCheckPointFromTxLog( fileSystem, workingDatabaseLayout.databaseDirectory() ); try { // when GraphDatabaseService database = createGraphDatabaseService(); database.shutdown();// shutdown db in case test fails fail( "Should have been unable to start upgrade on old version" ); } catch ( RuntimeException e ) { // then assertThat( Exceptions.rootCause( e ), Matchers.instanceOf( StoreUpgrader.UnableToUpgradeException.class ) ); } }
@Test public void shouldRefuseToUpgradeIfAllOfTheStoresWereNotShutDownCleanly() throws IOException { File comparisonDirectory = directory.directory( "shouldRefuseToUpgradeIfAllOfTheStoresWereNotShutDownCleanly-comparison" ); removeCheckPointFromTxLog( fileSystem, databaseLayout.databaseDirectory() ); fileSystem.deleteRecursively( comparisonDirectory ); fileSystem.copyRecursively( databaseLayout.databaseDirectory(), comparisonDirectory ); PageCache pageCache = pageCacheRule.getPageCache( fileSystem ); UpgradableDatabase upgradableDatabase = getUpgradableDatabase( pageCache ); try { newUpgrader( upgradableDatabase, pageCache ).migrateIfNeeded( databaseLayout ); fail( "Should throw exception" ); } catch ( StoreUpgrader.UnableToUpgradeException e ) { // expected } verifyFilesHaveSameContent( fileSystem, comparisonDirectory, databaseLayout.databaseDirectory() ); }
@Test public void shouldRefuseToUpgradeIfAnyOfTheStoresWereNotShutDownCleanly() throws IOException { File comparisonDirectory = directory.directory( "shouldRefuseToUpgradeIfAnyOfTheStoresWereNotShutDownCleanly-comparison" ); removeCheckPointFromTxLog( fileSystem, databaseLayout.databaseDirectory() ); fileSystem.deleteRecursively( comparisonDirectory ); fileSystem.copyRecursively( databaseLayout.databaseDirectory(), comparisonDirectory ); PageCache pageCache = pageCacheRule.getPageCache( fileSystem ); UpgradableDatabase upgradableDatabase = getUpgradableDatabase( pageCache ); try { newUpgrader( upgradableDatabase, pageCache ).migrateIfNeeded( databaseLayout ); fail( "Should throw exception" ); } catch ( StoreUpgrader.UnableToUpgradeException e ) { // expected } verifyFilesHaveSameContent( fileSystem, comparisonDirectory, databaseLayout.databaseDirectory() ); }