Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mono compatibility verification #2311

Merged
merged 1 commit into from
Sep 20, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.cmd
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ src\.nuget\NuGet.exe install FAKE -ConfigFile src\.nuget\Nuget.Config -OutputDir

src\.nuget\NuGet.exe install NUnit.Console -ConfigFile src\.nuget\Nuget.Config -OutputDirectory src\packages\FAKE -ExcludeVersion -Version 3.2.1
src\.nuget\NuGet.exe install xunit.runner.console -ConfigFile src\.nuget\Nuget.Config -OutputDirectory src\packages\FAKE -ExcludeVersion -Version 2.0.0
src\.nuget\NuGet.exe install NBench.Runner -OutputDirectory src\packages -ExcludeVersion -Version 0.3.0
src\.nuget\NuGet.exe install NBench.Runner -OutputDirectory src\packages -ExcludeVersion -Version 0.3.1
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mono-friendly implementation of NBench runner.

src\.nuget\NuGet.exe install Microsoft.SourceBrowser -OutputDirectory src\packages -ExcludeVersion

if not exist src\packages\SourceLink.Fake\tools\SourceLink.fsx (
53 changes: 24 additions & 29 deletions build.fsx
Original file line number Diff line number Diff line change
@@ -116,12 +116,6 @@ Target "Build" <| fun _ ->
|> MSBuildRelease "" "Rebuild"
|> ignore

Target "BuildMono" <| fun _ ->

!!"src/Akka.sln"
|> MSBuild "" "Rebuild" [("Configuration","Release Mono")]
|> ignore

//--------------------------------------------------------------------------------
// Build the docs
Target "Docs" <| fun _ ->
@@ -157,7 +151,7 @@ Target "AzureDocsDeploy" (fun _ ->
pushToAzure docDir azureUrl "stable" azureKey 3
pushToAzure docDir azureUrl release.NugetVersion azureKey 3
if(not canPush) then
printfn "Missing required paraments to push docs to Azure. Run build HelpDocs to find out!"
printfn "Missing required parameters to push docs to Azure. Run build HelpDocs to find out!"

)

@@ -241,6 +235,19 @@ Target "BuildRelease" DoNothing
// Tests targets
//--------------------------------------------------------------------------------

//--------------------------------------------------------------------------------
// Filter out assemblies which can't run on Linux, Mono, .NET Core, etc...

open Fake.EnvironmentHelper
let filterPlatformSpecificAssemblies (assembly:string) =
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Platform-specific filter for specs inside FAKE. Allows us to run the same FAKE file for multiple platforms and skip tests that can't run due to environmental issues on a particular platform.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine, but there's more elegant pattern (for the future):

let (|Contains|_|) pattern (assembly: string) = if assembly.Contains pattern then Some () else None
// usage
match assembly with
| Contains "Sqlite" when isMono -> false
| _ -> true

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, I'll leave it as-is for now in case someone wants a test that isn't just .Contains

match assembly with
| assembly when (assembly.Contains("Sqlite") && isMono) -> false
| assembly when (assembly.Contains(".API") && isMono) -> false
| assembly when (assembly.Contains("Akka.Remote.TestKit.Tests") && isMono) -> false
| assembly when (assembly.Contains("Akka.Persistence.TestKit.Tests") && isMono) -> false
| assembly when (assembly.Contains("Akka.Streams.Tests.TCK") && isMono) -> false
| _ -> true

//--------------------------------------------------------------------------------
// Clean test output

@@ -251,13 +258,16 @@ Target "CleanTests" <| fun _ ->

open Fake.Testing
Target "RunTests" <| fun _ ->
let xunitTestAssemblies = !! "src/**/bin/Release/*.Tests.dll" --
let xunitTestAssemblies = Seq.filter filterPlatformSpecificAssemblies (!! "src/**/bin/Release/*.Tests.dll" --
// Akka.Streams.Tests is referencing Akka.Streams.TestKit.Tests
"src/**/Akka.Streams.Tests/bin/Release/Akka.Streams.TestKit.Tests.dll" --
// Akka.Streams.Tests.Performance is referencing Akka.Streams.Tests and Akka.Streams.TestKit.Tests
"src/**/Akka.Streams.Tests.Performance/bin/Release/*.Tests.dll"
"src/**/Akka.Streams.Tests.Performance/bin/Release/*.Tests.dll")

let nunitTestAssemblies = Seq.filter filterPlatformSpecificAssemblies (!! "src/**/bin/Release/Akka.Streams.Tests.TCK.dll")

let nunitTestAssemblies = !! "src/**/bin/Release/Akka.Streams.Tests.TCK.dll"
// Debug output
xunitTestAssemblies |> Seq.iter (printfn "Executing: %s")

mkdir testOutput

@@ -268,35 +278,20 @@ Target "RunTests" <| fun _ ->
let runSingleAssembly assembly =
let assemblyName = Path.GetFileNameWithoutExtension(assembly)
xUnit2
(fun p -> { p with XmlOutputPath = Some (testOutput + @"\" + assemblyName + "_xunit.xml"); HtmlOutputPath = Some (testOutput + @"\" + assemblyName + "_xunit.HTML"); ToolPath = xunitToolPath; TimeOut = System.TimeSpan.FromMinutes 30.0; Parallel = ParallelMode.NoParallelization })
(fun p -> { p with XmlOutputPath = Some (testOutput @@ (assemblyName + "_xunit.xml")); HtmlOutputPath = Some (testOutput @@ (assemblyName + "_xunit.html")); ToolPath = xunitToolPath; TimeOut = System.TimeSpan.FromMinutes 30.0; Parallel = ParallelMode.NoParallelization; NoAppDomain = true; ForceTeamCity = true; })
(Seq.singleton assembly)

xunitTestAssemblies |> Seq.iter (runSingleAssembly)

let runNunitSingleAssembly assembly =
let assemblyName = Path.GetFileNameWithoutExtension(assembly)
NUnit3
(fun p -> { p with ToolPath = nunitToolPath; WorkingDir = testOutput})
(fun p -> { p with ToolPath = nunitToolPath; WorkingDir = testOutput; TeamCity = true;})
(Seq.singleton assembly)

printfn "Using NUnit runner: %s" nunitToolPath
nunitTestAssemblies |> Seq.iter (runNunitSingleAssembly)

Target "RunTestsMono" <| fun _ ->
let xunitTestAssemblies = !! "src/**/bin/Release Mono/*.Tests.dll"

mkdir testOutput

let xunitToolPath = findToolInSubPath "xunit.console.exe" "src/packages/xunit.runner.console*/tools"
printfn "Using XUnit runner: %s" xunitToolPath
let runSingleAssembly assembly =
let assemblyName = Path.GetFileNameWithoutExtension(assembly)
xUnit2
(fun p -> { p with XmlOutputPath = Some (testOutput + @"\" + assemblyName + "_xunit.xml"); HtmlOutputPath = Some (testOutput + @"\" + assemblyName + "_xunit.HTML"); ToolPath = xunitToolPath; TimeOut = System.TimeSpan.FromMinutes 30.0; Parallel = ParallelMode.NoParallelization })
(Seq.singleton assembly)

xunitTestAssemblies |> Seq.iter (runSingleAssembly)


(* Debug helper for troubleshooting an issue we had when we were running multi-node tests multiple times *)
Target "PrintMultiNodeTests" <| fun _ ->
@@ -309,7 +304,7 @@ Target "PrintMultiNodeTests" <| fun _ ->

Target "MultiNodeTests" <| fun _ ->
mkdir testOutput
let multiNodeTestPath = findToolInSubPath "Akka.MultiNodeTestRunner.exe" "bin/core/Akka.MultiNodeTestRunner*"
let multiNodeTestPath = findToolInSubPath "Akka.MultiNodeTestRunner.exe" (currentDirectory @@ "bin" @@ "core" @@ "Akka.MultiNodeTestRunner*")
let multiNodeTestAssemblies = !! "src/**/bin/Release/Akka.Remote.Tests.MultiNode.dll" ++
"src/**/bin/Release/Akka.Cluster.Tests.MultiNode.dll" ++
"src/**/bin/Release/Akka.Cluster.Tools.Tests.MultiNode.dll"
@@ -344,7 +339,7 @@ Target "NBench" <| fun _ ->

mkdir perfOutput
let nbenchTestPath = findToolInSubPath "NBench.Runner.exe" "src/packges/NBench.Runner*"
let nbenchTestAssemblies = !! testSearchPath
let nbenchTestAssemblies = Seq.filter filterPlatformSpecificAssemblies (!! testSearchPath)
printfn "Using NBench.Runner: %s" nbenchTestPath

let runNBench assembly =
7 changes: 3 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
@@ -29,11 +29,10 @@ mono $SCRIPT_PATH/src/.nuget/NuGet.exe update -self

mono $SCRIPT_PATH/src/.nuget/NuGet.exe install FAKE -OutputDirectory $SCRIPT_PATH/src/packages -ExcludeVersion -Version 4.16.1

mono $SCRIPT_PATH/src/.nuget/NuGet.exe install xunit.runners -OutputDirectory $SCRIPT_PATH/src/packages/FAKE -ExcludeVersion -Version 2.0.0
mono $SCRIPT_PATH/src/.nuget/NuGet.exe install nunit.runners -OutputDirectory $SCRIPT_PATH/src/packages/FAKE -ExcludeVersion -Version 2.6.4
mono $SCRIPT_PATH/src/.nuget/NuGet.exe install NUnit.Console -OutputDirectory $SCRIPT_PATH/src/packages/FAKE -ExcludeVersion -Version 3.0.0
mono $SCRIPT_PATH/src/.nuget/NuGet.exe install xunit.runner.console -OutputDirectory $SCRIPT_PATH/src/packages/FAKE -ExcludeVersion -Version 2.0.0
mono $SCRIPT_PATH/src/.nuget/NuGet.exe install NUnit.Console -OutputDirectory $SCRIPT_PATH/src/packages/FAKE -ExcludeVersion -Version 3.2.1

mono $SCRIPT_PATH/src/.nuget/NuGet.exe install NBench.Runner -OutputDirectory $SCRIPT_PATH/src/packages -ExcludeVersion -Version 0.3.0
mono $SCRIPT_PATH/src/.nuget/NuGet.exe install NBench.Runner -OutputDirectory $SCRIPT_PATH/src/packages -ExcludeVersion -Version 0.3.1


if ! [ -e $SCRIPT_PATH/src/packages/SourceLink.Fake/tools/SourceLink.fsx ] ; then
4 changes: 2 additions & 2 deletions src/Akka.sln
Original file line number Diff line number Diff line change
@@ -152,7 +152,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.TestKit.Xunit", "contr
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DependencyInjection", "DependencyInjection", "{B1D10183-8FAE-4506-B935-403FCED89BDB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.DI.Core", "contrib\dependencyInjection\Akka.DI.Core\Akka.DI.Core.csproj", "{FDF09D18-B68E-4B95-B1F6-B89D9C6C3AE9}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.DI.Core", "contrib\dependencyinjection\Akka.DI.Core\Akka.DI.Core.csproj", "{FDF09D18-B68E-4B95-B1F6-B89D9C6C3AE9}"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to fix capitalization of name or Linux builds fail.

EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Persistence", "Persistence", "{264C22A4-CAFC-41F6-B82C-4DDC5C196767}"
EndProject
@@ -164,7 +164,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TcpEchoService", "TcpEchoSe
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TcpEchoService.Server", "examples\TcpEchoService.Server\TcpEchoService.Server.csproj", "{825196A4-4B08-401F-8994-E2DB7C77A8B7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.DI.TestKit", "contrib\dependencyInjection\Akka.DI.TestKit\Akka.DI.TestKit.csproj", "{D8DB14A5-6147-4512-BF5C-683FDCA6190C}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.DI.TestKit", "contrib\dependencyinjection\Akka.DI.TestKit\Akka.DI.TestKit.csproj", "{D8DB14A5-6147-4512-BF5C-683FDCA6190C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestKit", "TestKit", "{46116E52-BF96-4B76-8C81-2104C74487DF}"
EndProject
4 changes: 4 additions & 0 deletions src/core/Akka.API.Tests/CoreAPISpec.ApproveCore.approved.txt
Original file line number Diff line number Diff line change
@@ -4929,6 +4929,10 @@ namespace Akka.Util
public override bool IsRight { get; }
public TB Value { get; }
}
public class static RuntimeDetector
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New class used to detect runtimes. Decided to unify all of our Mono detector implementations into a single static utility class.

{
public static readonly bool IsMono;
}
public class static StandardOutWriter
{
public static void Write(string message, System.Nullable<System.ConsoleColor> foregroundColor = null, System.Nullable<System.ConsoleColor> backgroundColor = null) { }
2 changes: 1 addition & 1 deletion src/core/Akka.Remote.TestKit/Conductor.cs
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ namespace Akka.Remote.TestKit
/// The conductor is the one orchestrating the test: it governs the
/// <see cref="Akka.Remote.TestKit.Controller"/>'s ports to which all
/// Players connect, it issues commands to their
/// <see cref="Akka.Remote.TestKit.NetworkFailureInjector"/> and provides support
/// <see cref="FailureInjectorTransportAdapter"/> and provides support
/// for barriers using the <see cref="Akka.Remote.TestKit.BarrierCoordinator"/>.
/// All of this is bundled inside the <see cref="TestConductor"/>
/// </summary>
10 changes: 9 additions & 1 deletion src/core/Akka.Remote.TestKit/Controller.cs
Original file line number Diff line number Diff line change
@@ -392,7 +392,15 @@ protected override void OnReceive(object message)

protected override void PostStop()
{
RemoteConnection.Shutdown(_connection);
try
{
RemoteConnection.Shutdown(_connection);
RemoteConnection.ReleaseAll().Wait(_settings.ConnectTimeout);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Safe disposal of MNTR resources.

}
catch (Exception ex)
{
_log.Error(ex, "Error while terminating RemoteConnection.");
}
}
}
}
1 change: 1 addition & 0 deletions src/core/Akka.Remote.TestKit/Player.cs
Original file line number Diff line number Diff line change
@@ -624,6 +624,7 @@ public override void ChannelInactive(IChannelHandlerContext context)
Task.Factory.StartNew(() =>
{
RemoteConnection.Shutdown(context.Channel);
RemoteConnection.ReleaseAll(); // yep, let it run asynchronously.
}, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default);
context.FireChannelInactive();
}
5 changes: 3 additions & 2 deletions src/core/Akka.Remote.TestKit/RemoteConnection.cs
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Threading.Tasks;
using Akka.Remote.TestKit.Proto;
using Akka.Remote.Transport.Helios;
@@ -93,7 +94,7 @@ public static Task<IChannel> CreateConnection(Role role, IPEndPoint socketAddres
if (role == Role.Client)
{
var connection = new ClientBootstrap()
.Channel<TcpSocketChannel>()
.ChannelFactory(() => new TcpSocketChannel(socketAddress.AddressFamily))
.Option(ChannelOption.TcpNodelay, true)
.Group(GetClientWorkerPool(poolSize))
.Handler(new ActionChannelInitializer<TcpSocketChannel>(channel =>
@@ -107,7 +108,7 @@ public static Task<IChannel> CreateConnection(Role role, IPEndPoint socketAddres
{
var connection = new ServerBootstrap()
.Group(GetServerPool(poolSize), GetServerWorkerPool(poolSize))
.Channel<TcpServerSocketChannel>()
.ChannelFactory(() => new TcpServerSocketChannel(socketAddress.AddressFamily))
.ChildOption(ChannelOption.TcpNodelay, true)
.ChildHandler(new ActionChannelInitializer<TcpSocketChannel>(channel =>
{
8 changes: 4 additions & 4 deletions src/core/Akka.Remote.Tests/RemoteConfigSpec.cs
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
using Akka.Util.Internal;
using Xunit;
using System.Net;
using static Akka.Util.RuntimeDetector;

namespace Akka.Remote.Tests
{
@@ -70,8 +71,7 @@ public void Remoting_should_contain_correct_configuration_values_in_ReferenceCon
public void Remoting_should_be_able_to_parse_AkkaProtocol_related_config_elements()
{
var settings = new AkkaProtocolSettings(((RemoteActorRefProvider)((ExtendedActorSystem)Sys).Provider).RemoteSettings.Config);

//TODO fill this in when we add secure cookie support

Assert.Equal(typeof(DeadlineFailureDetector), Type.GetType(settings.TransportFailureDetectorImplementationClass));
Assert.Equal(TimeSpan.FromSeconds(4), settings.TransportHeartBeatInterval);
Assert.Equal(TimeSpan.FromSeconds(20), settings.TransportFailureDetectorConfig.GetTimeSpan("acceptable-heartbeat-pause"));
@@ -103,7 +103,7 @@ public void Remoting_should_contain_correct_heliosTCP_values_in_ReferenceConf()
[Fact]
public void When_remoting_works_in_Mono_ip_enforcement_should_be_defaulted_to_true()
{
HeliosTransportSettings.IsMono = true;
if (!IsMono) return; // skip IF NOT using Mono
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mono 4.4.2 can't handle dual-mode sockets correctly, so we have to force the socket to use IPV4 OR IPV6, not "either." We check inside our RemoteSettings class to determine that this is explicitly set.

var c = ((RemoteActorRefProvider)((ActorSystemImpl)Sys).Provider).RemoteSettings.Config.GetConfig("akka.remote.helios.tcp");
var s = new HeliosTransportSettings(c);

@@ -113,7 +113,7 @@ public void When_remoting_works_in_Mono_ip_enforcement_should_be_defaulted_to_tr
[Fact]
public void When_remoting_works_not_in_Mono_ip_enforcement_should_be_defaulted_to_false()
{
HeliosTransportSettings.IsMono = false;
if (IsMono) return; // skip IF using Mono
var c = ((RemoteActorRefProvider)((ActorSystemImpl)Sys).Provider).RemoteSettings.Config.GetConfig("akka.remote.helios.tcp");
var s = new HeliosTransportSettings(c);

Loading