use of org.neo4j.bolt.runtime.BoltConnection in project neo4j by neo4j.
the class ExecutorBoltSchedulerConcurrencyTest method newConnection.
private BoltConnection newConnection(String id) {
BoltConnection result = mock(BoltConnection.class);
when(result.id()).thenReturn(id);
when(result.remoteAddress()).thenReturn(new InetSocketAddress("localhost", 32_000));
return result;
}
use of org.neo4j.bolt.runtime.BoltConnection in project neo4j by neo4j.
the class ExecutorBoltSchedulerTest method newConnection.
private static BoltConnection newConnection(String id) {
BoltConnection result = mock(BoltConnection.class);
when(result.id()).thenReturn(id);
when(result.remoteAddress()).thenReturn(new InetSocketAddress("localhost", 32_000));
return result;
}
use of org.neo4j.bolt.runtime.BoltConnection in project neo4j by neo4j.
the class ExecutorBoltSchedulerTest method failingJobShouldLogAndStopConnection.
@Test
void failingJobShouldLogAndStopConnection() throws Throwable {
AtomicBoolean stopped = new AtomicBoolean();
String id = UUID.randomUUID().toString();
BoltConnection connection = newConnection(id);
var unexpectedError = new RuntimeException("some unexpected error");
doThrow(unexpectedError).when(connection).processNextBatch();
doAnswer(inv -> stopped.getAndSet(true)).when(connection).stop();
boltScheduler.init();
boltScheduler.start();
boltScheduler.created(connection);
boltScheduler.enqueued(connection, Jobs.noop());
Predicates.await(stopped::get, 1, MINUTES);
assertFalse(boltScheduler.isActive(connection));
verify(connection).processNextBatch();
verify(connection).stop();
assertThat(logProvider).forClass(ExecutorBoltScheduler.class).forLevel(ERROR).assertExceptionForLogMessage("Unexpected error during job scheduling for session").hasCause(unexpectedError);
}
use of org.neo4j.bolt.runtime.BoltConnection in project neo4j by neo4j.
the class ExecutorBoltSchedulerTest method enqueuedShouldScheduleJob.
@Test
void enqueuedShouldScheduleJob() throws Throwable {
String id = UUID.randomUUID().toString();
AtomicBoolean exitCondition = new AtomicBoolean();
BoltConnection connection = newConnection(id);
when(connection.processNextBatch()).thenAnswer(inv -> awaitExit(exitCondition));
boltScheduler.init();
boltScheduler.start();
boltScheduler.created(connection);
boltScheduler.enqueued(connection, Jobs.noop());
Predicates.await(() -> boltScheduler.isActive(connection), 1, MINUTES);
exitCondition.set(true);
Predicates.await(() -> !boltScheduler.isActive(connection), 1, MINUTES);
verify(connection).processNextBatch();
}
use of org.neo4j.bolt.runtime.BoltConnection in project neo4j by neo4j.
the class ExecutorBoltSchedulerTest method destroyedShouldRemoveConnectionFromActiveConnections.
@Test
void destroyedShouldRemoveConnectionFromActiveConnections() throws Throwable {
String id = UUID.randomUUID().toString();
BoltConnection connection = newConnection(id);
boltScheduler.init();
boltScheduler.start();
boltScheduler.created(connection);
boltScheduler.closed(connection);
assertFalse(boltScheduler.isRegistered(connection));
}
Aggregations