Search in sources :

Example 1 with KeepAliveTask

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();
}
Also used : KeepAliveTask(io.pravega.client.connection.impl.FlowHandler.KeepAliveTask) Cleanup(lombok.Cleanup) FailingReplyProcessor(io.pravega.shared.protocol.netty.FailingReplyProcessor) ReplyProcessor(io.pravega.shared.protocol.netty.ReplyProcessor) Test(org.junit.Test)

Example 2 with KeepAliveTask

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();
}
Also used : KeepAlive(io.pravega.shared.protocol.netty.WireCommands.KeepAlive) KeepAliveTask(io.pravega.client.connection.impl.FlowHandler.KeepAliveTask) Cleanup(lombok.Cleanup) FailingReplyProcessor(io.pravega.shared.protocol.netty.FailingReplyProcessor) ReplyProcessor(io.pravega.shared.protocol.netty.ReplyProcessor) Test(org.junit.Test)

Example 3 with KeepAliveTask

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();
}
Also used : InvocationOnMock(org.mockito.invocation.InvocationOnMock) KeepAlive(io.pravega.shared.protocol.netty.WireCommands.KeepAlive) KeepAliveTask(io.pravega.client.connection.impl.FlowHandler.KeepAliveTask) Cleanup(lombok.Cleanup) FailingReplyProcessor(io.pravega.shared.protocol.netty.FailingReplyProcessor) ReplyProcessor(io.pravega.shared.protocol.netty.ReplyProcessor) Test(org.junit.Test)

Aggregations

KeepAliveTask (io.pravega.client.connection.impl.FlowHandler.KeepAliveTask)3 FailingReplyProcessor (io.pravega.shared.protocol.netty.FailingReplyProcessor)3 ReplyProcessor (io.pravega.shared.protocol.netty.ReplyProcessor)3 Cleanup (lombok.Cleanup)3 Test (org.junit.Test)3 KeepAlive (io.pravega.shared.protocol.netty.WireCommands.KeepAlive)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1