Skip to content

Commit

Permalink
close #2570 - ported to Akka.Remote.TestKit to DotNetty (#2574)
Browse files Browse the repository at this point in the history
* close #2570 - ported to Akka.Remote.TestKit to DotNetty

* fixed issues with DotNetty handlers

* added console out logging again

* updated approval files and pruned akka.remote.teskit packages.config
  • Loading branch information
Aaronontheweb authored Mar 31, 2017
1 parent 778e8e6 commit c6f3283
Show file tree
Hide file tree
Showing 19 changed files with 368 additions and 92 deletions.
6 changes: 3 additions & 3 deletions src/core/Akka.API.Tests/CoreAPISpec.ApproveCore.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3278,7 +3278,7 @@ namespace Akka.IO
}
public class Aborted : Akka.IO.Tcp.ConnectionClosed
{
public static Akka.IO.Tcp.Aborted Instance;
public static readonly Akka.IO.Tcp.Aborted Instance;
public override bool IsAborted { get; }
}
public class Bind : Akka.IO.Tcp.Command
Expand Down Expand Up @@ -3333,7 +3333,7 @@ namespace Akka.IO
}
public class ConfirmedClosed : Akka.IO.Tcp.ConnectionClosed
{
public static Akka.IO.Tcp.ConfirmedClosed Instance;
public static readonly Akka.IO.Tcp.ConfirmedClosed Instance;
public override bool IsConfirmed { get; }
}
public class Connect : Akka.IO.Tcp.Command
Expand Down Expand Up @@ -3382,7 +3382,7 @@ namespace Akka.IO
}
public class PeerClosed : Akka.IO.Tcp.ConnectionClosed
{
public static Akka.IO.Tcp.PeerClosed Instance;
public static readonly Akka.IO.Tcp.PeerClosed Instance;
public override bool IsPeerClosed { get; }
}
public sealed class Received : Akka.IO.Tcp.Event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("Akka.Cluster.Tests")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("Akka.Cluster.Tests.MultiNode")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("Akka.Remote.TestKit")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("Akka.Remote.TestKit.Tests")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("Akka.Remote.Tests")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("Akka.Remote.Tests.MultiNode")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute("Akka.Remote.Tests.Performance")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,58 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Helios, Version=2.1.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Helios.2.1.2\lib\net45\Helios.dll</HintPath>
<Reference Include="DotNetty.Buffers, Version=0.0.0.0, Culture=neutral, PublicKeyToken=bc13ca065fa06c29, processorArchitecture=MSIL">
<HintPath>..\..\packages\DotNetty.Buffers.0.4.3\lib\net45\DotNetty.Buffers.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="DotNetty.Codecs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=bc13ca065fa06c29, processorArchitecture=MSIL">
<HintPath>..\..\packages\DotNetty.Codecs.0.4.3\lib\net45\DotNetty.Codecs.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="DotNetty.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=bc13ca065fa06c29, processorArchitecture=MSIL">
<HintPath>..\..\packages\DotNetty.Common.0.4.3\lib\net45\DotNetty.Common.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="DotNetty.Transport, Version=0.0.0.0, Culture=neutral, PublicKeyToken=bc13ca065fa06c29, processorArchitecture=MSIL">
<HintPath>..\..\packages\DotNetty.Transport.0.4.3\lib\net45\DotNetty.Transport.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="FluentAssertions, Version=4.19.2.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
<HintPath>..\..\packages\FluentAssertions.4.19.2\lib\net45\FluentAssertions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="FluentAssertions.Core, Version=4.19.2.0, Culture=neutral, PublicKeyToken=33f2691a05b67b6a, processorArchitecture=MSIL">
<HintPath>..\..\packages\FluentAssertions.4.19.2\lib\net45\FluentAssertions.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=1.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.1.1.0\lib\netstandard1.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Extensions.Logging, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.Logging.1.1.1\lib\netstandard1.1\Microsoft.Extensions.Logging.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.Logging.Abstractions.1.1.1\lib\netstandard1.1\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Collections.Immutable, Version=1.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Collections.Immutable.1.3.1\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Numerics" />
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath>
<Private>True</Private>
Expand All @@ -62,6 +104,7 @@
<Compile Include="BarrierSpec.cs" />
<Compile Include="ControllerSpec.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RemoteConnectionSpecs.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\contrib\testkits\Akka.TestKit.Xunit2\Akka.TestKit.Xunit2.csproj">
Expand Down
113 changes: 113 additions & 0 deletions src/core/Akka.Remote.TestKit.Tests/RemoteConnectionSpecs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using FluentAssertions;
using System.Threading.Tasks;
using Akka.Actor;
using Akka.TestKit;
using DotNetty.Transport.Channels;
using Xunit;

namespace Akka.Remote.TestKit.Tests
{
public class RemoteConnectionSpecs : AkkaSpec
{
private const string Config = @"
akka.testconductor.barrier-timeout = 5s
akka.actor.provider = ""Akka.Remote.RemoteActorRefProvider, Akka.Remote""
akka.actor.debug.fsm = on
akka.actor.debug.lifecycle = on
";

public RemoteConnectionSpecs() : base(Config)
{

}

[Fact]
public async Task RemoteConnection_should_send_and_decode_messages()
{
var serverProbe = CreateTestProbe("server");
var clientProbe = CreateTestProbe("client");

var serverAddress = IPAddress.Parse("127.0.0.1");
var serverEndpoint = new IPEndPoint(serverAddress, 0);

IChannel server = null;
IChannel client = null;

try
{
server = await RemoteConnection.CreateConnection(Role.Server, serverEndpoint, 3,
new TestConductorHandler(serverProbe.Ref));

var reachableEndpoint = (IPEndPoint) server.LocalAddress;

client = await RemoteConnection.CreateConnection(Role.Client, reachableEndpoint, 3,
new PlayerHandler(serverEndpoint, 2, TimeSpan.FromSeconds(1), 3, clientProbe.Ref, Log, Sys.Scheduler));

serverProbe.ExpectMsg("active");
var serverClientChannel = serverProbe.ExpectMsg<IChannel>();
clientProbe.ExpectMsg<ClientFSM.Connected>();

var address = RARP.For(Sys).Provider.DefaultAddress;

// have the client send a message to the server
await client.WriteAndFlushAsync(new Hello("test", address));
var hello = serverProbe.ExpectMsg<Hello>();
hello.Name.Should().Be("test");
hello.Address.Should().Be(address);

// have the server send a message back to the client
await serverClientChannel.WriteAndFlushAsync(new Hello("test2", address));
var hello2 = clientProbe.ExpectMsg<Hello>();
hello2.Name.Should().Be("test2");
hello2.Address.Should().Be(address);
}
finally
{
server?.CloseAsync().Wait(TimeSpan.FromSeconds(2));
client?.CloseAsync().Wait(TimeSpan.FromSeconds(2));
}

}
}

public class TestConductorHandler : ChannelHandlerAdapter
{
private readonly IActorRef _testActorRef;

public TestConductorHandler(IActorRef testActorRef)
{
_testActorRef = testActorRef;
}

public override bool IsSharable => true;

public override void ChannelActive(IChannelHandlerContext context)
{
_testActorRef.Tell("active");
_testActorRef.Tell(context.Channel);
}

public override void ChannelInactive(IChannelHandlerContext context)
{
_testActorRef.Tell("inactive");
}

public override void ChannelRead(IChannelHandlerContext context, object message)
{
if (message is INetworkOp)
{
_testActorRef.Tell(message);
}
else
{
//_log.Debug("client {0} sent garbage `{1}`, disconnecting", channel.RemoteAddress, message);
context.Channel.CloseAsync();
}
}
}
}
41 changes: 40 additions & 1 deletion src/core/Akka.Remote.TestKit.Tests/packages.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Helios" version="2.1.2" targetFramework="net45" />
<package id="DotNetty.Buffers" version="0.4.3" targetFramework="net45" />
<package id="DotNetty.Codecs" version="0.4.3" targetFramework="net45" />
<package id="DotNetty.Common" version="0.4.3" targetFramework="net45" />
<package id="DotNetty.Transport" version="0.4.3" targetFramework="net45" />
<package id="FluentAssertions" version="4.19.2" targetFramework="net45" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="1.1.0" targetFramework="net45" />
<package id="Microsoft.Extensions.Logging" version="1.1.1" targetFramework="net45" />
<package id="Microsoft.Extensions.Logging.Abstractions" version="1.1.1" targetFramework="net45" />
<package id="Microsoft.NETCore.Platforms" version="1.1.0" targetFramework="net45" />
<package id="NETStandard.Library" version="1.6.1" targetFramework="net45" />
<package id="System.Collections" version="4.3.0" targetFramework="net45" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net45" />
<package id="System.Collections.Immutable" version="1.3.1" targetFramework="net45" />
<package id="System.ComponentModel" version="4.3.0" targetFramework="net45" />
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net45" />
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net45" />
<package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="net45" />
<package id="System.Globalization" version="4.3.0" targetFramework="net45" />
<package id="System.IO" version="4.3.0" targetFramework="net45" />
<package id="System.IO.Compression" version="4.3.0" targetFramework="net45" />
<package id="System.Linq" version="4.3.0" targetFramework="net45" />
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="net45" />
<package id="System.Net.Http" version="4.3.0" targetFramework="net45" />
<package id="System.Net.Primitives" version="4.3.0" targetFramework="net45" />
<package id="System.ObjectModel" version="4.3.0" targetFramework="net45" />
<package id="System.Reflection" version="4.3.0" targetFramework="net45" />
<package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net45" />
<package id="System.Reflection.Primitives" version="4.3.0" targetFramework="net45" />
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net45" />
<package id="System.Runtime" version="4.3.0" targetFramework="net45" />
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net45" />
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net45" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net45" />
<package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net45" />
<package id="System.Text.Encoding" version="4.3.0" targetFramework="net45" />
<package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net45" />
<package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="net45" />
<package id="System.Threading" version="4.3.0" targetFramework="net45" />
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="net45" />
<package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="net45" />
<package id="System.Xml.XDocument" version="4.3.0" targetFramework="net45" />
<package id="xunit" version="2.1.0" targetFramework="net45" />
<package id="xunit.abstractions" version="2.0.0" targetFramework="net45" />
<package id="xunit.assert" version="2.1.0" targetFramework="net45" />
Expand Down
33 changes: 30 additions & 3 deletions src/core/Akka.Remote.TestKit/Akka.Remote.TestKit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@
<DocumentationFile>bin\Release\Akka.Remote.TestKit.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="DotNetty.Buffers, Version=0.0.0.0, Culture=neutral, PublicKeyToken=bc13ca065fa06c29, processorArchitecture=MSIL">
<HintPath>..\..\packages\DotNetty.Buffers.0.4.3\lib\net45\DotNetty.Buffers.dll</HintPath>
</Reference>
<Reference Include="DotNetty.Codecs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=bc13ca065fa06c29, processorArchitecture=MSIL">
<HintPath>..\..\packages\DotNetty.Codecs.0.4.3\lib\net45\DotNetty.Codecs.dll</HintPath>
</Reference>
<Reference Include="DotNetty.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=bc13ca065fa06c29, processorArchitecture=MSIL">
<HintPath>..\..\packages\DotNetty.Common.0.4.3\lib\net45\DotNetty.Common.dll</HintPath>
</Reference>
<Reference Include="DotNetty.Transport, Version=0.0.0.0, Culture=neutral, PublicKeyToken=bc13ca065fa06c29, processorArchitecture=MSIL">
<HintPath>..\..\packages\DotNetty.Transport.0.4.3\lib\net45\DotNetty.Transport.dll</HintPath>
</Reference>
<Reference Include="Google.ProtocolBuffers, Version=2.4.1.555, Culture=neutral, PublicKeyToken=55f7125234beb589, processorArchitecture=MSIL">
<HintPath>..\..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.dll</HintPath>
<Private>True</Private>
Expand All @@ -40,9 +52,14 @@
<HintPath>..\..\packages\Google.ProtocolBuffers.2.4.1.555\lib\net40\Google.ProtocolBuffers.Serialization.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Helios, Version=2.1.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Helios.2.1.2\lib\net45\Helios.dll</HintPath>
<Private>True</Private>
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=1.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.1.1.0\lib\netstandard1.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Logging, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.Logging.1.1.1\lib\netstandard1.1\Microsoft.Extensions.Logging.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.Extensions.Logging.Abstractions.1.1.1\lib\netstandard1.1\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
Expand All @@ -53,8 +70,17 @@
<HintPath>..\..\packages\System.Collections.Immutable.1.3.1\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Numerics" />
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath>
Expand All @@ -73,6 +99,7 @@
<Compile Include="BarrierCoordinator.cs" />
<Compile Include="CommandLine.cs" />
<Compile Include="Conductor.cs" />
<Compile Include="ConsoleLogger.cs" />
<Compile Include="Controller.cs" />
<Compile Include="DataTypes.cs" />
<Compile Include="Extension.cs" />
Expand Down
Loading

0 comments on commit c6f3283

Please sign in to comment.