Search in sources :

Example 16 with TestDatabaseManagementServiceBuilder

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

the class DatabaseShutdownTest method invokeDatabaseShutdownListenersOnShutdown.

@Test
void invokeDatabaseShutdownListenersOnShutdown() {
    DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(databaseLayout).setFileSystem(fs).build();
    ShutdownListenerDatabaseEventListener shutdownHandler = new ShutdownListenerDatabaseEventListener();
    managementService.registerDatabaseEventListener(shutdownHandler);
    managementService.shutdown();
    assertEquals(2, shutdownHandler.shutdownCounter());
}
Also used : TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) Test(org.junit.jupiter.api.Test)

Example 17 with TestDatabaseManagementServiceBuilder

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

the class QueryRestartIT method startSnapshotQueryDb.

private GraphDatabaseService startSnapshotQueryDb() {
    // Inject TransactionVersionContextSupplier
    Dependencies dependencies = new Dependencies();
    dependencies.satisfyDependencies(testContextSupplier);
    managementService = new TestDatabaseManagementServiceBuilder(storeDir).setExternalDependencies(dependencies).setConfig(snapshot_query, true).setConfig(index_background_sampling_enabled, false).build();
    return managementService.database(DEFAULT_DATABASE_NAME);
}
Also used : TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) Dependencies(org.neo4j.collection.Dependencies)

Example 18 with TestDatabaseManagementServiceBuilder

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

the class TestGraphDescription method startDatabase.

@BeforeAll
public static void startDatabase() {
    managementService = new TestDatabaseManagementServiceBuilder().impermanent().build();
    graphdb = managementService.database(DEFAULT_DATABASE_NAME);
}
Also used : TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 19 with TestDatabaseManagementServiceBuilder

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

the class RecoveryLogIT method transactionsRecoveryLogContainsTimeSpent.

@Test
void transactionsRecoveryLogContainsTimeSpent() throws IOException {
    // Create database with forced recovery
    Path tmpLogDir = testDirectory.directory("logs");
    managementService = new TestDatabaseManagementServiceBuilder(testDirectory.homePath()).build();
    GraphDatabaseAPI db = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
    StorageEngineFactory storageEngineFactory = db.getDependencyResolver().resolveDependency(StorageEngineFactory.class);
    try (Transaction tx = db.beginTx()) {
        Node node1 = tx.createNode();
        Node node2 = tx.createNode();
        node1.createRelationshipTo(node2, RelationshipType.withName("likes"));
        tx.commit();
    }
    Path[] txLogs = LogFilesBuilder.logFilesBasedOnlyBuilder(databaseLayout.getTransactionLogsDirectory(), fileSystem).withCommandReaderFactory(storageEngineFactory.commandReaderFactory()).build().logFiles();
    for (Path file : txLogs) {
        fileSystem.copyToDirectory(file, tmpLogDir);
    }
    managementService.shutdown();
    for (Path txLog : fileSystem.listFiles(databaseLayout.getTransactionLogsDirectory())) {
        fileSystem.deleteFile(txLog);
    }
    for (Path file : LogFilesBuilder.logFilesBasedOnlyBuilder(tmpLogDir, fileSystem).withCommandReaderFactory(storageEngineFactory.commandReaderFactory()).build().logFiles()) {
        fileSystem.moveToDirectory(file, databaseLayout.getTransactionLogsDirectory());
    }
    AssertableLogProvider provider = new AssertableLogProvider();
    managementService = new TestDatabaseManagementServiceBuilder(testDirectory.homePath()).setInternalLogProvider(provider).build();
    managementService.database(DEFAULT_DATABASE_NAME);
    assertThat(provider).containsMessages("Recovery completed", "time spent");
}
Also used : Path(java.nio.file.Path) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) Transaction(org.neo4j.graphdb.Transaction) StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) Node(org.neo4j.graphdb.Node) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.jupiter.api.Test)

Example 20 with TestDatabaseManagementServiceBuilder

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

the class UniqueSpatialIndexIT method setupDb.

private void setupDb(GraphDatabaseSettings.SchemaIndex schemaIndex) {
    managementService = new TestDatabaseManagementServiceBuilder(directory.homePath()).setConfig(GraphDatabaseSettings.default_schema_provider, schemaIndex.providerName()).build();
    db = managementService.database(DEFAULT_DATABASE_NAME);
}
Also used : TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder)

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