private static CheckPointEntry checkPoint() { return checkPoint( null/*means self-position*/ ); }
@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 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 latestLogFileContainingACheckPointOnly() { // given setupLogFiles( logFile( checkPoint() ) ); // when LogTailInformation logTailInformation = tailScanner.getTailInformation(); // then assertLatestCheckPoint( true, false, NO_TRANSACTION_ID, endLogVersion, 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 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 latestLogFileContainingACheckPointAndAStartAfter() { // given long txId = 35; StartEntry start = start(); setupLogFiles( logFile( start, commit( txId ), checkPoint( start ) ) ); // when LogTailInformation logTailInformation = tailScanner.getTailInformation(); // then assertLatestCheckPoint( true, true, txId, 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 olderLogFileContainingACheckPointAndNewerFileContainingAStart() { // given long txId = 11; StartEntry start = start(); setupLogFiles( logFile( checkPoint() ), logFile( start, commit( txId ) ) ); // when LogTailInformation logTailInformation = tailScanner.getTailInformation(); // then assertLatestCheckPoint( true, true, txId, startLogVersion, 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 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 ); }
@Test public void twoLogFilesCheckPointTargetsPrevious() { // given long txId = 6; PositionEntry position = position(); setupLogFiles( logFile( start(), commit( txId - 1 ), position ), logFile( start(), commit( txId ) ), logFile( checkPoint( position ) ) ); // when LogTailInformation logTailInformation = tailScanner.getTailInformation(); // then assertLatestCheckPoint( true, true, txId, endLogVersion, logTailInformation ); }
@Test public void twoLogFilesSecondIsCorruptedBeforeAfterCommit() throws IOException { int firstTxId = 2; setupLogFiles( logFile( checkPoint() ), logFile( start(), commit( firstTxId ), start(), commit( 3 ) ) ); File highestLogFile = logFiles.getHighestLogFile(); fsRule.truncate( highestLogFile, fsRule.getFileSize( highestLogFile ) - 3 ); // when LogTailInformation logTailInformation = tailScanner.getTailInformation(); // then assertLatestCheckPoint( true, true, firstTxId, startLogVersion, logTailInformation ); }