Search in sources :

Example 1 with NeoStoreRecord

use of org.neo4j.kernel.impl.store.record.NeoStoreRecord in project neo4j by neo4j.

the class OwnerCheckTest method shouldReportRelationshipWithReferenceToTheGraphGlobalChain.

@Test
public void shouldReportRelationshipWithReferenceToTheGraphGlobalChain() throws Exception {
    // given
    OwnerCheck decorator = new OwnerCheck(true);
    RecordCheck<RelationshipRecord, ConsistencyReport.RelationshipConsistencyReport> relationshipChecker = decorator.decorateRelationshipChecker(dummyRelationshipChecker());
    RecordCheck<NeoStoreRecord, ConsistencyReport.NeoStoreConsistencyReport> neoStoreCheck = decorator.decorateNeoStoreChecker(dummyNeoStoreCheck());
    RecordAccessStub records = new RecordAccessStub();
    NeoStoreRecord master = records.add(new NeoStoreRecord());
    master.setNextProp(7);
    RelationshipRecord relationship = records.add(inUse(new RelationshipRecord(1, 0, 1, 0)));
    relationship.setNextProp(7);
    // when
    ConsistencyReport.NeoStoreConsistencyReport masterReport = check(ConsistencyReport.NeoStoreConsistencyReport.class, neoStoreCheck, master, records);
    ConsistencyReport.RelationshipConsistencyReport relationshipReport = check(ConsistencyReport.RelationshipConsistencyReport.class, relationshipChecker, relationship, records);
    // then
    verifyZeroInteractions(masterReport);
    verify(relationshipReport).multipleOwners(master);
}
Also used : NeoStoreRecord(org.neo4j.kernel.impl.store.record.NeoStoreRecord) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) RecordAccessStub(org.neo4j.consistency.store.RecordAccessStub) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 2 with NeoStoreRecord

use of org.neo4j.kernel.impl.store.record.NeoStoreRecord in project neo4j by neo4j.

the class OwnerCheckTest method shouldReportNodeStoreReferencingSameChainAsRelationship.

@Test
public void shouldReportNodeStoreReferencingSameChainAsRelationship() throws Exception {
    // given
    OwnerCheck decorator = new OwnerCheck(true);
    RecordCheck<RelationshipRecord, ConsistencyReport.RelationshipConsistencyReport> relationshipChecker = decorator.decorateRelationshipChecker(dummyRelationshipChecker());
    RecordCheck<NeoStoreRecord, ConsistencyReport.NeoStoreConsistencyReport> neoStoreCheck = decorator.decorateNeoStoreChecker(dummyNeoStoreCheck());
    RecordAccessStub records = new RecordAccessStub();
    NeoStoreRecord master = records.add(new NeoStoreRecord());
    master.setNextProp(7);
    RelationshipRecord relationship = records.add(inUse(new RelationshipRecord(1, 0, 1, 0)));
    relationship.setNextProp(7);
    // when
    ConsistencyReport.RelationshipConsistencyReport relationshipReport = check(ConsistencyReport.RelationshipConsistencyReport.class, relationshipChecker, relationship, records);
    ConsistencyReport.NeoStoreConsistencyReport masterReport = check(ConsistencyReport.NeoStoreConsistencyReport.class, neoStoreCheck, master, records);
    // then
    verifyZeroInteractions(relationshipReport);
    verify(masterReport).multipleOwners(relationship);
}
Also used : NeoStoreRecord(org.neo4j.kernel.impl.store.record.NeoStoreRecord) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) RecordAccessStub(org.neo4j.consistency.store.RecordAccessStub) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 3 with NeoStoreRecord

use of org.neo4j.kernel.impl.store.record.NeoStoreRecord in project neo4j by neo4j.

the class MetaDataStoreCheckTest method shouldReportPropertyNotFirstInChain.

@Test
public void shouldReportPropertyNotFirstInChain() throws Exception {
    // given
    NeoStoreRecord record = new NeoStoreRecord();
    PropertyRecord property = add(inUse(new PropertyRecord(7)));
    property.setPrevProp(6);
    record.setNextProp(property.getId());
    // when
    ConsistencyReport.NeoStoreConsistencyReport report = check(record);
    // then
    verify(report).propertyNotFirstInChain(property);
    verifyNoMoreInteractions(report);
}
Also used : NeoStoreRecord(org.neo4j.kernel.impl.store.record.NeoStoreRecord) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 4 with NeoStoreRecord

use of org.neo4j.kernel.impl.store.record.NeoStoreRecord in project neo4j by neo4j.

the class CheckTxLogsTest method shouldReportNeoStoreInconsistenciesFromDifferentLogs.

@Test
public void shouldReportNeoStoreInconsistenciesFromDifferentLogs() throws IOException {
    // Given
    File log1 = logFile(1);
    File log2 = logFile(2);
    File log3 = logFile(3);
    writeTxContent(log1, 0, new Command.NeoStoreCommand(new NeoStoreRecord(), createNeoStoreRecord(42)), new Command.PropertyCommand(propertyRecord(5, false, -1, -1), propertyRecord(5, true, -1, -1, 777)), new Command.NeoStoreCommand(createNeoStoreRecord(42), createNeoStoreRecord(21)));
    writeTxContent(log2, 0, new Command.NeoStoreCommand(createNeoStoreRecord(12), createNeoStoreRecord(21)));
    writeTxContent(log3, 0, new Command.NeoStoreCommand(createNeoStoreRecord(13), createNeoStoreRecord(21)));
    CapturingInconsistenciesHandler handler = new CapturingInconsistenciesHandler();
    CheckTxLogs checker = new CheckTxLogs(System.out, fsRule.get());
    // When
    checker.scan(new PhysicalLogFiles(storeDirectory, fsRule.get()), handler, NEO_STORE);
    // Then
    assertEquals(2, handler.recordInconsistencies.size());
    NeoStoreRecord seenRecord1 = (NeoStoreRecord) handler.recordInconsistencies.get(0).committed.record();
    NeoStoreRecord currentRecord1 = (NeoStoreRecord) handler.recordInconsistencies.get(0).current.record();
    assertEquals(21, seenRecord1.getNextProp());
    assertEquals(12, currentRecord1.getNextProp());
    NeoStoreRecord seenRecord2 = (NeoStoreRecord) handler.recordInconsistencies.get(1).committed.record();
    NeoStoreRecord currentRecord2 = (NeoStoreRecord) handler.recordInconsistencies.get(1).current.record();
    assertEquals(21, seenRecord2.getNextProp());
    assertEquals(13, currentRecord2.getNextProp());
}
Also used : NeoStoreRecord(org.neo4j.kernel.impl.store.record.NeoStoreRecord) Command(org.neo4j.kernel.impl.transaction.command.Command) File(java.io.File) PhysicalLogFile(org.neo4j.kernel.impl.transaction.log.PhysicalLogFile) PhysicalLogFiles(org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles) Test(org.junit.Test)

Example 5 with NeoStoreRecord

use of org.neo4j.kernel.impl.store.record.NeoStoreRecord in project neo4j by neo4j.

the class CheckTxLogsTest method createNeoStoreRecord.

private NeoStoreRecord createNeoStoreRecord(int nextProp) {
    NeoStoreRecord neoStoreRecord = new NeoStoreRecord();
    neoStoreRecord.setNextProp(nextProp);
    return neoStoreRecord;
}
Also used : NeoStoreRecord(org.neo4j.kernel.impl.store.record.NeoStoreRecord)

Aggregations

NeoStoreRecord (org.neo4j.kernel.impl.store.record.NeoStoreRecord)36 Test (org.junit.Test)16 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)9 Test (org.junit.jupiter.api.Test)5 RecordAccessStub (org.neo4j.consistency.store.RecordAccessStub)5 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)5 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)3 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)3 Command (org.neo4j.kernel.impl.transaction.command.Command)3 File (java.io.File)2 BatchTransactionApplier (org.neo4j.kernel.impl.api.BatchTransactionApplier)2 LabelTokenCommand (org.neo4j.kernel.impl.transaction.command.Command.LabelTokenCommand)2 PropertyKeyTokenCommand (org.neo4j.kernel.impl.transaction.command.Command.PropertyKeyTokenCommand)2 RelationshipTypeTokenCommand (org.neo4j.kernel.impl.transaction.command.Command.RelationshipTypeTokenCommand)2 InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)2 PhysicalLogFile (org.neo4j.kernel.impl.transaction.log.PhysicalLogFile)2 PhysicalLogFiles (org.neo4j.kernel.impl.transaction.log.PhysicalLogFiles)2 LabelTokenRecord (org.neo4j.kernel.impl.store.record.LabelTokenRecord)1 PrimitiveRecord (org.neo4j.kernel.impl.store.record.PrimitiveRecord)1 PropertyKeyTokenRecord (org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)1