use of org.neo4j.kernel.impl.store.MetaDataStore in project neo4j by neo4j.
the class IntegrityValidatorTest method transactionsStartedBeforeAConstraintWasCreatedAreDisallowed.
@Test
public void transactionsStartedBeforeAConstraintWasCreatedAreDisallowed() throws Exception {
// Given
NeoStores store = mock(NeoStores.class);
MetaDataStore metaDataStore = mock(MetaDataStore.class);
when(store.getMetaDataStore()).thenReturn(metaDataStore);
IndexingService indexes = mock(IndexingService.class);
when(metaDataStore.getLatestConstraintIntroducingTx()).thenReturn(10L);
IntegrityValidator validator = new IntegrityValidator(store, indexes);
// When
try {
validator.validateTransactionStartKnowledge(1);
fail("Should have thrown integrity error.");
} catch (Exception e) {
// good
}
}
use of org.neo4j.kernel.impl.store.MetaDataStore in project neo4j by neo4j.
the class CountsStoreRecoveryTest method flushNeoStoreOnly.
private void flushNeoStoreOnly() {
NeoStores neoStores = ((GraphDatabaseAPI) db).getDependencyResolver().resolveDependency(RecordStorageEngine.class).testAccessNeoStores();
MetaDataStore metaDataStore = neoStores.getMetaDataStore();
metaDataStore.flush(NULL);
}
use of org.neo4j.kernel.impl.store.MetaDataStore in project neo4j by neo4j.
the class IntegrityValidatorTest method transactionsStartedBeforeAConstraintWasCreatedAreDisallowed.
@Test
void transactionsStartedBeforeAConstraintWasCreatedAreDisallowed() {
// Given
NeoStores store = mock(NeoStores.class);
MetaDataStore metaDataStore = mock(MetaDataStore.class);
when(store.getMetaDataStore()).thenReturn(metaDataStore);
when(metaDataStore.getLatestConstraintIntroducingTx()).thenReturn(10L);
IntegrityValidator validator = new IntegrityValidator(store);
// When
assertThrows(Exception.class, () -> validator.validateTransactionStartKnowledge(1));
}
use of org.neo4j.kernel.impl.store.MetaDataStore in project neo4j by neo4j.
the class IntegrityValidatorTest method relationshipPropertyIndexesNotAllowedForOldKernelVersions.
@Test
void relationshipPropertyIndexesNotAllowedForOldKernelVersions() {
// Given
NeoStores store = mock(NeoStores.class);
MetaDataStore metaDataStore = mock(MetaDataStore.class);
when(store.getMetaDataStore()).thenReturn(metaDataStore);
when(metaDataStore.kernelVersion()).thenReturn(KernelVersion.V4_2);
IndexUpdateListener indexes = mock(IndexUpdateListener.class);
IntegrityValidator validator = new IntegrityValidator(store);
validator.setIndexValidator(indexes);
var index = IndexPrototype.forSchema(SchemaDescriptor.forRelType(3, 14)).withIndexType(IndexType.BTREE).withName("any name").materialise(4);
// When
assertThatThrownBy(() -> validator.validateSchemaRule(index)).isInstanceOf(TransactionFailureException.class).hasMessageContaining("Required kernel version for this transaction is V4_3_D4, but actual version was V4_2.");
}
use of org.neo4j.kernel.impl.store.MetaDataStore in project neo4j by neo4j.
the class RecordStorageEngineTestUtils method applyLogicalChanges.
public static void applyLogicalChanges(RecordStorageEngine storageEngine, ThrowingBiConsumer<ReadableTransactionState, TxStateVisitor, Exception> changes) throws Exception {
ReadableTransactionState txState = mock(ReadableTransactionState.class);
doAnswer(invocationOnMock -> {
TxStateVisitor visitor = invocationOnMock.getArgument(0);
changes.accept(txState, visitor);
return null;
}).when(txState).accept(any());
List<StorageCommand> commands = new ArrayList<>();
NeoStores neoStores = storageEngine.testAccessNeoStores();
MetaDataStore metaDataStore = neoStores.getMetaDataStore();
CursorContext cursorContext = CursorContext.NULL;
try (RecordStorageCommandCreationContext commandCreationContext = storageEngine.newCommandCreationContext(EmptyMemoryTracker.INSTANCE)) {
commandCreationContext.initialize(cursorContext);
storageEngine.createCommands(commands, txState, storageEngine.newReader(), commandCreationContext, ResourceLocker.IGNORE, LockTracer.NONE, metaDataStore.getLastCommittedTransactionId(), t -> t, cursorContext, EmptyMemoryTracker.INSTANCE);
storageEngine.apply(new GroupOfCommands(metaDataStore.nextCommittingTransactionId(), commands.toArray(new StorageCommand[0])), TransactionApplicationMode.EXTERNAL);
}
}
Aggregations