From 6db0d9b07f41fd53897f6702d96601b65c3f311b Mon Sep 17 00:00:00 2001 From: Aaron Stannard Date: Tue, 21 May 2019 09:02:27 -0500 Subject: [PATCH] added debug logging --- .../RemoteConnectionSpecs.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/core/Akka.Remote.TestKit.Tests/RemoteConnectionSpecs.cs b/src/core/Akka.Remote.TestKit.Tests/RemoteConnectionSpecs.cs index b985db0a4e0..2b7bba02b2b 100644 --- a/src/core/Akka.Remote.TestKit.Tests/RemoteConnectionSpecs.cs +++ b/src/core/Akka.Remote.TestKit.Tests/RemoteConnectionSpecs.cs @@ -14,10 +14,12 @@ using FluentAssertions; using System.Threading.Tasks; using Akka.Actor; +using Akka.Event; using Akka.TestKit; using Akka.Util.Internal; using DotNetty.Transport.Channels; using Xunit; +using Xunit.Abstractions; namespace Akka.Remote.TestKit.Tests { @@ -31,7 +33,7 @@ public class RemoteConnectionSpecs : AkkaSpec akka.actor.debug.lifecycle = on "; - public RemoteConnectionSpecs() : base(Config) + public RemoteConnectionSpecs(ITestOutputHelper output) : base(Config, output) { } @@ -105,7 +107,7 @@ public async Task RemoteConnection_should_send_and_decode_Done_message() var cts = new CancellationTokenSource(); cts.CancelAfter(TimeSpan.FromSeconds(10)); var t1 = RemoteConnection.CreateConnection(Role.Server, serverEndpoint, 3, - new TestConductorHandler(serverProbe.Ref)); + new TestConductorHandler(serverProbe.Ref, Log)); await t1.WithCancellation(cts.Token); server = t1.Result; // task will already be complete or cancelled @@ -143,11 +145,13 @@ public async Task RemoteConnection_should_send_and_decode_Done_message() public class TestConductorHandler : ChannelHandlerAdapter { + private readonly ILoggingAdapter _log; private readonly IActorRef _testActorRef; - public TestConductorHandler(IActorRef testActorRef) + public TestConductorHandler(IActorRef testActorRef, ILoggingAdapter log) { _testActorRef = testActorRef; + _log = log; } public override bool IsSharable => true; @@ -175,5 +179,11 @@ public override void ChannelRead(IChannelHandlerContext context, object message) context.Channel.CloseAsync(); } } + + public override void ExceptionCaught(IChannelHandlerContext context, Exception exception) + { + _log.Error(exception, "Error caught by {0}", context.Channel.LocalAddress); + base.ExceptionCaught(context, exception); + } } }