Search in sources :

Example 36 with ConsistencySummaryStatistics

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

the class FullCheckIntegrationTest method shouldReportCyclesInDynamicRecordsWithLabels.

@Test
public void shouldReportCyclesInDynamicRecordsWithLabels() throws Exception {
    // given
    final List<DynamicRecord> chain = chainOfDynamicRecordsWithLabelsForANode(176).first();
    assertEquals("number of records in chain", 3, chain.size());
    assertEquals("all records full", chain.get(0).getLength(), chain.get(2).getLength());
    fixture.apply(new GraphStoreFixture.Transaction() {

        @Override
        protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
            long nodeId = ((long[]) getRightArray(readFullByteArrayFromHeavyRecords(chain, ARRAY)))[0];
            NodeRecord before = inUse(new NodeRecord(nodeId, false, -1, -1));
            NodeRecord after = inUse(new NodeRecord(nodeId, false, -1, -1));
            DynamicRecord record1 = chain.get(0).clone();
            DynamicRecord record2 = chain.get(1).clone();
            DynamicRecord record3 = chain.get(2).clone();
            record3.setNextBlock(record2.getId());
            before.setLabelField(dynamicPointer(chain), chain);
            after.setLabelField(dynamicPointer(chain), asList(record1, record2, record3));
            tx.update(before, after);
        }
    });
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    on(stats).verify(RecordType.NODE, 1).verify(RecordType.COUNTS, 177).andThatsAllFolks();
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) 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 37 with ConsistencySummaryStatistics

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

the class FullCheckIntegrationTest method shouldReportRelationshipGroupTypeInconsistencies.

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

        @Override
        protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
            long node = next.node();
            long group = next.relationshipGroup();
            int nonExistentType = next.relationshipType() + 1;
            tx.create(inUse(new NodeRecord(node, true, group, NO_NEXT_PROPERTY.intValue())));
            tx.create(withOwner(inUse(new RelationshipGroupRecord(group, nonExistentType)), node));
        }
    });
    // 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 38 with ConsistencySummaryStatistics

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

the class FullCheckIntegrationTest method shouldReportInvalidConstraintBackReferences.

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

        @Override
        protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
            int ruleId1 = (int) next.schema();
            int ruleId2 = (int) next.schema();
            int labelId = next.label();
            int propertyKeyId = next.propertyKey();
            DynamicRecord record1 = new DynamicRecord(ruleId1);
            DynamicRecord record2 = new DynamicRecord(ruleId2);
            DynamicRecord record1Before = record1.clone();
            DynamicRecord record2Before = record2.clone();
            IndexRule rule1 = constraintIndexRule(ruleId1, labelId, propertyKeyId, DESCRIPTOR, (long) ruleId2);
            ConstraintRule rule2 = uniquenessConstraintRule(ruleId2, labelId, propertyKeyId, ruleId2);
            Collection<DynamicRecord> records1 = serializeRule(rule1, record1);
            Collection<DynamicRecord> records2 = serializeRule(rule2, record2);
            assertEquals(asList(record1), records1);
            assertEquals(asList(record2), records2);
            tx.nodeLabel(labelId, "label");
            tx.propertyKey(propertyKeyId, "property");
            tx.createSchema(asList(record1Before), records1, rule1);
            tx.createSchema(asList(record2Before), records2, rule2);
        }
    });
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    on(stats).verify(RecordType.SCHEMA, 2).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) SchemaRuleUtil.uniquenessConstraintRule(org.neo4j.consistency.checking.SchemaRuleUtil.uniquenessConstraintRule) SchemaRuleUtil.relPropertyExistenceConstraintRule(org.neo4j.consistency.checking.SchemaRuleUtil.relPropertyExistenceConstraintRule) ConstraintRule(org.neo4j.kernel.impl.store.record.ConstraintRule) SchemaRuleUtil.nodePropertyExistenceConstraintRule(org.neo4j.consistency.checking.SchemaRuleUtil.nodePropertyExistenceConstraintRule) IdGenerator(org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator) Collection(java.util.Collection) GraphStoreFixture(org.neo4j.consistency.checking.GraphStoreFixture) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) Test(org.junit.Test)

Example 39 with ConsistencySummaryStatistics

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

the class FullCheckIntegrationTest method shouldReportRelationshipTypeInconsistencies.

@Test
public void shouldReportRelationshipTypeInconsistencies() throws Exception {
    // given
    StoreAccess access = fixture.directStoreAccess().nativeStores();
    RecordStore<RelationshipTypeTokenRecord> relTypeStore = access.getRelationshipTypeTokenStore();
    RelationshipTypeTokenRecord record = relTypeStore.getRecord((int) relTypeStore.nextId(), relTypeStore.newRecord(), FORCE);
    record.setNameId(20);
    record.setInUse(true);
    relTypeStore.updateRecord(record);
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    access.close();
    on(stats).verify(RecordType.RELATIONSHIP_TYPE, 1).andThatsAllFolks();
}
Also used : DirectStoreAccess(org.neo4j.kernel.api.direct.DirectStoreAccess) StoreAccess(org.neo4j.kernel.impl.store.StoreAccess) RelationshipTypeTokenRecord(org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) Test(org.junit.Test)

Example 40 with ConsistencySummaryStatistics

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

the class FullCheckIntegrationTest method shouldReportDuplicatedIndexRules.

@Test
public void shouldReportDuplicatedIndexRules() throws Exception {
    // Given
    int labelId = createLabel();
    int propertyKeyId = createPropertyKey();
    createIndexRule(labelId, propertyKeyId);
    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)

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