use of org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder in project neo4j by neo4j.
the class FullCheckIntegrationTest method shouldReportCircularPropertyRecordChain.
private void shouldReportCircularPropertyRecordChain(RecordType expectedInconsistentRecordType, EntityCreator entityCreator) throws Exception {
// Given
fixture.apply(new GraphStoreFixture.Transaction() {
@Override
protected void transactionData(TransactionDataBuilder tx, IdGenerator next) {
// Create property chain A --> B --> C --> D
// ↑ │
// └───────────┘
long a = next.property();
long b = next.property();
long c = next.property();
long d = next.property();
tx.create(propertyRecordWithSingleIntProperty(a, next.propertyKey(), -1, b));
tx.create(propertyRecordWithSingleIntProperty(b, next.propertyKey(), a, c));
tx.create(propertyRecordWithSingleIntProperty(c, next.propertyKey(), b, d));
tx.create(propertyRecordWithSingleIntProperty(d, next.propertyKey(), c, b));
entityCreator.create(tx, next, a);
}
private PropertyRecord propertyRecordWithSingleIntProperty(long id, int propertyKeyId, long prev, long next) {
PropertyRecord record = new PropertyRecord(id).initialize(true, prev, next);
PropertyBlock block = new PropertyBlock();
PropertyStore.encodeValue(block, propertyKeyId, Values.intValue(10), null, null, false, NULL, INSTANCE);
record.addPropertyBlock(block);
return record;
}
});
// When
ConsistencySummaryStatistics stats = check();
// Then report will be filed on Node inconsistent with the Property completing the circle
on(stats).verify(expectedInconsistentRecordType, 1);
}
use of org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder in project neo4j by neo4j.
the class FullCheckIntegrationTest method shouldManageUnusedRecordsWithWeirdDataIn.
@Test
void shouldManageUnusedRecordsWithWeirdDataIn() throws Exception {
// Given
final AtomicLong id = new AtomicLong();
fixture.apply(new GraphStoreFixture.Transaction() {
@Override
protected void transactionData(TransactionDataBuilder tx, IdGenerator next) {
id.set(next.relationship());
RelationshipRecord relationship = new RelationshipRecord(id.get());
relationship.setFirstNode(-1);
relationship.setSecondNode(-1);
relationship.setInUse(true);
tx.create(relationship);
}
});
fixture.apply(new GraphStoreFixture.Transaction() {
@Override
protected void transactionData(TransactionDataBuilder tx, IdGenerator next) {
RelationshipRecord relationship = new RelationshipRecord(id.get());
tx.delete(relationship);
}
});
// When
ConsistencySummaryStatistics stats = check();
// Then
assertTrue(stats.isConsistent());
}
use of org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder in project neo4j by neo4j.
the class FullCheckIntegrationTest method shouldDetectCutOffRelationshipGroupChains.
@Test
void shouldDetectCutOffRelationshipGroupChains() throws Exception {
fixture.apply(new GraphStoreFixture.Transaction() {
@Override
protected void transactionData(TransactionDataBuilder tx, IdGenerator next) {
// node -> group1 -> group2 -X-> group3 -> group4
// ^
// | chain cut off
long nodeId = next.node();
long group1Id = next.relationshipGroup();
long group2Id = next.relationshipGroup();
long group3Id = next.relationshipGroup();
long group4Id = next.relationshipGroup();
int type1 = next.relationshipType();
int type2 = next.relationshipType();
int type3 = next.relationshipType();
int type4 = next.relationshipType();
NodeRecord node = new NodeRecord(nodeId).initialize(true, NULL_REFERENCE.longValue(), true, group1Id, NO_LABELS_FIELD.longValue());
RelationshipGroupRecord group1 = new RelationshipGroupRecord(group1Id).initialize(true, type1, NULL_REFERENCE.longValue(), NULL_REFERENCE.longValue(), NULL_REFERENCE.longValue(), nodeId, group2Id);
RelationshipGroupRecord group2 = new RelationshipGroupRecord(group2Id).initialize(true, type2, NULL_REFERENCE.longValue(), NULL_REFERENCE.longValue(), NULL_REFERENCE.longValue(), nodeId, // cut-off point
NULL_REFERENCE.longValue());
RelationshipGroupRecord group3 = new RelationshipGroupRecord(group3Id).initialize(true, type3, NULL_REFERENCE.longValue(), NULL_REFERENCE.longValue(), NULL_REFERENCE.longValue(), nodeId, group4Id);
RelationshipGroupRecord group4 = new RelationshipGroupRecord(group3Id).initialize(true, type4, NULL_REFERENCE.longValue(), NULL_REFERENCE.longValue(), NULL_REFERENCE.longValue(), nodeId, // correct end of chain
NULL_REFERENCE.longValue());
tx.create(node);
tx.relationshipType(type1, "T1", false);
tx.relationshipType(type2, "T2", false);
tx.relationshipType(type3, "T3", false);
tx.relationshipType(type4, "T4", false);
tx.create(group1);
tx.create(group2);
tx.create(group3);
tx.create(group4);
}
});
// when
ConsistencySummaryStatistics stats = check();
// then
assertFalse(stats.isConsistent());
on(stats).verify(RecordType.RELATIONSHIP_GROUP, 1).andThatsAllFolks();
}
Aggregations