use of io.pravega.client.connection.impl.FlowHandler.KeepAliveTask in project pravega by pravega.
the class FlowHandlerTest method keepAliveFailureTest.
@Test
public void keepAliveFailureTest() throws Exception {
ReplyProcessor replyProcessor = mock(ReplyProcessor.class);
@Cleanup ClientConnection connection1 = flowHandler.createFlow(flow, processor);
@Cleanup ClientConnection connection2 = flowHandler.createFlow(new Flow(11, 0), replyProcessor);
KeepAliveTask keepAlive = flowHandler.getKeepAliveTask();
keepAlive.run();
// simulate a KeepAlive connection failure.
keepAlive.handleError(new RuntimeException("Induced error"));
// ensure all the reply processors are informed immediately of the channel being closed due to KeepAlive Failure.
verify(processor).connectionDropped();
verify(replyProcessor).connectionDropped();
}
use of io.pravega.client.connection.impl.FlowHandler.KeepAliveTask in project pravega by pravega.
the class FlowHandlerTest method keepAliveWriteFailureTest.
@Test
public void keepAliveWriteFailureTest() throws Exception {
ReplyProcessor replyProcessor = mock(ReplyProcessor.class);
@Cleanup ClientConnection connection1 = flowHandler.createFlow(flow, processor);
@Cleanup ClientConnection connection2 = flowHandler.createFlow(new Flow(11, 0), replyProcessor);
KeepAliveTask keepAlive = flowHandler.getKeepAliveTask();
Mockito.doThrow(new RuntimeException("Induced error")).when(connection).send(any(KeepAlive.class));
keepAlive.run();
// ensure all the reply processors are informed immediately of the channel being closed due to KeepAlive Failure.
verify(processor).connectionDropped();
verify(replyProcessor).connectionDropped();
}
use of io.pravega.client.connection.impl.FlowHandler.KeepAliveTask in project pravega by pravega.
the class FlowHandlerTest method keepAliveTimeoutTest.
@Test
public void keepAliveTimeoutTest() throws Exception {
ReplyProcessor replyProcessor = mock(ReplyProcessor.class);
@Cleanup ClientConnection connection1 = flowHandler.createFlow(flow, processor);
@Cleanup ClientConnection connection2 = flowHandler.createFlow(new Flow(11, 0), replyProcessor);
KeepAliveTask keepAlive = flowHandler.getKeepAliveTask();
Mockito.doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
// Triggers a timeout.
keepAlive.run();
return null;
}
}).when(connection).send(any(KeepAlive.class));
keepAlive.run();
// ensure all the reply processors are informed immediately of the channel being closed due to KeepAlive Failure.
verify(processor).connectionDropped();
verify(replyProcessor).connectionDropped();
}
Aggregations