Search in sources :

Example 76 with TestDatabaseManagementServiceBuilder

use of org.neo4j.test.TestDatabaseManagementServiceBuilder in project neo4j by neo4j.

the class MissingStoreFilesRecoveryIT method setUp.

@BeforeEach
void setUp() throws IOException {
    serviceBuilder = new TestDatabaseManagementServiceBuilder(testDirectory.homePath());
    managementService = serviceBuilder.build();
    var databaseApi = defaultDatabase(managementService);
    createSomeData(databaseApi);
    databaseLayout = databaseApi.databaseLayout();
    defaultNamedDatabaseId = getDatabaseManager().databaseIdRepository().getByName(DEFAULT_DATABASE_NAME).get();
    managementService.shutdown();
}
Also used : TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 77 with TestDatabaseManagementServiceBuilder

use of org.neo4j.test.TestDatabaseManagementServiceBuilder in project neo4j by neo4j.

the class RecoveryCorruptedTransactionLogIT method setUp.

@BeforeEach
void setUp() {
    monitors.addMonitorListener(recoveryMonitor);
    databaseFactory = new TestDatabaseManagementServiceBuilder(databaseLayout).setConfig(checkpoint_logical_log_keep_threshold, 25).setInternalLogProvider(logProvider).setMonitors(monitors).setFileSystem(fileSystem);
    txOffsetAfterStart = startStopDatabaseAndGetTxOffset();
}
Also used : TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 78 with TestDatabaseManagementServiceBuilder

use of org.neo4j.test.TestDatabaseManagementServiceBuilder in project neo4j by neo4j.

the class TestTxEntries method testStartEntryWrittenOnceOnRollback.

@Test
void testStartEntryWrittenOnceOnRollback() {
    Path storeDir = testDirectory.homePath();
    DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(storeDir).setFileSystem(fs).impermanent().build();
    final GraphDatabaseService db = managementService.database(DEFAULT_DATABASE_NAME);
    createSomeTransactions(db);
    EphemeralFileSystemAbstraction snapshot = fs.snapshot();
    managementService.shutdown();
    managementService = new TestDatabaseManagementServiceBuilder(storeDir).setFileSystem(snapshot).impermanent().build();
    managementService.shutdown();
}
Also used : Path(java.nio.file.Path) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) EphemeralFileSystemAbstraction(org.neo4j.io.fs.EphemeralFileSystemAbstraction) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) Test(org.junit.jupiter.api.Test)

Example 79 with TestDatabaseManagementServiceBuilder

use of org.neo4j.test.TestDatabaseManagementServiceBuilder in project neo4j by neo4j.

the class DatabaseFileListingTest method verifyLogFilesWithCustomPathListing.

private void verifyLogFilesWithCustomPathListing(Path path) throws IOException {
    DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(testDirectory.homePath("customDb")).setConfig(GraphDatabaseSettings.transaction_logs_root_path, path).build();
    GraphDatabaseAPI graphDatabase = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
    Database database = graphDatabase.getDependencyResolver().resolveDependency(Database.class);
    LogFiles logFiles = graphDatabase.getDependencyResolver().resolveDependency(LogFiles.class);
    assertTrue(database.listStoreFiles(true).stream().anyMatch(metadata -> metadata.isLogFile() && logFiles.isLogFile(metadata.path())));
    assertEquals(path.getFileName().toString(), logFiles.logFilesDirectory().getParent().getFileName().toString());
    managementService.shutdown();
}
Also used : IndexingService(org.neo4j.kernel.impl.api.index.IndexingService) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BeforeEach(org.junit.jupiter.api.BeforeEach) LogFiles(org.neo4j.kernel.impl.transaction.log.files.LogFiles) ResourceIterator(org.neo4j.graphdb.ResourceIterator) StoreFileMetadata(org.neo4j.storageengine.api.StoreFileMetadata) IdGeneratorFactory(org.neo4j.internal.id.IdGeneratorFactory) GraphDatabaseSettings(org.neo4j.configuration.GraphDatabaseSettings) Resource(org.neo4j.graphdb.Resource) Mockito.spy(org.mockito.Mockito.spy) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) ArrayList(java.util.ArrayList) DEFAULT_DATABASE_NAME(org.neo4j.configuration.GraphDatabaseSettings.DEFAULT_DATABASE_NAME) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) Inject(org.neo4j.test.extension.Inject) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Path(java.nio.file.Path) DEFAULT_FILENAME_FILTER(org.neo4j.kernel.impl.transaction.log.files.TransactionLogFiles.DEFAULT_FILENAME_FILTER) Files(java.nio.file.Files) Iterators(org.neo4j.internal.helpers.collection.Iterators) StorageEngine(org.neo4j.storageengine.api.StorageEngine) Collection(java.util.Collection) Set(java.util.Set) TestDirectory(org.neo4j.test.rule.TestDirectory) IOException(java.io.IOException) DbmsExtension(org.neo4j.test.extension.DbmsExtension) Mockito.when(org.mockito.Mockito.when) Collectors(java.util.stream.Collectors) File(java.io.File) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) Mockito.verify(org.mockito.Mockito.verify) Test(org.junit.jupiter.api.Test) UncheckedIOException(java.io.UncheckedIOException) List(java.util.List) Database(org.neo4j.kernel.database.Database) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) Mockito.mock(org.mockito.Mockito.mock) Iterators.asResourceIterator(org.neo4j.internal.helpers.collection.Iterators.asResourceIterator) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) Database(org.neo4j.kernel.database.Database) LogFiles(org.neo4j.kernel.impl.transaction.log.files.LogFiles) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService)

Example 80 with TestDatabaseManagementServiceBuilder

use of org.neo4j.test.TestDatabaseManagementServiceBuilder in project neo4j by neo4j.

the class LockerLifecycleAdapterTest method shouldNotAllowDatabasesToUseFilesetsConcurrently.

private void shouldNotAllowDatabasesToUseFilesetsConcurrently(Map<Setting<?>, Object> config) {
    DatabaseManagementService managementService = newDb();
    DatabaseManagementService embeddedService = null;
    try {
        embeddedService = new TestDatabaseManagementServiceBuilder(directory.homePath()).setConfig(config).build();
        fail();
    } catch (RuntimeException e) {
        assertThat(e.getCause().getCause()).isInstanceOf(FileLockException.class);
    } finally {
        if (embeddedService != null) {
            embeddedService.shutdown();
        }
        if (managementService != null) {
            managementService.shutdown();
        }
    }
}
Also used : TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) FileLockException(org.neo4j.kernel.internal.locker.FileLockException) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService)

Aggregations

TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)135 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)74 Test (org.junit.jupiter.api.Test)48 Transaction (org.neo4j.graphdb.Transaction)42 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)38 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)30 Path (java.nio.file.Path)23 BeforeEach (org.junit.jupiter.api.BeforeEach)18 Node (org.neo4j.graphdb.Node)18 EphemeralFileSystemAbstraction (org.neo4j.io.fs.EphemeralFileSystemAbstraction)13 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)11 PageCache (org.neo4j.io.pagecache.PageCache)10 UncloseableDelegatingFileSystemAbstraction (org.neo4j.io.fs.UncloseableDelegatingFileSystemAbstraction)9 DatabaseLayout (org.neo4j.io.layout.DatabaseLayout)8 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)7 TokenIndexProviderFactory (org.neo4j.kernel.impl.index.schema.TokenIndexProviderFactory)7 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 Dependencies (org.neo4j.collection.Dependencies)6 Config (org.neo4j.configuration.Config)6 DatabaseManagementServiceBuilder (org.neo4j.dbms.api.DatabaseManagementServiceBuilder)6