use of org.neo4j.test.rule.RepeatRule.Repeat in project neo4j by neo4j.
the class DynamicTaskExecutorTest method shouldCopeWithConcurrentIncrementOfProcessorsAndShutdown.
@Repeat(times = 10)
@Test
public void shouldCopeWithConcurrentIncrementOfProcessorsAndShutdown() throws Throwable {
// GIVEN
TaskExecutor<Void> executor = new DynamicTaskExecutor<>(1, 2, 2, PARK, "test");
Race race = new Race().withRandomStartDelays();
race.addContestant(() -> executor.close());
race.addContestant(() -> executor.processors(1));
// WHEN
race.go(10, SECONDS);
// THEN we should be able to do so, there was a recent fix here and before that fix
// shutdown() would hang, that's why we wait for 10 seconds here to cap it if there's an issue.
}
use of org.neo4j.test.rule.RepeatRule.Repeat in project neo4j by neo4j.
the class TestPropertyReadOnNewEntityBeforeLockRelease method shouldBeAbleToReadPropertiesFromNewNodeReturnedFromIndex.
@Test
@Repeat(times = 100)
public void shouldBeAbleToReadPropertiesFromNewNodeReturnedFromIndex() throws Exception {
String propertyKey = UUID.randomUUID().toString();
String propertyValue = UUID.randomUUID().toString();
AtomicBoolean start = new AtomicBoolean(false);
int readerDelay = ThreadLocalRandom.current().nextInt(MAX_READER_DELAY_MS);
Writer writer = new Writer(db, propertyKey, propertyValue, start);
Reader reader = new Reader(db, propertyKey, propertyValue, start, readerDelay);
ExecutorService executor = Executors.newFixedThreadPool(2);
Future<?> readResult;
Future<?> writeResult;
try {
writeResult = executor.submit(writer);
readResult = executor.submit(reader);
start.set(true);
} finally {
executor.shutdown();
executor.awaitTermination(20, TimeUnit.SECONDS);
}
assertNull(writeResult.get());
assertNull(readResult.get());
}
Aggregations