Search in sources :

Example 51 with ConsistencySummaryStatistics

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

the class FullCheckIntegrationTest method shouldNotReportRelationshipGroupInconsistenciesForConsistentRecords.

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

        @Override
        protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
            /* Create a little mini consistent structure:
                 *
                 *    nodeA --> groupA -[next]-> groupB
                 *      ^          |
                 *       \       [out]
                 *        \        v
                 *       [start]- rel -[end]-> nodeB
                 */
            long nodeA = next.node();
            long nodeB = next.node();
            long rel = next.relationship();
            long groupA = next.relationshipGroup();
            long groupB = next.relationshipGroup();
            tx.create(new NodeRecord(nodeA, true, groupA, NO_NEXT_PROPERTY.intValue()));
            tx.create(new NodeRecord(nodeB, false, rel, NO_NEXT_PROPERTY.intValue()));
            tx.create(firstInChains(new RelationshipRecord(rel, nodeA, nodeB, C), 1));
            tx.incrementRelationshipCount(ANY_LABEL, ANY_RELATIONSHIP_TYPE, ANY_LABEL, 1);
            tx.incrementRelationshipCount(ANY_LABEL, C, ANY_LABEL, 1);
            tx.create(withOwner(withRelationship(withNext(new RelationshipGroupRecord(groupA, C), groupB), Direction.OUTGOING, rel), nodeA));
            tx.create(withOwner(new RelationshipGroupRecord(groupB, T), nodeA));
        }
    });
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    assertTrue("should be consistent", stats.isConsistent());
}
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) 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 52 with ConsistencySummaryStatistics

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

the class FullCheckIntegrationTest method shouldReportBrokenSchemaRecordChain.

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

        @Override
        protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
            DynamicRecord schema = new DynamicRecord(next.schema());
            DynamicRecord schemaBefore = schema.clone();
            // Point to a record that isn't in use.
            schema.setNextBlock(next.schema());
            IndexRule rule = indexRule(schema.getId(), label1, key, DESCRIPTOR);
            schema.setData(rule.serialize());
            tx.createSchema(asList(schemaBefore), asList(schema), rule);
        }
    });
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    on(stats).verify(RecordType.SCHEMA, 3).andThatsAllFolks();
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) IndexRule(org.neo4j.kernel.impl.store.record.IndexRule) SchemaRuleUtil.constraintIndexRule(org.neo4j.consistency.checking.SchemaRuleUtil.constraintIndexRule) 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 53 with ConsistencySummaryStatistics

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

the class FullCheckIntegrationTest method shouldReportRelationshipGroupOwnerNotInUse.

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

        @Override
        protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
            // group -[owner]-> <not-in-use node>
            long node = next.node();
            long group = next.relationshipGroup();
            tx.create(withOwner(inUse(new RelationshipGroupRecord(group, C)), node));
        }
    });
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    on(stats).verify(RecordType.RELATIONSHIP_GROUP, 1).andThatsAllFolks();
}
Also used : 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 54 with ConsistencySummaryStatistics

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

the class FullCheckIntegrationTest method shouldReportInvalidLabelIdInIndexRule.

@Test
public void shouldReportInvalidLabelIdInIndexRule() throws Exception {
    // Given
    int labelId = fixture.idGenerator().label();
    int propertyKeyId = createPropertyKey();
    createIndexRule(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 55 with ConsistencySummaryStatistics

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

the class FullCheckIntegrationTest method shouldReportStringPropertyInconsistencies.

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

        @Override
        protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
            DynamicRecord string = new DynamicRecord(next.stringProperty());
            string.setInUse(true);
            string.setCreated();
            string.setType(PropertyType.STRING.intValue());
            string.setNextBlock(next.stringProperty());
            string.setData(UTF8.encode("hello world"));
            PropertyBlock block = new PropertyBlock();
            block.setSingleBlock((((long) PropertyType.STRING.intValue()) << 24) | (string.getId() << 28));
            block.addValueRecord(string);
            PropertyRecord property = new PropertyRecord(next.property());
            property.addPropertyBlock(block);
            tx.create(property);
        }
    });
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    on(stats).verify(RecordType.STRING_PROPERTY, 1).andThatsAllFolks();
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) 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)

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