Search in sources :

Example 1 with IdGenerator

use of org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator 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 2 with IdGenerator

use of org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator in project neo4j by neo4j.

the class FullCheckIntegrationTest method shouldReportLabelScanStoreInconsistencies.

@Test
public void shouldReportLabelScanStoreInconsistencies() throws Exception {
    // given
    GraphStoreFixture.IdGenerator idGenerator = fixture.idGenerator();
    long nodeId1 = idGenerator.node();
    long labelId = idGenerator.label() - 1;
    LabelScanStore labelScanStore = fixture.directStoreAccess().labelScanStore();
    Iterable<NodeLabelUpdate> nodeLabelUpdates = asIterable(labelChanges(nodeId1, new long[] {}, new long[] { labelId }));
    write(labelScanStore, nodeLabelUpdates);
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    on(stats).verify(RecordType.LABEL_SCAN_DOCUMENT, 1).andThatsAllFolks();
}
Also used : LabelScanStore(org.neo4j.kernel.api.labelscan.LabelScanStore) IdGenerator(org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator) NodeLabelUpdate(org.neo4j.kernel.api.labelscan.NodeLabelUpdate) GraphStoreFixture(org.neo4j.consistency.checking.GraphStoreFixture) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)2 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)2 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 TransactionDataBuilder (org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder)1 LabelScanStore (org.neo4j.kernel.api.labelscan.LabelScanStore)1 NodeLabelUpdate (org.neo4j.kernel.api.labelscan.NodeLabelUpdate)1 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)1