use of org.neo4j.kernel.impl.index.schema.TokenIndexProviderFactory in project neo4j by neo4j.
the class ConstraintIndexFailureIT method shouldFailToValidateConstraintsIfUnderlyingIndexIsFailed.
@Test
void shouldFailToValidateConstraintsIfUnderlyingIndexIsFailed() throws Exception {
// given a perfectly normal constraint
Path dir = directory.homePath();
DatabaseManagementService managementService = new TestDatabaseManagementServiceBuilder(dir).build();
GraphDatabaseService db = managementService.database(DEFAULT_DATABASE_NAME);
try (Transaction tx = db.beginTx()) {
tx.schema().constraintFor(label("Label1")).assertPropertyIsUnique("key1").create();
tx.commit();
} finally {
managementService.shutdown();
}
// Remove the indexes offline and start up with an index provider which reports FAILED as initial state. An ordeal, I know right...
FileUtils.deleteDirectory(IndexDirectoryStructure.baseSchemaIndexFolder(dir));
managementService = new TestDatabaseManagementServiceBuilder(dir).removeExtensions(INDEX_PROVIDERS_FILTER).addExtension(new FailingGenericNativeIndexProviderFactory(INITIAL_STATE)).addExtension(new TokenIndexProviderFactory()).noOpSystemGraphInitializer().build();
db = managementService.database(DEFAULT_DATABASE_NAME);
// when
try (Transaction tx = db.beginTx()) {
var e = assertThrows(ConstraintViolationException.class, () -> tx.createNode(label("Label1")).setProperty("key1", "value1"));
assertThat(e.getCause()).isInstanceOf(UnableToValidateConstraintException.class);
assertThat(e.getCause().getCause().getMessage()).contains("The index is in a failed state:").contains(INITIAL_STATE_FAILURE_MESSAGE);
} finally {
managementService.shutdown();
}
}
use of org.neo4j.kernel.impl.index.schema.TokenIndexProviderFactory in project neo4j by neo4j.
the class IndexCRUDIT method before.
@BeforeEach
void before() {
when(mockedIndexProvider.getProviderDescriptor()).thenReturn(PROVIDER_DESCRIPTOR);
when(mockedIndexProvider.storeMigrationParticipant(any(FileSystemAbstraction.class), any(PageCache.class), any())).thenReturn(StoreMigrationParticipant.NOT_PARTICIPATING);
when(mockedIndexProvider.completeConfiguration(any(IndexDescriptor.class))).then(inv -> inv.getArgument(0));
managementService = new TestDatabaseManagementServiceBuilder().setFileSystem(fs).setExtensions(asList(mockedIndexProviderFactory, new TokenIndexProviderFactory())).noOpSystemGraphInitializer().impermanent().setConfig(default_schema_provider, PROVIDER_DESCRIPTOR.name()).build();
db = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
}
use of org.neo4j.kernel.impl.index.schema.TokenIndexProviderFactory in project neo4j by neo4j.
the class IndexRestartIT method before.
@BeforeEach
void before() {
factory = new TestDatabaseManagementServiceBuilder();
factory.setFileSystem(new UncloseableDelegatingFileSystemAbstraction(fs));
factory.setExtensions(Arrays.asList(singleInstanceIndexProviderFactory("test", provider), new TokenIndexProviderFactory()));
}
use of org.neo4j.kernel.impl.index.schema.TokenIndexProviderFactory in project neo4j by neo4j.
the class SchemaIndexWaitingAcceptanceTest method configure.
@ExtensionCallback
void configure(TestDatabaseManagementServiceBuilder builder) {
List<ExtensionFactory<?>> extensions = Arrays.asList(singleInstanceIndexProviderFactory("test", provider), new TokenIndexProviderFactory());
builder.setExtensions(extensions).noOpSystemGraphInitializer();
builder.setConfig(default_schema_provider, provider.getProviderDescriptor().name());
}
Aggregations