@Test public void notAllowCreateDynamicStoreWithNegativeBlockSize() { Config config = Config.defaults(); StoreFactory sf = getStoreFactory( config, databaseLayout, fs.get(), NullLogProvider.getInstance() ); exception.expect( IllegalArgumentException.class ); exception.expectMessage( "Block size of dynamic array store should be positive integer." ); try ( NeoStores neoStores = sf.openNeoStores( true ) ) { neoStores.createDynamicArrayStore( new File( "someStore" ), new File( "someIdFile" ), IdType.ARRAY_BLOCK, -2 ); } }
StoreFactory factory = getStoreFactory( defaults, databaseLayout, fileSystem, LOG_PROVIDER ); NeoStores neoStore = factory.openAllNeoStores( true );
@Test public void impossibleToGetNotRequestedStore() { Config config = Config.defaults(); StoreFactory sf = getStoreFactory( config, databaseLayout, fs.get(), NullLogProvider.getInstance() ); exception.expect( IllegalStateException.class ); exception.expectMessage( "Specified store was not initialized. Please specify " + StoreType.META_DATA.name() + " as one of the stores types that should be open to be able to use it." ); try ( NeoStores neoStores = sf.openNeoStores( true, StoreType.NODE_LABEL ) ) { neoStores.getMetaDataStore(); } }
@Before public void setUpNeoStores() { databaseLayout = dir.databaseLayout(); Config config = Config.defaults(); pageCache = pageCacheRule.getPageCache( fs.get() ); StoreFactory sf = getStoreFactory( config, databaseLayout, fs.get(), NullLogProvider.getInstance() ); sf.openAllNeoStores( true ).close(); propertyKeyTokenHolder = new DelegatingTokenHolder( this::createPropertyKeyToken, TokenHolder.TYPE_PROPERTY_KEY ); }
@Test public void impossibleToGetStoreFromClosedNeoStoresContainer() { Config config = Config.defaults(); StoreFactory sf = getStoreFactory( config, databaseLayout, fs.get(), NullLogProvider.getInstance() ); NeoStores neoStores = sf.openAllNeoStores( true ); assertNotNull( neoStores.getMetaDataStore() ); neoStores.close(); exception.expect( IllegalStateException.class ); exception.expectMessage( "Specified store was already closed."); neoStores.getMetaDataStore(); }
@Test public void shouldInitializeTheTxIdToOne() { StoreFactory factory = getStoreFactory( Config.defaults(), dir.databaseLayout(), fs.get(), LOG_PROVIDER ); try ( NeoStores neoStores = factory.openAllNeoStores( true ) ) { neoStores.getMetaDataStore(); } try ( NeoStores neoStores = factory.openAllNeoStores() ) { long lastCommittedTransactionId = neoStores.getMetaDataStore().getLastCommittedTransactionId(); assertEquals( TransactionIdStore.BASE_TX_ID, lastCommittedTransactionId ); } }
@Test public void shouldThrowUnderlyingStorageExceptionWhenFailingToLoadStorage() { FileSystemAbstraction fileSystem = fs.get(); DatabaseLayout databaseLayout = dir.databaseLayout(); StoreFactory factory = getStoreFactory( Config.defaults(), databaseLayout, fileSystem, LOG_PROVIDER ); try ( NeoStores neoStores = factory.openAllNeoStores( true ) ) { neoStores.getMetaDataStore(); } File file = databaseLayout.metadataStore(); fileSystem.deleteFile( file ); exception.expect( StoreNotFoundException.class ); try ( NeoStores neoStores = factory.openAllNeoStores() ) { neoStores.getMetaDataStore(); } }
@Test public void shouldSetHighestTransactionIdWhenNeeded() { // GIVEN FileSystemAbstraction fileSystem = fs.get(); StoreFactory factory = getStoreFactory( Config.defaults(), databaseLayout, fileSystem, LOG_PROVIDER ); try ( NeoStores neoStore = factory.openAllNeoStores( true ) ) { MetaDataStore store = neoStore.getMetaDataStore(); store.setLastCommittedAndClosedTransactionId( 40, 4444, BASE_TX_COMMIT_TIMESTAMP, LogHeader.LOG_HEADER_SIZE, 0 ); // WHEN store.transactionCommitted( 42, 6666, BASE_TX_COMMIT_TIMESTAMP ); // THEN assertEquals( new TransactionId( 42, 6666, BASE_TX_COMMIT_TIMESTAMP ), store.getLastCommittedTransaction() ); assertArrayEquals( store.getLastClosedTransaction(), new long[]{40,0,LogHeader.LOG_HEADER_SIZE} ); } }
@Test public void shouldNotSetHighestTransactionIdWhenNeeded() { // GIVEN FileSystemAbstraction fileSystem = fs.get(); StoreFactory factory = getStoreFactory( Config.defaults(), databaseLayout, fileSystem, LOG_PROVIDER ); try ( NeoStores neoStore = factory.openAllNeoStores( true ) ) { MetaDataStore store = neoStore.getMetaDataStore(); store.setLastCommittedAndClosedTransactionId( 40, 4444, BASE_TX_COMMIT_TIMESTAMP, LogHeader.LOG_HEADER_SIZE, 0 ); // WHEN store.transactionCommitted( 39, 3333, BASE_TX_COMMIT_TIMESTAMP ); // THEN assertEquals( new TransactionId( 40, 4444, BASE_TX_COMMIT_TIMESTAMP ), store.getLastCommittedTransaction() ); assertArrayEquals( store.getLastClosedTransaction(), new long[]{40,0,LogHeader.LOG_HEADER_SIZE} ); } }
@Test public void setVersion() throws Exception { FileSystemAbstraction fileSystem = fs.get(); File storeDir = dir.directory(); createTestDatabase( fileSystem, storeDir ).shutdown(); DatabaseLayout databaseLayout = dir.databaseLayout(); assertEquals( 0, MetaDataStore.setRecord( pageCache, databaseLayout.metadataStore(), Position.LOG_VERSION, 10 ) ); assertEquals( 10, MetaDataStore.setRecord( pageCache, databaseLayout.metadataStore(), Position.LOG_VERSION, 12 ) ); Config config = Config.defaults(); StoreFactory sf = getStoreFactory( config, databaseLayout, fileSystem, LOG_PROVIDER ); NeoStores neoStores = sf.openAllNeoStores(); assertEquals( 12, neoStores.getMetaDataStore().getCurrentLogVersion() ); neoStores.close(); }