Search in sources :

Example 1 with SetInitialStateInNativeIndex

use of org.neo4j.index.SetInitialStateInNativeIndex in project neo4j by neo4j.

the class IndexCleanupIT method mustClearIndexDirectoryOnDropWhileFailed.

@ParameterizedTest
@EnumSource(SchemaIndex.class)
void mustClearIndexDirectoryOnDropWhileFailed(SchemaIndex schemaIndex) throws IOException {
    configureDb(schemaIndex);
    createIndex(db, true);
    IndexProviderDescriptor providerDescriptor = new IndexProviderDescriptor(schemaIndex.providerKey(), schemaIndex.providerVersion());
    SetInitialStateInNativeIndex setInitialStateInNativeIndex = new SetInitialStateInNativeIndex(BYTE_FAILED, providerDescriptor);
    restartDatabase(schemaIndex, setInitialStateInNativeIndex);
    try (Transaction tx = db.beginTx()) {
        for (IndexDefinition index : tx.schema().getIndexes()) {
            // ignore the lookup indexes which are there by default and have nothing to do with this test
            if (index.getIndexType() == IndexType.LOOKUP) {
                continue;
            }
            IndexState indexState = tx.schema().getIndexState(index);
            assertEquals(IndexState.FAILED, indexState, "expected index state to be " + IndexState.FAILED);
        }
        tx.commit();
    }
    // when
    dropAllIndexes();
    // then
    assertNoIndexFilesExisting(providerDirectories(fs, db));
}
Also used : SetInitialStateInNativeIndex(org.neo4j.index.SetInitialStateInNativeIndex) Transaction(org.neo4j.graphdb.Transaction) IndexDefinition(org.neo4j.graphdb.schema.IndexDefinition) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) IndexState(org.neo4j.graphdb.schema.Schema.IndexState) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 EnumSource (org.junit.jupiter.params.provider.EnumSource)1 Transaction (org.neo4j.graphdb.Transaction)1 IndexDefinition (org.neo4j.graphdb.schema.IndexDefinition)1 IndexState (org.neo4j.graphdb.schema.Schema.IndexState)1 SetInitialStateInNativeIndex (org.neo4j.index.SetInitialStateInNativeIndex)1 IndexProviderDescriptor (org.neo4j.internal.schema.IndexProviderDescriptor)1