Search in sources :

Example 6 with ConsistencySummaryStatistics

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

the class FullCheckIntegrationTest method shouldReportPropertyInconsistencies.

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

        @Override
        protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
            NodeRecord node = new NodeRecord(next.node());
            PropertyRecord property = new PropertyRecord(next.property());
            node.setNextProp(property.getId());
            // Mess up the prev/next pointers a bit
            property.setNextProp(1_000);
            PropertyBlock block = new PropertyBlock();
            block.setSingleBlock(next.propertyKey() | (((long) PropertyType.INT.intValue()) << 24) | (666L << 28));
            property.addPropertyBlock(block);
            tx.create(node);
            tx.create(property);
        }
    });
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    on(stats).verify(RecordType.PROPERTY, 2).verify(RecordType.NODE, 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) GraphStoreFixture(org.neo4j.consistency.checking.GraphStoreFixture) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) Test(org.junit.Test)

Example 7 with ConsistencySummaryStatistics

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

the class FullCheckIntegrationTest method shouldReportDuplicatedUniquenessConstraintRules.

@Test
public void shouldReportDuplicatedUniquenessConstraintRules() throws Exception {
    // Given
    int labelId = createLabel();
    int propertyKeyId = createPropertyKey();
    createUniquenessConstraintRule(labelId, propertyKeyId);
    createUniquenessConstraintRule(labelId, propertyKeyId);
    // When
    ConsistencySummaryStatistics stats = check();
    // Then
    // pair of duplicated indexes & pair of duplicated constraints
    on(stats).verify(RecordType.SCHEMA, 2).andThatsAllFolks();
}
Also used : ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) Test(org.junit.Test)

Example 8 with ConsistencySummaryStatistics

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

the class FullCheckIntegrationTest method shouldReportInvalidPropertyKeyIdInNodePropertyExistenceConstraintRule.

@Test
public void shouldReportInvalidPropertyKeyIdInNodePropertyExistenceConstraintRule() throws Exception {
    // Given
    int labelId = createLabel();
    int propertyKeyId = fixture.idGenerator().propertyKey();
    createNodePropertyExistenceConstraint(labelId, 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 9 with ConsistencySummaryStatistics

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

the class FullCheckIntegrationTest method shouldReportRelationshipOtherNodeInconsistencies.

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

        @Override
        protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
            long node1 = next.node();
            long node2 = next.node();
            long rel = next.relationship();
            tx.create(inUse(new RelationshipRecord(rel, node1, node2, 0)));
            tx.create(inUse(new NodeRecord(node1, false, rel + 1, -1)));
            tx.create(inUse(new NodeRecord(node2, false, rel + 2, -1)));
        }
    });
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    on(stats).verify(RecordType.RELATIONSHIP, 2).verify(RecordType.NODE, 2).verify(RecordType.COUNTS, 2).andThatsAllFolks();
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) TransactionDataBuilder(org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder) IdGenerator(org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator) 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 10 with ConsistencySummaryStatistics

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

the class FullCheckIntegrationTest method shouldReportInvalidPropertyKeyIdInUniquenessConstraintRule.

@Test
public void shouldReportInvalidPropertyKeyIdInUniquenessConstraintRule() throws Exception {
    // Given
    int labelId = createLabel();
    int propertyKeyId = fixture.idGenerator().propertyKey();
    createUniquenessConstraintRule(labelId, propertyKeyId);
    // When
    ConsistencySummaryStatistics stats = check();
    // Then
    // invalid property key in both index & owning constraint
    on(stats).verify(RecordType.SCHEMA, 2).andThatsAllFolks();
}
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