Search in sources :

Example 11 with ConsistencySummaryStatistics

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

the class FullCheckIntegrationTest method shouldReportNodesThatAreNotIndexed.

@Test
public void shouldReportNodesThatAreNotIndexed() throws Exception {
    // given
    IndexSamplingConfig samplingConfig = new IndexSamplingConfig(Config.empty());
    Iterator<IndexRule> indexRuleIterator = new SchemaStorage(fixture.directStoreAccess().nativeStores().getSchemaStore()).indexesGetAll();
    while (indexRuleIterator.hasNext()) {
        IndexRule indexRule = indexRuleIterator.next();
        IndexAccessor accessor = fixture.directStoreAccess().indexes().getOnlineAccessor(indexRule.getId(), indexRule.getIndexDescriptor(), samplingConfig);
        IndexUpdater updater = accessor.newUpdater(IndexUpdateMode.ONLINE);
        updater.remove(asPrimitiveLongSet(indexedNodes));
        updater.close();
        accessor.close();
    }
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    on(stats).verify(RecordType.NODE, 1).andThatsAllFolks();
}
Also used : IndexSamplingConfig(org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig) IndexRule(org.neo4j.kernel.impl.store.record.IndexRule) SchemaRuleUtil.constraintIndexRule(org.neo4j.consistency.checking.SchemaRuleUtil.constraintIndexRule) SchemaStorage(org.neo4j.kernel.impl.store.SchemaStorage) IndexAccessor(org.neo4j.kernel.api.index.IndexAccessor) IndexUpdater(org.neo4j.kernel.api.index.IndexUpdater) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) Test(org.junit.Test)

Example 12 with ConsistencySummaryStatistics

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

the class FullCheckIntegrationTest method shouldManageUnusedRecordsWithWeirdDataIn.

@Test
public void shouldManageUnusedRecordsWithWeirdDataIn() throws Exception {
    // Given
    final AtomicLong id = new AtomicLong();
    fixture.apply(new GraphStoreFixture.Transaction() {

        @Override
        protected void transactionData(TransactionDataBuilder tx, IdGenerator next) {
            id.set(next.relationship());
            RelationshipRecord relationship = new RelationshipRecord(id.get());
            relationship.setFirstNode(-1);
            relationship.setSecondNode(-1);
            relationship.setInUse(true);
            tx.create(relationship);
        }
    });
    fixture.apply(new GraphStoreFixture.Transaction() {

        @Override
        protected void transactionData(TransactionDataBuilder tx, IdGenerator next) {
            RelationshipRecord relationship = new RelationshipRecord(id.get());
            tx.delete(relationship);
        }
    });
    // When
    ConsistencySummaryStatistics stats = check();
    // Then
    assertTrue(stats.isConsistent());
}
Also used : TransactionDataBuilder(org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder) AtomicLong(java.util.concurrent.atomic.AtomicLong) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) IdGenerator(org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator) GraphStoreFixture(org.neo4j.consistency.checking.GraphStoreFixture) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) Test(org.junit.Test)

Example 13 with ConsistencySummaryStatistics

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

the class FullCheckIntegrationTest method shouldReportOrphanedNodeDynamicLabelAsNodeInconsistency.

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

        @Override
        protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
            tx.nodeLabel(42, "Label");
            NodeRecord nodeRecord = new NodeRecord(next.node(), false, -1, -1);
            DynamicRecord record = inUse(new DynamicRecord(next.nodeLabel()));
            Collection<DynamicRecord> newRecords = new ArrayList<>();
            allocateFromNumbers(newRecords, prependNodeId(next.node(), new long[] { 42L }), new ReusableRecordsAllocator(60, record));
            nodeRecord.setLabelField(dynamicPointer(newRecords), newRecords);
            tx.create(nodeRecord);
        }
    });
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    on(stats).verify(RecordType.NODE_DYNAMIC_LABEL, 1).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) Collection(java.util.Collection) GraphStoreFixture(org.neo4j.consistency.checking.GraphStoreFixture) ReusableRecordsAllocator(org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) Test(org.junit.Test)

Example 14 with ConsistencySummaryStatistics

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

the class FullCheckIntegrationTest method shouldReportDuplicateConstraintReferences.

@Test
public void shouldReportDuplicateConstraintReferences() 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) ruleId1);
            IndexRule rule2 = constraintIndexRule(ruleId2, labelId, propertyKeyId, DESCRIPTOR, (long) ruleId1);
            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, 4).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) Collection(java.util.Collection) GraphStoreFixture(org.neo4j.consistency.checking.GraphStoreFixture) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) Test(org.junit.Test)

Example 15 with ConsistencySummaryStatistics

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

the class FullCheckIntegrationTest method shouldReportRelationshipGroupChainInconsistencies.

@Test
public void shouldReportRelationshipGroupChainInconsistencies() 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();
            tx.create(inUse(new NodeRecord(node, true, group, NO_NEXT_PROPERTY.intValue())));
            tx.create(withOwner(withNext(inUse(new RelationshipGroupRecord(group, C)), group + 1), 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)

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