use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class RecordFormatMigrationIT method skipMigrationIfFormatSpecifiedInConfig.
@Test
void skipMigrationIfFormatSpecifiedInConfig() {
DatabaseManagementService managementService = startManagementService(StandardV4_0.NAME);
GraphDatabaseAPI database = getDefaultDatabase(managementService);
try (Transaction transaction = database.beginTx()) {
Node node = transaction.createNode();
node.setProperty("a", "b");
transaction.commit();
}
managementService.shutdown();
managementService = startManagementService(StandardV4_0.NAME);
GraphDatabaseAPI nonUpgradedStore = getDefaultDatabase(managementService);
RecordStorageEngine storageEngine = nonUpgradedStore.getDependencyResolver().resolveDependency(RecordStorageEngine.class);
assertEquals(StandardV4_0.NAME, storageEngine.testAccessNeoStores().getRecordFormats().name());
managementService.shutdown();
}
use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class LabelsAcceptanceTest method oversteppingMaxNumberOfLabelsShouldFailGracefully.
@Test
void oversteppingMaxNumberOfLabelsShouldFailGracefully() throws IOException {
JobScheduler scheduler = JobSchedulerFactory.createScheduler();
try (EphemeralFileSystemAbstraction fileSystem = new EphemeralFileSystemAbstraction();
Lifespan lifespan = new Lifespan(scheduler);
PageCache pageCache = new MuninnPageCache(swapper(fileSystem), scheduler, MuninnPageCache.config(1_000))) {
// Given
Dependencies dependencies = new Dependencies();
dependencies.satisfyDependencies(createIdContextFactoryWithMaxedOutLabelTokenIds(fileSystem, scheduler));
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder().setFileSystem(fileSystem).noOpSystemGraphInitializer().setExternalDependencies(dependencies).impermanent().build();
GraphDatabaseService graphDatabase = managementService.database(DEFAULT_DATABASE_NAME);
// When
try (Transaction tx = graphDatabase.beginTx()) {
assertThrows(ConstraintViolationException.class, () -> tx.createNode().addLabel(Labels.MY_LABEL));
}
managementService.shutdown();
}
}
use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class GraphDatabaseInternalLogIT method shouldWriteToInternalDiagnosticsLog.
@Test
void shouldWriteToInternalDiagnosticsLog() throws Exception {
// Given
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(testDir.homePath()).setConfig(GraphDatabaseSettings.logs_directory, testDir.directory("logs").toAbsolutePath()).build();
var databaseId = ((GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME)).databaseId();
managementService.shutdown();
Path internalLog = testDir.directory("logs").resolve(INTERNAL_LOG_FILE);
// Then
assertThat(Files.isRegularFile(internalLog)).isEqualTo(true);
assertThat(Files.size(internalLog)).isGreaterThan(0L);
assertEquals(1, countOccurrences(internalLog, databaseId + " is ready."));
assertEquals(2, countOccurrences(internalLog, databaseId + " is unavailable."));
}
use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class GraphDatabaseInternalLogIT method shouldNotWriteDebugToInternalDiagnosticsLogByDefault.
@Test
void shouldNotWriteDebugToInternalDiagnosticsLogByDefault() throws Exception {
// Given
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(testDir.homePath()).setConfig(GraphDatabaseSettings.logs_directory, testDir.directory("logs").toAbsolutePath()).build();
GraphDatabaseService db = managementService.database(DEFAULT_DATABASE_NAME);
// When
LogService logService = ((GraphDatabaseAPI) db).getDependencyResolver().resolveDependency(LogService.class);
logService.getInternalLog(getClass()).debug("A debug entry");
managementService.shutdown();
Path internalLog = testDir.directory("logs").resolve(INTERNAL_LOG_FILE);
// Then
assertThat(Files.isRegularFile(internalLog)).isEqualTo(true);
assertThat(Files.size(internalLog)).isGreaterThan(0L);
assertEquals(0, countOccurrences(internalLog, "A debug entry"));
}
use of org.neo4j.dbms.api.DatabaseManagementService in project neo4j by neo4j.
the class CancelIndexPopulationIT method shouldKeepIndexInPopulatingStateBetweenRestarts.
@Test
void shouldKeepIndexInPopulatingStateBetweenRestarts() throws InterruptedException {
DatabaseManagementService dbms = new TestDatabaseManagementServiceBuilder(directory.homePath()).build();
try {
GraphDatabaseAPI db = (GraphDatabaseAPI) dbms.database(DEFAULT_DATABASE_NAME);
// given
Monitors monitors = db.getDependencyResolver().resolveDependency(Monitors.class);
Barrier.Control barrier = new Barrier.Control();
monitors.addMonitorListener(populationCompletionBlocker(barrier));
// when
createRelevantNode(db);
createIndex(db);
barrier.await();
} finally {
// This call to shutdown will eventually make a call to populationCancelled on the monitor below
dbms.shutdown();
}
dbms = new TestDatabaseManagementServiceBuilder(directory.homePath()).build();
try {
GraphDatabaseAPI db = (GraphDatabaseAPI) dbms.database(DEFAULT_DATABASE_NAME);
// then
assertEquals(Schema.IndexState.ONLINE, awaitAndGetIndexState(db));
} finally {
dbms.shutdown();
}
}
Aggregations