@Test public void shouldExtractTransactionInformationFromMetaDataStore() throws Exception { // given // ... variables long txId = 42; long checksum = 123456789123456789L; long timestamp = 919191919191919191L; TransactionId expected = new TransactionId( txId, checksum, timestamp ); // ... and files DatabaseLayout databaseLayout = directory.databaseLayout(); File neoStore = databaseLayout.metadataStore(); neoStore.createNewFile(); // ... and mocks Config config = mock( Config.class ); LogService logService = mock( LogService.class ); // when // ... data in record setRecord( pageCache, neoStore, LAST_TRANSACTION_ID, txId ); setRecord( pageCache, neoStore, LAST_TRANSACTION_CHECKSUM, checksum ); setRecord( pageCache, neoStore, LAST_TRANSACTION_COMMIT_TIMESTAMP, timestamp ); // ... and with migrator StoreMigrator migrator = new StoreMigrator( fileSystemRule.get(), pageCache, config, logService, jobScheduler ); TransactionId actual = migrator.extractTransactionIdInformation( neoStore, txId ); // then assertEquals( expected, actual ); }
TransactionId lastTxInfo = extractTransactionIdInformation( neoStore, lastTxId ); LogPosition lastTxLogPosition = extractTransactionLogPosition( neoStore, directoryLayout, lastTxId );
@Test public void shouldGenerateTransactionInformationWhenLogsNotPresent() throws Exception { // given long txId = 42; DatabaseLayout databaseLayout = directory.databaseLayout(); File neoStore = databaseLayout.metadataStore(); neoStore.createNewFile(); Config config = mock( Config.class ); LogService logService = new SimpleLogService( NullLogProvider.getInstance(), NullLogProvider.getInstance() ); // when // ... transaction info not in neo store assertEquals( FIELD_NOT_PRESENT, getRecord( pageCache, neoStore, LAST_TRANSACTION_ID ) ); assertEquals( FIELD_NOT_PRESENT, getRecord( pageCache, neoStore, LAST_TRANSACTION_CHECKSUM ) ); assertEquals( FIELD_NOT_PRESENT, getRecord( pageCache, neoStore, LAST_TRANSACTION_COMMIT_TIMESTAMP ) ); // ... and with migrator StoreMigrator migrator = new StoreMigrator( fileSystemRule.get(), pageCache, config, logService, jobScheduler ); TransactionId actual = migrator.extractTransactionIdInformation( neoStore, txId ); // then assertEquals( txId, actual.transactionId() ); assertEquals( TransactionIdStore.UNKNOWN_TX_CHECKSUM, actual.checksum() ); assertEquals( TransactionIdStore.UNKNOWN_TX_COMMIT_TIMESTAMP, actual.commitTimestamp() ); }
@Test public void shouldGenerateTransactionInformationWhenLogsAreEmpty() throws Exception { // given long txId = 1; DatabaseLayout databaseLayout = directory.databaseLayout(); File neoStore = databaseLayout.metadataStore(); neoStore.createNewFile(); Config config = mock( Config.class ); LogService logService = new SimpleLogService( NullLogProvider.getInstance(), NullLogProvider.getInstance() ); // when // ... transaction info not in neo store assertEquals( FIELD_NOT_PRESENT, getRecord( pageCache, neoStore, LAST_TRANSACTION_ID ) ); assertEquals( FIELD_NOT_PRESENT, getRecord( pageCache, neoStore, LAST_TRANSACTION_CHECKSUM ) ); assertEquals( FIELD_NOT_PRESENT, getRecord( pageCache, neoStore, LAST_TRANSACTION_COMMIT_TIMESTAMP ) ); // ... and with migrator StoreMigrator migrator = new StoreMigrator( fileSystemRule.get(), pageCache, config, logService, jobScheduler ); TransactionId actual = migrator.extractTransactionIdInformation( neoStore, txId ); // then assertEquals( txId, actual.transactionId() ); assertEquals( TransactionIdStore.BASE_TX_CHECKSUM, actual.checksum() ); assertEquals( TransactionIdStore.BASE_TX_COMMIT_TIMESTAMP, actual.commitTimestamp() ); }
TransactionId lastTxInfo = extractTransactionIdInformation( neoStore, lastTxId ); LogPosition lastTxLogPosition = extractTransactionLogPosition( neoStore, directoryLayout, lastTxId );