Search in sources :

Example 1 with ConsistencySummaryStatistics

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

the class FullCheckIntegrationTest method shouldReportChainedRelationshipGroupOwnerInconsistency.

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

        @Override
        protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
            /* node -[first]-> groupA -[next]-> groupB
                 *    ^               /                |
                 *     \--[owner]----               [owner]
                 *                                     v
                 *                                  otherNode
                 */
            long node = next.node();
            long otherNode = next.node();
            long groupA = next.relationshipGroup();
            long groupB = next.relationshipGroup();
            tx.create(inUse(new NodeRecord(node, true, groupA, NO_NEXT_PROPERTY.intValue())));
            tx.create(inUse(new NodeRecord(otherNode, false, NO_NEXT_RELATIONSHIP.intValue(), NO_NEXT_PROPERTY.intValue())));
            tx.create(withNext(withOwner(inUse(new RelationshipGroupRecord(groupA, C)), node), groupB));
            tx.create(withOwner(inUse(new RelationshipGroupRecord(groupB, T)), otherNode));
        }
    });
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    on(stats).verify(RecordType.RELATIONSHIP_GROUP, 1).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 2 with ConsistencySummaryStatistics

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

the class FullCheckIntegrationTest method shouldReportRelationshipLabelNameInconsistencies.

@Test
public void shouldReportRelationshipLabelNameInconsistencies() throws Exception {
    // given
    final Reference<Integer> inconsistentName = new Reference<>();
    fixture.apply(new GraphStoreFixture.Transaction() {

        @Override
        protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
            inconsistentName.set(next.relationshipType());
            tx.relationshipType(inconsistentName.get(), "FOO");
        }
    });
    StoreAccess access = fixture.directStoreAccess().nativeStores();
    DynamicRecord record = access.getRelationshipTypeNameStore().getRecord(inconsistentName.get(), access.getRelationshipTypeNameStore().newRecord(), FORCE);
    record.setNextBlock(record.getId());
    access.getRelationshipTypeNameStore().updateRecord(record);
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    on(stats).verify(RecordType.RELATIONSHIP_TYPE_NAME, 1).andThatsAllFolks();
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) DirectStoreAccess(org.neo4j.kernel.api.direct.DirectStoreAccess) StoreAccess(org.neo4j.kernel.impl.store.StoreAccess) 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 3 with ConsistencySummaryStatistics

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

the class FullCheckIntegrationTest method shouldReportLabelInconsistencies.

@Test
public void shouldReportLabelInconsistencies() throws Exception {
    // given
    StoreAccess access = fixture.directStoreAccess().nativeStores();
    LabelTokenRecord record = access.getLabelTokenStore().getRecord(1, access.getLabelTokenStore().newRecord(), FORCE);
    record.setNameId(20);
    record.setInUse(true);
    access.getLabelTokenStore().updateRecord(record);
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    on(stats).verify(RecordType.LABEL, 1).andThatsAllFolks();
}
Also used : DirectStoreAccess(org.neo4j.kernel.api.direct.DirectStoreAccess) StoreAccess(org.neo4j.kernel.impl.store.StoreAccess) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) Test(org.junit.Test)

Example 4 with ConsistencySummaryStatistics

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

the class FullCheckIntegrationTest method shouldReportRelationshipGroupOwnerInvalidValue.

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

        @Override
        protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
            // node -[first]-> group -[owner]-> -1
            long group = next.relationshipGroup();
            tx.create(withOwner(inUse(new RelationshipGroupRecord(group, C)), -1));
        }
    });
    // 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 5 with ConsistencySummaryStatistics

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

the class FullCheckIntegrationTest method shouldReportPropertyKeyInconsistencies.

@Test
public void shouldReportPropertyKeyInconsistencies() throws Exception {
    // given
    final Reference<Integer> inconsistentKey = new Reference<>();
    fixture.apply(new GraphStoreFixture.Transaction() {

        @Override
        protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
            inconsistentKey.set(next.propertyKey());
            tx.propertyKey(inconsistentKey.get(), "FOO");
        }
    });
    StoreAccess access = fixture.directStoreAccess().nativeStores();
    DynamicRecord record = access.getPropertyKeyNameStore().getRecord(inconsistentKey.get() + 1, access.getPropertyKeyNameStore().newRecord(), FORCE);
    record.setInUse(false);
    access.getPropertyKeyNameStore().updateRecord(record);
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    on(stats).verify(RecordType.PROPERTY_KEY, 1).andThatsAllFolks();
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) DirectStoreAccess(org.neo4j.kernel.api.direct.DirectStoreAccess) StoreAccess(org.neo4j.kernel.impl.store.StoreAccess) 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)

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