Skip to content

Commit

Permalink
added debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronontheweb committed May 21, 2019
1 parent 42777e2 commit 6db0d9b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/core/Akka.Remote.TestKit.Tests/RemoteConnectionSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -31,7 +33,7 @@ public class RemoteConnectionSpecs : AkkaSpec
akka.actor.debug.lifecycle = on
";

public RemoteConnectionSpecs() : base(Config)
public RemoteConnectionSpecs(ITestOutputHelper output) : base(Config, output)
{

}
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
}

0 comments on commit 6db0d9b

Please sign in to comment.