Search in sources :

Example 46 with ConsistencySummaryStatistics

use of org.neo4j.consistency.report.ConsistencySummaryStatistics in project neo4j by neo4j.

the class FullCheckIntegrationTest method shouldReportMissingMandatoryRelationshipProperty.

@Test
public void shouldReportMissingMandatoryRelationshipProperty() throws Exception {
    // given
    fixture.apply(new GraphStoreFixture.Transaction() {

        @Override
        protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
            long nodeId1 = next.node();
            long nodeId2 = next.node();
            long relId = next.relationship();
            long propId = next.property();
            NodeRecord node1 = new NodeRecord(nodeId1, true, false, relId, NO_NEXT_PROPERTY.intValue(), NO_LABELS_FIELD.intValue());
            NodeRecord node2 = new NodeRecord(nodeId2, true, false, relId, NO_NEXT_PROPERTY.intValue(), NO_LABELS_FIELD.intValue());
            // structurally correct, but does not have the 'mandatory' property with the 'M' rel type
            RelationshipRecord relationship = new RelationshipRecord(relId, true, nodeId1, nodeId2, M, NO_PREV_RELATIONSHIP.intValue(), NO_NEXT_RELATIONSHIP.intValue(), NO_PREV_RELATIONSHIP.intValue(), NO_NEXT_RELATIONSHIP.intValue(), true, true);
            relationship.setNextProp(propId);
            PropertyRecord property = new PropertyRecord(propId, relationship);
            property.setInUse(true);
            PropertyBlock block = new PropertyBlock();
            block.setSingleBlock(key | (((long) PropertyType.INT.intValue()) << 24) | (1337L << 28));
            property.addPropertyBlock(block);
            tx.create(node1);
            tx.create(node2);
            tx.create(relationship);
            tx.create(property);
            tx.incrementRelationshipCount(ANY_LABEL, ANY_RELATIONSHIP_TYPE, ANY_LABEL, 1);
            tx.incrementRelationshipCount(ANY_LABEL, M, ANY_LABEL, 1);
        }
    });
    createRelationshipPropertyExistenceConstraint(M, mandatory);
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    on(stats).verify(RecordType.RELATIONSHIP, 1).andThatsAllFolks();
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) TransactionDataBuilder(org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder) IdGenerator(org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) GraphStoreFixture(org.neo4j.consistency.checking.GraphStoreFixture) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) Test(org.junit.Test)

Example 47 with ConsistencySummaryStatistics

use of org.neo4j.consistency.report.ConsistencySummaryStatistics in project neo4j by neo4j.

the class FullCheckIntegrationTest method shouldNotReportAnythingForNodeWithConsistentChainOfDynamicRecordsWithLabels.

@Test
public void shouldNotReportAnythingForNodeWithConsistentChainOfDynamicRecordsWithLabels() throws Exception {
    // given
    assertEquals(3, chainOfDynamicRecordsWithLabelsForANode(130).first().size());
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    assertTrue("should be consistent", stats.isConsistent());
}
Also used : ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) Test(org.junit.Test)

Example 48 with ConsistencySummaryStatistics

use of org.neo4j.consistency.report.ConsistencySummaryStatistics in project neo4j by neo4j.

the class FullCheckIntegrationTest method shouldReportRelationshipGroupRelationshipNotInUseInconsistencies.

@Test
public void shouldReportRelationshipGroupRelationshipNotInUseInconsistencies() throws Exception {
    // given
    fixture.apply(new GraphStoreFixture.Transaction() {

        @Override
        protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
            long node = next.node();
            long groupId = next.relationshipGroup();
            long rel = next.relationship();
            tx.create(inUse(new NodeRecord(node, true, groupId, NO_NEXT_PROPERTY.intValue())));
            tx.create(withOwner(withRelationships(inUse(new RelationshipGroupRecord(groupId, C)), rel, rel, rel), node));
        }
    });
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    on(stats).verify(RecordType.RELATIONSHIP_GROUP, 3).andThatsAllFolks();
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) TransactionDataBuilder(org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder) IdGenerator(org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator) GraphStoreFixture(org.neo4j.consistency.checking.GraphStoreFixture) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) Test(org.junit.Test)

Example 49 with ConsistencySummaryStatistics

use of org.neo4j.consistency.report.ConsistencySummaryStatistics in project neo4j by neo4j.

the class FullCheckIntegrationTest method shouldReportInvalidRelTypeIdInRelationshipPropertyExistenceConstraintRule.

@Test
public void shouldReportInvalidRelTypeIdInRelationshipPropertyExistenceConstraintRule() throws Exception {
    // Given
    int relTypeId = fixture.idGenerator().relationshipType();
    int propertyKeyId = createPropertyKey();
    createRelationshipPropertyExistenceConstraint(relTypeId, propertyKeyId);
    // When
    ConsistencySummaryStatistics stats = check();
    // Then
    on(stats).verify(RecordType.SCHEMA, 1).andThatsAllFolks();
}
Also used : ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) Test(org.junit.Test)

Example 50 with ConsistencySummaryStatistics

use of org.neo4j.consistency.report.ConsistencySummaryStatistics in project neo4j by neo4j.

the class FullCheckIntegrationTest method shouldReportNothingForUniquenessAndPropertyExistenceConstraintOnSameLabelAndProperty.

@Test
public void shouldReportNothingForUniquenessAndPropertyExistenceConstraintOnSameLabelAndProperty() throws Exception {
    // Given
    int labelId = createLabel();
    int propertyKeyId = createPropertyKey();
    createUniquenessConstraintRule(labelId, propertyKeyId);
    createNodePropertyExistenceConstraint(labelId, propertyKeyId);
    // When
    ConsistencySummaryStatistics stats = check();
    // Then
    assertTrue(stats.isConsistent());
}
Also used : ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) Test(org.junit.Test)

Aggregations

ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)62 Test (org.junit.Test)60 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)38 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)38 TransactionDataBuilder (org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder)37 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)23 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)14 RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)11 DirectStoreAccess (org.neo4j.kernel.api.direct.DirectStoreAccess)8 StoreAccess (org.neo4j.kernel.impl.store.StoreAccess)8 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)7 SchemaRuleUtil.constraintIndexRule (org.neo4j.consistency.checking.SchemaRuleUtil.constraintIndexRule)6 IndexRule (org.neo4j.kernel.impl.store.record.IndexRule)6 Collection (java.util.Collection)5 PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)4 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)4 AtomicLong (java.util.concurrent.atomic.AtomicLong)3 LabelScanStore (org.neo4j.kernel.api.labelscan.LabelScanStore)3 CacheAccess (org.neo4j.consistency.checking.cache.CacheAccess)2 DefaultCacheAccess (org.neo4j.consistency.checking.cache.DefaultCacheAccess)2