public async Task DotNettyTcpTransport_should_cleanly_terminate_active_endpoints_upon_outbound_shutdown() { var config = Sys.Settings.Config.GetConfig("akka.remote.dot-netty.tcp"); Assert.False(config.IsNullOrEmpty()); var t1 = new TcpTransport(Sys, config); var t2 = new TcpTransport(Sys, config); try { var p1 = CreateTestProbe(); var p2 = CreateTestProbe(); // bind var c1 = await t1.Listen(); c1.Item2.SetResult(new ActorAssociationEventListener(p1)); var c2 = await t2.Listen(); c2.Item2.SetResult(new ActorAssociationEventListener(p2)); // t1 --> t2 association var handle = await t1.Associate(c2.Item1); handle.ReadHandlerSource.SetResult(new ActorHandleEventListener(p1)); var inboundHandle = p2.ExpectMsg <InboundAssociation>().Association; // wait for the inbound association handle to show up inboundHandle.ReadHandlerSource.SetResult(new ActorHandleEventListener(p2)); AwaitCondition(() => t1.ConnectionGroup.Count == 2); AwaitCondition(() => t2.ConnectionGroup.Count == 2); var chan1 = t1.ConnectionGroup.Single(x => !x.Id.Equals(t1.ServerChannel.Id)); var chan2 = t2.ConnectionGroup.Single(x => !x.Id.Equals(t2.ServerChannel.Id)); // shutdown remoting on t1 await t1.Shutdown(); p2.ExpectMsg <Disassociated>(); // verify that the connections are terminated AwaitCondition(() => t1.ConnectionGroup.Count == 0, null, message: $"Expected 0 open connection but found {t1.ConnectionGroup.Count}"); AwaitCondition(() => t2.ConnectionGroup.Count == 1, null, message: $"Expected 1 open connection but found {t2.ConnectionGroup.Count}"); // verify that the connection channels were terminated on both ends chan1.CloseCompletion.IsCompleted.Should().BeTrue(); chan2.CloseCompletion.IsCompleted.Should().BeTrue(); } finally { await t1.Shutdown(); await t2.Shutdown(); } }
public async Task DotNettyTcpTransport_should_start_without_pooling() { var t1 = new TcpTransport(Sys, Sys.Settings.Config.GetConfig("akka.remote.dot-netty.tcp")); try { // bind await t1.Listen(); // verify that ServerChannel is active and open var sc = t1.ServerChannel; sc.Should().NotBeNull(); sc.Active.Should().BeTrue(); sc.Open.Should().BeTrue(); sc.Allocator.Should().NotBeOfType <PooledByteBufferAllocator>(); // verify we are not using pooling sc.Allocator.Should().BeOfType <UnpooledByteBufferAllocator>(); } finally { await t1.Shutdown(); } }