Search in sources :

Example 96 with TestDatabaseManagementServiceBuilder

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

the class RecoveryIT method createBuilder.

private void createBuilder(long logThreshold) {
    if (builder == null) {
        builder = new TestDatabaseManagementServiceBuilder(neo4jLayout).setConfig(preallocate_logical_logs, false).setConfig(logical_log_rotation_threshold, logThreshold);
        builder = additionalConfiguration(builder);
    }
}
Also used : TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder)

Example 97 with TestDatabaseManagementServiceBuilder

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

the class TestRecoveryRelationshipTypes method main.

public static void main(String[] args) throws IOException {
    if (args.length != 1) {
        exit(1);
    }
    Path storeDir = Path.of(args[0]).toAbsolutePath();
    DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(storeDir).build();
    GraphDatabaseService db = managementService.database(DEFAULT_DATABASE_NAME);
    try (Transaction tx = db.beginTx()) {
        tx.createNode().createRelationshipTo(tx.createNode(), MyRelTypes.TEST);
        tx.commit();
    }
    CheckPointer checkPointer = ((GraphDatabaseAPI) db).getDependencyResolver().resolveDependency(CheckPointer.class);
    checkPointer.forceCheckPoint(new SimpleTriggerInfo("test"));
    exit(0);
}
Also used : Path(java.nio.file.Path) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) SimpleTriggerInfo(org.neo4j.kernel.impl.transaction.log.checkpoint.SimpleTriggerInfo) Transaction(org.neo4j.graphdb.Transaction) CheckPointer(org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointer) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService)

Example 98 with TestDatabaseManagementServiceBuilder

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

the class FileWatchIT method notifyWhenFileWatchingFailToStart.

@Test
void notifyWhenFileWatchingFailToStart() {
    AssertableLogProvider logProvider = new AssertableLogProvider(true);
    DatabaseManagementService service = null;
    try {
        service = new TestDatabaseManagementServiceBuilder(testDirectory.homePath("failed-start-db")).setInternalLogProvider(logProvider).setFileSystem(new NonWatchableFileSystemAbstraction()).build();
        assertNotNull(managementService.database(DEFAULT_DATABASE_NAME));
        assertThat(logProvider).containsMessages("Can not create file watcher for current file system. " + "File monitoring capabilities for store files will be disabled.");
    } finally {
        shutdownDatabaseSilently(service);
    }
}
Also used : TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.jupiter.api.Test)

Example 99 with TestDatabaseManagementServiceBuilder

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

the class FileWatchIT method shouldLogWhenDisabled.

@Test
void shouldLogWhenDisabled() {
    AssertableLogProvider logProvider = new AssertableLogProvider(true);
    DatabaseManagementService service = null;
    try {
        service = new TestDatabaseManagementServiceBuilder(testDirectory.homePath("failed-start-db")).setInternalLogProvider(logProvider).setFileSystem(new NonWatchableFileSystemAbstraction()).setConfig(GraphDatabaseSettings.filewatcher_enabled, false).build();
        assertNotNull(managementService.database(DEFAULT_DATABASE_NAME));
        assertThat(logProvider).containsMessages("File watcher disabled by configuration.");
    } finally {
        shutdownDatabaseSilently(service);
    }
}
Also used : TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.jupiter.api.Test)

Example 100 with TestDatabaseManagementServiceBuilder

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

the class RecoveryRequiredCheckerTest method createSomeDataAndCrash.

private static EphemeralFileSystemAbstraction createSomeDataAndCrash(Path store, Config config) throws IOException {
    try (EphemeralFileSystemAbstraction ephemeralFs = new EphemeralFileSystemAbstraction()) {
        DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(store).setFileSystem(ephemeralFs).setConfig(config).build();
        final GraphDatabaseService db = managementService.database(DEFAULT_DATABASE_NAME);
        try (Transaction tx = db.beginTx()) {
            tx.createNode();
            tx.commit();
        }
        EphemeralFileSystemAbstraction snapshot = ephemeralFs.snapshot();
        managementService.shutdown();
        return snapshot;
    }
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) Transaction(org.neo4j.graphdb.Transaction) EphemeralFileSystemAbstraction(org.neo4j.io.fs.EphemeralFileSystemAbstraction) 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