use of org.neo4j.test.TestDatabaseManagementServiceBuilder in project neo4j by neo4j.
the class SchemaConstraintProviderApprovalTest method init.
@BeforeAll
public static void init() {
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder().impermanent().build();
GraphDatabaseService db = managementService.database(DEFAULT_DATABASE_NAME);
for (TestValue value : TestValue.values()) {
createNode(db, PROPERTY_KEY, value.value);
}
noIndexRun = runFindByLabelAndProperty(db);
createConstraint(db, label(LABEL), PROPERTY_KEY);
constraintRun = runFindByLabelAndProperty(db);
managementService.shutdown();
}
use of org.neo4j.test.TestDatabaseManagementServiceBuilder in project neo4j by neo4j.
the class BTreeIndexKeySizeValidationIT method startDb.
private void startDb(int pageSize) {
TestDatabaseManagementServiceBuilder builder = new TestDatabaseManagementServiceBuilder(neo4jLayout);
builder.setConfig(default_schema_provider, NATIVE_BTREE10.providerName());
scheduler = JobSchedulerFactory.createInitialisedScheduler();
PageCache pageCache = StandalonePageCacheFactory.createPageCache(fs, scheduler, pageSize);
Dependencies dependencies = new Dependencies();
dependencies.satisfyDependency(pageCache);
builder.setExternalDependencies(dependencies);
dbms = builder.build();
db = (GraphDatabaseAPI) dbms.database(DEFAULT_DATABASE_NAME);
}
use of org.neo4j.test.TestDatabaseManagementServiceBuilder in project neo4j by neo4j.
the class LuceneIndexRecoveryIT method startDb.
private void startDb(ExtensionFactory<?> indexProviderFactory) {
if (db != null) {
managementService.shutdown();
}
TestDatabaseManagementServiceBuilder factory = new TestDatabaseManagementServiceBuilder();
factory.setFileSystem(fs);
factory.setExtensions(asList(indexProviderFactory, new TokenIndexProviderFactory()));
managementService = factory.impermanent().setConfig(default_schema_provider, DESCRIPTOR.name()).build();
db = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
}
use of org.neo4j.test.TestDatabaseManagementServiceBuilder in project neo4j by neo4j.
the class StoreMigratorTest method extractTransactionalInformationFromLogs.
private void extractTransactionalInformationFromLogs(Path customLogsLocation) throws IOException {
Config config = Config.defaults(transaction_logs_root_path, customLogsLocation);
LogService logService = new SimpleLogService(NullLogProvider.getInstance(), NullLogProvider.getInstance());
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(databaseLayout).setConfig(transaction_logs_root_path, customLogsLocation).build();
GraphDatabaseAPI database = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
StorageEngineFactory storageEngineFactory = database.getDependencyResolver().resolveDependency(StorageEngineFactory.class);
for (int i = 0; i < 10; i++) {
try (Transaction transaction = database.beginTx()) {
transaction.createNode();
transaction.commit();
}
}
DatabaseLayout databaseLayout = database.databaseLayout();
Path neoStore = databaseLayout.metadataStore();
managementService.shutdown();
MetaDataStore.setRecord(pageCache, neoStore, MetaDataStore.Position.LAST_CLOSED_TRANSACTION_LOG_VERSION, MetaDataRecordFormat.FIELD_NOT_PRESENT, databaseLayout.getDatabaseName(), NULL);
RecordStorageMigrator migrator = new RecordStorageMigrator(fileSystem, pageCache, config, logService, jobScheduler, PageCacheTracer.NULL, batchImporterFactory, INSTANCE);
LogPosition logPosition = migrator.extractTransactionLogPosition(neoStore, databaseLayout, 100, NULL);
LogFiles logFiles = LogFilesBuilder.activeFilesBuilder(databaseLayout, fileSystem, pageCache).withConfig(config).withCommandReaderFactory(storageEngineFactory.commandReaderFactory()).build();
assertEquals(0, logPosition.getLogVersion());
assertEquals(Files.size(logFiles.getLogFile().getHighestLogFile()), logPosition.getByteOffset());
}
use of org.neo4j.test.TestDatabaseManagementServiceBuilder in project neo4j by neo4j.
the class WriteTestSupport method setup.
@Override
public void setup(Path storeDir, Consumer<GraphDatabaseService> sysCreate) {
TestDatabaseManagementServiceBuilder databaseManagementServiceBuilder = newManagementServiceBuilder(storeDir);
managementService = configure(databaseManagementServiceBuilder).build();
db = managementService.database(DEFAULT_DATABASE_NAME);
try (KernelTransaction tx = beginTransaction()) {
// We are creating these dummy tokens so that that the ones that we actually use don't get
// the value 0. Using 0 may hide bugs that are caused by default the initialization of ints
TokenWrite tokenWrite = tx.tokenWrite();
tokenWrite.propertyKeyCreateForName("DO_NOT_USE", false);
tokenWrite.labelCreateForName("DO_NOT_USE", false);
tokenWrite.relationshipTypeCreateForName("DO_NOT_USE", false);
} catch (KernelException e) {
throw new AssertionError("Failed to setup database", e);
}
GraphDatabaseService sysDb = managementService.database(SYSTEM_DATABASE_NAME);
sysCreate.accept(sysDb);
}
Aggregations