use of org.neo4j.test.TestDatabaseManagementServiceBuilder in project neo4j by neo4j.
the class TestLogPruning method newDb.
private GraphDatabaseAPI newDb(String logPruning, int rotateEveryNTransactions) {
this.rotateEveryNTransactions = rotateEveryNTransactions;
fs = new EphemeralFileSystemAbstraction();
TestDatabaseManagementServiceBuilder gdf = new TestDatabaseManagementServiceBuilder();
gdf.setFileSystem(new UncloseableDelegatingFileSystemAbstraction(fs));
DatabaseManagementServiceBuilder builder = gdf.impermanent();
builder.setConfig(keep_logical_logs, logPruning);
managementService = builder.build();
this.db = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
files = db.getDependencyResolver().resolveDependency(LogFiles.class);
return db;
}
use of org.neo4j.test.TestDatabaseManagementServiceBuilder in project neo4j by neo4j.
the class KernelDiagnosticsIT method createIndexInIsolatedDbInstance.
private static void createIndexInIsolatedDbInstance(Path homeDir, GraphDatabaseSettings.SchemaIndex index) {
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(homeDir).setConfig(GraphDatabaseSettings.default_schema_provider, index.providerName()).build();
GraphDatabaseService db = managementService.database(DEFAULT_DATABASE_NAME);
try {
Label label = Label.label("Label-" + index.providerName());
String key = "key";
try (Transaction tx = db.beginTx()) {
for (int i = 0; i < 100; i++) {
tx.createNode(label).setProperty(key, i);
}
tx.commit();
}
try (Transaction tx = db.beginTx()) {
tx.schema().indexFor(label).on(key).create();
tx.commit();
}
try (Transaction tx = db.beginTx()) {
tx.schema().awaitIndexesOnline(2, MINUTES);
tx.commit();
}
} finally {
managementService.shutdown();
}
}
use of org.neo4j.test.TestDatabaseManagementServiceBuilder in project neo4j by neo4j.
the class TestRecoveryRelationshipTypes method recoverNeoAndHavingAllRelationshipTypesAfterRecovery.
@Test
void recoverNeoAndHavingAllRelationshipTypesAfterRecovery() throws Exception {
// Given (create transactions and kill process, leaving it needing for recovery)
Path storeDir = testDirectory.homePath();
Process process = start(getClass().getName(), storeDir.toAbsolutePath().toString());
assertEquals(0, process.waitFor());
// When
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(storeDir).build();
GraphDatabaseService db = managementService.database(DEFAULT_DATABASE_NAME);
// Then
try (Transaction transaction = db.beginTx()) {
Iterator<RelationshipType> typeResourceIterator = transaction.getAllRelationshipTypes().iterator();
assertEquals(MyRelTypes.TEST.name(), typeResourceIterator.next().name());
} finally {
managementService.shutdown();
}
}
use of org.neo4j.test.TestDatabaseManagementServiceBuilder in project neo4j by neo4j.
the class FileWatchIT method setUp.
@BeforeEach
void setUp() {
logProvider = new AssertableLogProvider();
managementService = new TestDatabaseManagementServiceBuilder(databaseLayout).setInternalLogProvider(logProvider).build();
database = managementService.database(DEFAULT_DATABASE_NAME);
}
use of org.neo4j.test.TestDatabaseManagementServiceBuilder in project neo4j by neo4j.
the class FileLockerTest method mustPreventMultipleInstancesFromStartingOnSameStore.
@Test
void mustPreventMultipleInstancesFromStartingOnSameStore() {
Path storeDir = testDirectory.homePath();
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(storeDir).build();
try {
GraphDatabaseService db = managementService.database(DEFAULT_DATABASE_NAME);
try (Transaction tx = db.beginTx()) {
tx.createNode();
tx.commit();
}
assertThrows(Exception.class, () -> {
new TestDatabaseManagementServiceBuilder(storeDir).build();
});
} finally {
managementService.shutdown();
}
}
Aggregations