Search in sources :

Example 41 with IndexRule

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

the class SchemaRecordCheckTest method shouldReportTwoIndexRulesWithDuplicateContent.

@Test
public void shouldReportTwoIndexRulesWithDuplicateContent() throws Exception {
    // given
    int ruleId1 = 0;
    int ruleId2 = 1;
    DynamicRecord record1 = inUse(dynamicRecord(ruleId1));
    DynamicRecord record2 = inUse(dynamicRecord(ruleId2));
    SchemaIndexProvider.Descriptor providerDescriptor = new SchemaIndexProvider.Descriptor("in-memory", "1.0");
    IndexRule rule1 = constraintIndexRule(ruleId1, labelId, propertyKeyId, providerDescriptor, (long) ruleId1);
    IndexRule rule2 = constraintIndexRule(ruleId2, labelId, propertyKeyId, providerDescriptor, (long) ruleId2);
    when(checker().ruleAccess.loadSingleSchemaRule(ruleId1)).thenReturn(rule1);
    when(checker().ruleAccess.loadSingleSchemaRule(ruleId2)).thenReturn(rule2);
    add(inUse(new LabelTokenRecord(labelId)));
    add(inUse(new PropertyKeyTokenRecord(propertyKeyId)));
    // when
    check(record1);
    ConsistencyReport.SchemaConsistencyReport report = check(record2);
    // then
    verify(report).duplicateRuleContent(record1);
}
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) SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) NodePropertyDescriptor(org.neo4j.kernel.api.schema.NodePropertyDescriptor) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 42 with IndexRule

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

the class SchemaRecordCheckTest method shouldReportInvalidLabelReferences.

@Test
public void shouldReportInvalidLabelReferences() throws Exception {
    // given
    int schemaRuleId = 0;
    DynamicRecord record = inUse(dynamicRecord(schemaRuleId));
    SchemaIndexProvider.Descriptor providerDescriptor = new SchemaIndexProvider.Descriptor("in-memory", "1.0");
    IndexRule rule = indexRule(schemaRuleId, labelId, propertyKeyId, providerDescriptor);
    when(checker().ruleAccess.loadSingleSchemaRule(schemaRuleId)).thenReturn(rule);
    LabelTokenRecord labelTokenRecord = add(notInUse(new LabelTokenRecord(labelId)));
    add(inUse(new PropertyKeyTokenRecord(propertyKeyId)));
    // when
    ConsistencyReport.SchemaConsistencyReport report = check(record);
    // then
    verify(report).labelNotInUse(labelTokenRecord);
}
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) SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) NodePropertyDescriptor(org.neo4j.kernel.api.schema.NodePropertyDescriptor) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 43 with IndexRule

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

the class SchemaRecordCheckTest method shouldReportUniquenessConstraintNotReferencingBack.

@Test
public void shouldReportUniquenessConstraintNotReferencingBack() throws Exception {
    // given
    int ruleId1 = 0;
    int ruleId2 = 1;
    DynamicRecord record1 = inUse(dynamicRecord(ruleId1));
    DynamicRecord record2 = inUse(dynamicRecord(ruleId2));
    SchemaIndexProvider.Descriptor providerDescriptor = new SchemaIndexProvider.Descriptor("in-memory", "1.0");
    IndexRule rule1 = constraintIndexRule(ruleId1, labelId, propertyKeyId, providerDescriptor, (long) ruleId2);
    ConstraintRule rule2 = uniquenessConstraintRule(ruleId2, labelId, propertyKeyId, ruleId2);
    when(checker().ruleAccess.loadSingleSchemaRule(ruleId1)).thenReturn(rule1);
    when(checker().ruleAccess.loadSingleSchemaRule(ruleId2)).thenReturn(rule2);
    add(inUse(new LabelTokenRecord(labelId)));
    add(inUse(new PropertyKeyTokenRecord(propertyKeyId)));
    // when
    check(record1);
    check(record2);
    SchemaRecordCheck obligationChecker = checker().forObligationChecking();
    check(obligationChecker, record1);
    ConsistencyReport.SchemaConsistencyReport report = check(obligationChecker, record2);
    // then
    verify(report).uniquenessConstraintNotReferencingBack(record1);
}
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) SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) ConstraintRule(org.neo4j.kernel.impl.store.record.ConstraintRule) SchemaRuleUtil.uniquenessConstraintRule(org.neo4j.consistency.checking.SchemaRuleUtil.uniquenessConstraintRule) NodePropertyDescriptor(org.neo4j.kernel.api.schema.NodePropertyDescriptor) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 44 with IndexRule

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

the class SchemaRecordCheckTest method shouldReportUnreferencedConstraintIndex.

@Test
public void shouldReportUnreferencedConstraintIndex() throws Exception {
    // given
    int ruleId = 0;
    DynamicRecord record = inUse(dynamicRecord(ruleId));
    SchemaIndexProvider.Descriptor providerDescriptor = new SchemaIndexProvider.Descriptor("in-memory", "1.0");
    IndexRule rule = constraintIndexRule(ruleId, labelId, propertyKeyId, providerDescriptor, (long) ruleId);
    when(checker().ruleAccess.loadSingleSchemaRule(ruleId)).thenReturn(rule);
    add(inUse(new LabelTokenRecord(labelId)));
    add(inUse(new PropertyKeyTokenRecord(propertyKeyId)));
    // when
    check(record);
    SchemaRecordCheck obligationChecker = checker().forObligationChecking();
    ConsistencyReport.SchemaConsistencyReport report = check(obligationChecker, record);
    // then
    verify(report).missingObligation(SchemaRule.Kind.UNIQUENESS_CONSTRAINT);
}
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) SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) NodePropertyDescriptor(org.neo4j.kernel.api.schema.NodePropertyDescriptor) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 45 with IndexRule

use of org.neo4j.kernel.impl.store.record.IndexRule 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)

Aggregations

IndexRule (org.neo4j.kernel.impl.store.record.IndexRule)60 Test (org.junit.Test)42 SchemaIndexProvider (org.neo4j.kernel.api.index.SchemaIndexProvider)24 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)22 SchemaRuleUtil.constraintIndexRule (org.neo4j.consistency.checking.SchemaRuleUtil.constraintIndexRule)14 NodePropertyDescriptor (org.neo4j.kernel.api.schema.NodePropertyDescriptor)9 ConstraintRule (org.neo4j.kernel.impl.store.record.ConstraintRule)9 LabelTokenRecord (org.neo4j.kernel.impl.store.record.LabelTokenRecord)9 PropertyKeyTokenRecord (org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)9 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)8 NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)8 IndexSamplingConfig (org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig)8 IndexAccessor (org.neo4j.kernel.api.index.IndexAccessor)7 BatchTransactionApplier (org.neo4j.kernel.impl.api.BatchTransactionApplier)7 SchemaStorage (org.neo4j.kernel.impl.store.SchemaStorage)7 LabelTokenCommand (org.neo4j.kernel.impl.transaction.command.Command.LabelTokenCommand)7 PropertyKeyTokenCommand (org.neo4j.kernel.impl.transaction.command.Command.PropertyKeyTokenCommand)7 RelationshipTypeTokenCommand (org.neo4j.kernel.impl.transaction.command.Command.RelationshipTypeTokenCommand)7 ArrayList (java.util.ArrayList)6 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)6