Search in sources :

Example 36 with IndexProvider

use of org.neo4j.kernel.api.index.IndexProvider in project neo4j by neo4j.

the class FusionIndexProviderTest method shouldReportFailedIfAnyIsFailed.

@Test
void shouldReportFailedIfAnyIsFailed() {
    // given
    IndexProvider provider = fusionIndexProvider;
    for (InternalIndexState state : InternalIndexState.values()) {
        for (IndexProvider failedProvider : aliveProviders) {
            // when
            for (IndexProvider aliveProvider : aliveProviders) {
                setInitialState(aliveProvider, failedProvider == aliveProvider ? InternalIndexState.FAILED : state);
            }
            InternalIndexState initialState = provider.getInitialState(AN_INDEX, NULL);
            // then
            assertEquals(InternalIndexState.FAILED, initialState);
        }
    }
}
Also used : GenericNativeIndexProvider(org.neo4j.kernel.impl.index.schema.GenericNativeIndexProvider) IndexProvider(org.neo4j.kernel.api.index.IndexProvider) InternalIndexState(org.neo4j.internal.kernel.api.InternalIndexState) Test(org.junit.jupiter.api.Test)

Example 37 with IndexProvider

use of org.neo4j.kernel.api.index.IndexProvider in project neo4j by neo4j.

the class FusionIndexProviderTest method getPopulationFailureMustReportFailureWhenMultipleFail.

@Test
void getPopulationFailureMustReportFailureWhenMultipleFail() {
    // when
    List<String> failureMessages = new ArrayList<>();
    for (IndexProvider aliveProvider : aliveProviders) {
        String failureMessage = "FAILURE[" + aliveProvider + "]";
        failureMessages.add(failureMessage);
        when(aliveProvider.getPopulationFailure(any(IndexDescriptor.class), any(CursorContext.class))).thenReturn(failureMessage);
    }
    // then
    String populationFailure = fusionIndexProvider.getPopulationFailure(AN_INDEX, NULL);
    for (String failureMessage : failureMessages) {
        assertThat(populationFailure).contains(failureMessage);
    }
}
Also used : GenericNativeIndexProvider(org.neo4j.kernel.impl.index.schema.GenericNativeIndexProvider) IndexProvider(org.neo4j.kernel.api.index.IndexProvider) ArrayList(java.util.ArrayList) CursorContext(org.neo4j.io.pagecache.context.CursorContext) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Example 38 with IndexProvider

use of org.neo4j.kernel.api.index.IndexProvider in project neo4j by neo4j.

the class FusionIndexProviderTest method getPopulationFailureMustReportFailureWhenAnyFailed.

@Test
void getPopulationFailureMustReportFailureWhenAnyFailed() {
    for (IndexProvider failingProvider : aliveProviders) {
        // when
        String failure = "failure";
        for (IndexProvider provider : aliveProviders) {
            if (provider == failingProvider) {
                when(provider.getPopulationFailure(any(IndexDescriptor.class), any(CursorContext.class))).thenReturn(failure);
            } else {
                when(provider.getPopulationFailure(any(IndexDescriptor.class), any(CursorContext.class))).thenReturn(StringUtils.EMPTY);
            }
        }
        // then
        assertThat(fusionIndexProvider.getPopulationFailure(AN_INDEX, NULL)).contains(failure);
    }
}
Also used : GenericNativeIndexProvider(org.neo4j.kernel.impl.index.schema.GenericNativeIndexProvider) IndexProvider(org.neo4j.kernel.api.index.IndexProvider) CursorContext(org.neo4j.io.pagecache.context.CursorContext) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Example 39 with IndexProvider

use of org.neo4j.kernel.api.index.IndexProvider in project neo4j by neo4j.

the class FusionIndexProviderTest method shouldReportPopulatingIfAnyIsPopulating.

@Test
void shouldReportPopulatingIfAnyIsPopulating() {
    // given
    for (InternalIndexState state : array(InternalIndexState.ONLINE, InternalIndexState.POPULATING)) {
        for (IndexProvider populatingProvider : aliveProviders) {
            // when
            for (IndexProvider aliveProvider : aliveProviders) {
                setInitialState(aliveProvider, populatingProvider == aliveProvider ? InternalIndexState.POPULATING : state);
            }
            InternalIndexState initialState = fusionIndexProvider.getInitialState(AN_INDEX, NULL);
            // then
            assertEquals(InternalIndexState.POPULATING, initialState);
        }
    }
}
Also used : GenericNativeIndexProvider(org.neo4j.kernel.impl.index.schema.GenericNativeIndexProvider) IndexProvider(org.neo4j.kernel.api.index.IndexProvider) InternalIndexState(org.neo4j.internal.kernel.api.InternalIndexState) Test(org.junit.jupiter.api.Test)

Example 40 with IndexProvider

use of org.neo4j.kernel.api.index.IndexProvider in project neo4j by neo4j.

the class FusionSlotSelectorTest method throwIfToManyInstances.

@Test
void throwIfToManyInstances() {
    // given
    EnumMap<IndexSlot, IndexProvider> instances = new EnumMap<>(IndexSlot.class);
    for (IndexSlot indexSlot : IndexSlot.values()) {
        instances.put(indexSlot, IndexProvider.EMPTY);
    }
    IndexProvider mockedIndxProvider = mock(IndexProvider.class);
    instances.put(GENERIC, mockedIndxProvider);
    InstanceSelector<IndexProvider> instanceSelector = new InstanceSelector<>(instances);
    // when, then
    assertThrows(IllegalArgumentException.class, () -> validateSelectorInstances(instanceSelector));
}
Also used : IndexProvider(org.neo4j.kernel.api.index.IndexProvider) EnumMap(java.util.EnumMap) Test(org.junit.jupiter.api.Test)

Aggregations

IndexProvider (org.neo4j.kernel.api.index.IndexProvider)40 Test (org.junit.jupiter.api.Test)23 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)17 IndexProviderDescriptor (org.neo4j.internal.schema.IndexProviderDescriptor)14 ArrayList (java.util.ArrayList)9 Config (org.neo4j.configuration.Config)9 GenericNativeIndexProvider (org.neo4j.kernel.impl.index.schema.GenericNativeIndexProvider)7 DefaultIndexProviderMap (org.neo4j.kernel.impl.transaction.state.DefaultIndexProviderMap)7 CursorContext (org.neo4j.io.pagecache.context.CursorContext)6 IndexSample (org.neo4j.kernel.api.index.IndexSample)6 TokenNameLookup (org.neo4j.common.TokenNameLookup)5 IndexAccessor (org.neo4j.kernel.api.index.IndexAccessor)5 TokenIndexProvider (org.neo4j.kernel.impl.index.schema.TokenIndexProvider)5 JobScheduler (org.neo4j.scheduler.JobScheduler)5 IOException (java.io.IOException)4 String.format (java.lang.String.format)4 Arrays (java.util.Arrays)4 HashMap (java.util.HashMap)4 List (java.util.List)4 Map (java.util.Map)4