@Test public void stillAcceptLatestVersionWhenUpgradeIsAllowed() { when( tailScanner.getTailInformation() ).thenReturn( new OnlyVersionTailInformation( LogEntryVersion.CURRENT ) ); LogVersionUpgradeChecker.check( tailScanner, Config.defaults( GraphDatabaseSettings.allow_upgrade, "true") ); }
@Test public void acceptOlderLogsWhenUpgradeIsAllowed() { when( tailScanner.getTailInformation() ).thenReturn( new OnlyVersionTailInformation( LogEntryVersion.V2_3 ) ); LogVersionUpgradeChecker.check( tailScanner, Config.defaults( GraphDatabaseSettings.allow_upgrade, "true") ); }
@Test public void noThrowWhenLatestVersionAndUpgradeIsNotAllowed() { when( tailScanner.getTailInformation() ).thenReturn( new OnlyVersionTailInformation( LogEntryVersion.CURRENT ) ); LogVersionUpgradeChecker.check( tailScanner, Config.defaults( GraphDatabaseSettings.allow_upgrade, "false") ); }
@Test public void throwWhenVersionIsOlderAndUpgradeIsNotAllowed() { when( tailScanner.getTailInformation() ).thenReturn( new OnlyVersionTailInformation( LogEntryVersion.V2_3 ) ); expect.expect( UpgradeNotAllowedByConfigurationException.class ); LogVersionUpgradeChecker.check( tailScanner, Config.defaults( GraphDatabaseSettings.allow_upgrade, "false") ); }
@Test public void noLogFilesFound() { // given no files setupLogFiles(); // when LogTailInformation logTailInformation = tailScanner.getTailInformation(); // then assertLatestCheckPoint( false, false, NO_TRANSACTION_ID, -1, logTailInformation ); }
@Test public void oneLogFileNoCheckPoints() { // given setupLogFiles( logFile() ); // when LogTailInformation logTailInformation = tailScanner.getTailInformation(); // then assertLatestCheckPoint( false, true, NO_TRANSACTION_ID, endLogVersion, logTailInformation ); }
@Test public void twoLogFilesNoCheckPoints() { // given setupLogFiles( logFile(), logFile() ); // when LogTailInformation logTailInformation = tailScanner.getTailInformation(); // then assertLatestCheckPoint( false, true, NO_TRANSACTION_ID, startLogVersion, logTailInformation ); }
@Test public void latestLogFileContainingACheckPointAndAStartBefore() { // given setupLogFiles( logFile( start(), checkPoint() ) ); // when LogTailInformation logTailInformation = tailScanner.getTailInformation(); // then assertLatestCheckPoint( true, false, NO_TRANSACTION_ID, endLogVersion, logTailInformation ); }
@Test public void oneLogFileNoCheckPointsOneStart() { // given long txId = 10; setupLogFiles( logFile( start(), commit( txId ) ) ); // when LogTailInformation logTailInformation = tailScanner.getTailInformation(); // then assertLatestCheckPoint( false, true, txId, endLogVersion, logTailInformation ); }
@Test public void twoLogFilesNoCheckPointsOneStartWithoutCommit() { // given setupLogFiles( logFile(), logFile( start() ) ); // when LogTailInformation logTailInformation = tailScanner.getTailInformation(); // then assertLatestCheckPoint( false, true, NO_TRANSACTION_ID, startLogVersion, logTailInformation ); }
@Test public void latestLogFileContainingACheckPointAndAStartWithoutCommitAfter() { // given StartEntry start = start(); setupLogFiles( logFile( start, checkPoint( start ) ) ); // when LogTailInformation logTailInformation = tailScanner.getTailInformation(); // then assertLatestCheckPoint( true, true, NO_TRANSACTION_ID, endLogVersion, logTailInformation ); }
@Test public void olderLogFileContainingACheckPointAndNewerFileIsEmpty() { // given StartEntry start = start(); setupLogFiles( logFile( start, checkPoint() ), logFile() ); // when LogTailInformation logTailInformation = tailScanner.getTailInformation(); // then assertLatestCheckPoint( true, true, NO_TRANSACTION_ID, startLogVersion, logTailInformation ); }
@Test public void olderLogFileContainingAStartAndNewerFileContainingACheckPointPointingToAPreviousPositionThanStartWithoutCommit() { // given StartEntry start = start(); setupLogFiles( logFile( start ), logFile( checkPoint( start ) ) ); // when LogTailInformation logTailInformation = tailScanner.getTailInformation(); // then assertLatestCheckPoint( true, false, NO_TRANSACTION_ID, endLogVersion, logTailInformation ); }
@Test public void latestLogFileContainingMultipleCheckPointsOneStartInBetween() { // given setupLogFiles( logFile( checkPoint(), start(), checkPoint() ) ); // when LogTailInformation logTailInformation = tailScanner.getTailInformation(); // then assertLatestCheckPoint( true, false, NO_TRANSACTION_ID, endLogVersion, logTailInformation ); }
@Test public void olderLogFileContainingAStartAndNewerFileContainingACheckPointPointingToAPreviousPositionThanStart() { // given long txId = 123; StartEntry start = start(); setupLogFiles( logFile( start, commit( txId ) ), logFile( checkPoint( start ) ) ); // when LogTailInformation logTailInformation = tailScanner.getTailInformation(); // then assertLatestCheckPoint( true, true, txId, endLogVersion, logTailInformation ); }
@Test public void latestLogFileContainingMultipleCheckPointsOneStartAfterBoth() { // given long txId = 11; setupLogFiles( logFile( checkPoint(), checkPoint(), start(), commit( txId ) ) ); // when LogTailInformation logTailInformation = tailScanner.getTailInformation(); // then assertLatestCheckPoint( true, true, txId, endLogVersion, logTailInformation ); }
@Test public void latestLogEmptyStartEntryBeforeAndAfterCheckPointInTheLastButOneLog() { // given long txId = 432; setupLogFiles( logFile( start(), checkPoint(), start(), commit( txId ) ), logFile() ); // when LogTailInformation logTailInformation = tailScanner.getTailInformation(); // then assertLatestCheckPoint( true, true, txId, startLogVersion, logTailInformation ); }
@Test public void twoLogFilesNoCheckPointsTwoCommits() { // given long txId = 21; setupLogFiles( logFile(), logFile( start(), commit( txId ), start(), commit( txId + 1 ) ) ); // when LogTailInformation logTailInformation = tailScanner.getTailInformation(); // then assertLatestCheckPoint( false, true, txId, startLogVersion, logTailInformation ); }
@Test public void olderLogFileContainingAStartAndNewerFileContainingACheckPointPointingToALaterPositionThanStart() { // given PositionEntry position = position(); setupLogFiles( logFile( start(), commit( 3 ), position ), logFile( checkPoint( position ) ) ); // when LogTailInformation logTailInformation = tailScanner.getTailInformation(); // then assertLatestCheckPoint( true, false, NO_TRANSACTION_ID, endLogVersion, logTailInformation ); }
@Test public void twoLogFilesSecondIsCorruptedBeforeCommit() throws IOException { setupLogFiles( logFile( checkPoint() ), logFile( start(), commit( 2 ) ) ); File highestLogFile = logFiles.getHighestLogFile(); fsRule.truncate( highestLogFile, fsRule.getFileSize( highestLogFile ) - 3 ); // when LogTailInformation logTailInformation = tailScanner.getTailInformation(); // then assertLatestCheckPoint( true, true, NO_TRANSACTION_ID, startLogVersion, logTailInformation ); }