use of java.util.concurrent.TimeUnit.SECONDS in project neo4j by neo4j.
the class DatabaseIndexAccessorTest method shouldStopSamplingWhenIndexIsDropped.
@Test
public void shouldStopSamplingWhenIndexIsDropped() throws Exception {
// given
updateAndCommit(asList(add(nodeId, value), add(nodeId2, value2)));
// when
// needs to be acquired before drop() is called
IndexReader indexReader = accessor.newReader();
IndexSampler indexSampler = indexReader.createSampler();
Future<Void> drop = threading.executeAndAwait((IOFunction<Void, Void>) nothing -> {
accessor.drop();
return nothing;
}, null, waitingWhileIn(TaskCoordinator.class, "awaitCompletion"), 3, SECONDS);
try (IndexReader reader = indexReader) /* do not inline! */
{
indexSampler.sampleIndex();
fail("expected exception");
} catch (IndexNotFoundKernelException e) {
assertEquals("Index dropped while sampling.", e.getMessage());
} finally {
drop.get();
}
}
Aggregations