use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.
the class ConsistencyCheckServiceIntegrationTest method shouldNotReportDuplicateForHugeLongValues.
@Test
public void shouldNotReportDuplicateForHugeLongValues() throws Exception {
// given
ConsistencyCheckService service = new ConsistencyCheckService();
Config configuration = Config.embeddedDefaults(settings());
GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder(testDirectory.graphDbDir()).setConfig(GraphDatabaseSettings.record_format, getRecordFormatName()).newGraphDatabase();
String propertyKey = "itemId";
Label label = Label.label("Item");
try (Transaction tx = db.beginTx()) {
db.schema().constraintFor(label).assertPropertyIsUnique(propertyKey).create();
tx.success();
}
try (Transaction tx = db.beginTx()) {
set(db.createNode(label), property(propertyKey, 973305894188596880L));
set(db.createNode(label), property(propertyKey, 973305894188596864L));
tx.success();
}
db.shutdown();
// when
Result result = runFullConsistencyCheck(service, configuration);
// then
assertTrue(result.isSuccessful());
}
use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.
the class ConsistencyCheckServiceIntegrationTest method getGraphDatabaseService.
private GraphDatabaseService getGraphDatabaseService() {
GraphDatabaseBuilder builder = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder(testDirectory.absolutePath());
builder.setConfig(settings());
return builder.newGraphDatabase();
}
use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.
the class ConsistencyCheckToolTest method createGraphDbAndKillIt.
private void createGraphDbAndKillIt() throws Exception {
final GraphDatabaseService db = new TestGraphDatabaseFactory().setFileSystem(fs.get()).newImpermanentDatabaseBuilder(storeDirectory.graphDbDir()).newGraphDatabase();
try (Transaction tx = db.beginTx()) {
db.createNode(label("FOO"));
db.createNode(label("BAR"));
tx.success();
}
fs.snapshot(() -> db.shutdown());
}
use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.
the class GraphStoreFixture method generateInitialData.
private void generateInitialData() {
GraphDatabaseBuilder builder = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder(directory);
GraphDatabaseAPI graphDb = (GraphDatabaseAPI) builder.setConfig(GraphDatabaseSettings.record_format, formatName).setConfig(GraphDatabaseSettings.label_block_size, "60").newGraphDatabase();
try {
generateInitialData(graphDb);
StoreAccess stores = new StoreAccess(graphDb.getDependencyResolver().resolveDependency(RecordStorageEngine.class).testAccessNeoStores()).initialize();
schemaId = stores.getSchemaStore().getHighId();
nodeId = stores.getNodeStore().getHighId();
labelId = (int) stores.getLabelTokenStore().getHighId();
nodeLabelsId = stores.getNodeDynamicLabelStore().getHighId();
relId = stores.getRelationshipStore().getHighId();
relGroupId = stores.getRelationshipGroupStore().getHighId();
propId = (int) stores.getPropertyStore().getHighId();
stringPropId = stores.getStringStore().getHighId();
arrayPropId = stores.getArrayStore().getHighId();
relTypeId = (int) stores.getRelationshipTypeTokenStore().getHighId();
propKeyId = (int) stores.getPropertyKeyNameStore().getHighId();
} finally {
graphDb.shutdown();
}
}
use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.
the class ParallelBatchImporterTest method shouldImportCsvData.
@Test
public void shouldImportCsvData() throws Exception {
// GIVEN
ExecutionMonitor processorAssigner = eagerRandomSaturation(config.maxNumberOfProcessors());
final BatchImporter inserter = new ParallelBatchImporter(directory.graphDbDir(), fileSystemRule.get(), config, NullLogService.getInstance(), processorAssigner, EMPTY, Config.empty(), getFormat());
boolean successful = false;
IdGroupDistribution groups = new IdGroupDistribution(NODE_COUNT, 5, random.random());
long nodeRandomSeed = random.nextLong(), relationshipRandomSeed = random.nextLong();
try {
// WHEN
inserter.doImport(Inputs.input(nodes(nodeRandomSeed, NODE_COUNT, inputIdGenerator, groups), relationships(relationshipRandomSeed, RELATIONSHIP_COUNT, inputIdGenerator, groups), idMapper, idGenerator, /*insanely high bad tolerance, but it will actually never be that many*/
silentBadCollector(RELATIONSHIP_COUNT)));
// THEN
GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder(directory.graphDbDir()).newGraphDatabase();
try (Transaction tx = db.beginTx()) {
inputIdGenerator.reset();
verifyData(NODE_COUNT, RELATIONSHIP_COUNT, db, groups, nodeRandomSeed, relationshipRandomSeed);
tx.success();
} finally {
db.shutdown();
}
assertConsistent(directory.graphDbDir());
successful = true;
} finally {
if (!successful) {
File failureFile = directory.file("input");
try (PrintStream out = new PrintStream(failureFile)) {
out.println("Seed used in this failing run: " + random.seed());
out.println(inputIdGenerator);
inputIdGenerator.reset();
for (InputNode node : nodes(nodeRandomSeed, NODE_COUNT, inputIdGenerator, groups)) {
out.println(node);
}
for (InputRelationship relationship : relationships(relationshipRandomSeed, RELATIONSHIP_COUNT, inputIdGenerator, groups)) {
out.println(relationship);
}
out.println();
out.println("Processor assignments");
out.println(processorAssigner.toString());
}
System.err.println("Additional debug information stored in " + failureFile);
}
}
}
Aggregations