Search in sources :

Example 6 with TokenIndexProviderFactory

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();
    }
}
Also used : Path(java.nio.file.Path) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) Transaction(org.neo4j.graphdb.Transaction) TokenIndexProviderFactory(org.neo4j.kernel.impl.index.schema.TokenIndexProviderFactory) FailingGenericNativeIndexProviderFactory(org.neo4j.kernel.impl.index.schema.FailingGenericNativeIndexProviderFactory) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) Test(org.junit.jupiter.api.Test)

Example 7 with TokenIndexProviderFactory

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);
}
Also used : TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) TokenIndexProviderFactory(org.neo4j.kernel.impl.index.schema.TokenIndexProviderFactory) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) PageCache(org.neo4j.io.pagecache.PageCache) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 8 with TokenIndexProviderFactory

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()));
}
Also used : TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) TokenIndexProviderFactory(org.neo4j.kernel.impl.index.schema.TokenIndexProviderFactory) UncloseableDelegatingFileSystemAbstraction(org.neo4j.io.fs.UncloseableDelegatingFileSystemAbstraction) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 9 with 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());
}
Also used : ExtensionFactory(org.neo4j.kernel.extension.ExtensionFactory) TokenIndexProviderFactory(org.neo4j.kernel.impl.index.schema.TokenIndexProviderFactory) ExtensionCallback(org.neo4j.test.extension.ExtensionCallback)

Aggregations

TokenIndexProviderFactory (org.neo4j.kernel.impl.index.schema.TokenIndexProviderFactory)9 TestDatabaseManagementServiceBuilder (org.neo4j.test.TestDatabaseManagementServiceBuilder)7 BeforeEach (org.junit.jupiter.api.BeforeEach)2 Test (org.junit.jupiter.api.Test)2 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)2 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)2 Transaction (org.neo4j.graphdb.Transaction)2 FailingGenericNativeIndexProviderFactory (org.neo4j.kernel.impl.index.schema.FailingGenericNativeIndexProviderFactory)2 Path (java.nio.file.Path)1 Before (org.junit.Before)1 Disabled (org.junit.jupiter.api.Disabled)1 Config (org.neo4j.configuration.Config)1 ConsistencyCheckService (org.neo4j.consistency.ConsistencyCheckService)1 Node (org.neo4j.graphdb.Node)1 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)1 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)1 UncloseableDelegatingFileSystemAbstraction (org.neo4j.io.fs.UncloseableDelegatingFileSystemAbstraction)1 PageCache (org.neo4j.io.pagecache.PageCache)1 ExtensionFactory (org.neo4j.kernel.extension.ExtensionFactory)1 IndexSamplingConfig (org.neo4j.kernel.impl.api.index.IndexSamplingConfig)1