From c867e1350a8bdfa05ff19f580278c5e4367c0ef5 Mon Sep 17 00:00:00 2001 From: Aaron Stannard Date: Wed, 26 Feb 2020 09:48:02 -0600 Subject: [PATCH] Disable racy Remoting and Core specs (#4256) * disabled Ask_does_not_deadlock spec * Delete Bug3370DotNettyLinuxBufferPoolSpec.cs Deleted since https://github.com/akkadotnet/akka.net/pull/4252 eliminated need for this * relaxing timeout on FSMTimingSpec --- src/core/Akka.Remote.Tests/RemotingSpec.cs | 8 +- .../Bug3370DotNettyLinuxBufferPoolSpec.cs | 93 ------------------- src/core/Akka.Tests/Actor/FSMTimingSpec.cs | 88 +++++++++--------- 3 files changed, 48 insertions(+), 141 deletions(-) delete mode 100644 src/core/Akka.Remote.Tests/Transport/Bug3370DotNettyLinuxBufferPoolSpec.cs diff --git a/src/core/Akka.Remote.Tests/RemotingSpec.cs b/src/core/Akka.Remote.Tests/RemotingSpec.cs index 374904b7231..a362c31624b 100644 --- a/src/core/Akka.Remote.Tests/RemotingSpec.cs +++ b/src/core/Akka.Remote.Tests/RemotingSpec.cs @@ -168,12 +168,12 @@ public async Task Remoting_must_support_Ask() //TODO: using smaller numbers for the cancellation here causes a bug. //the remoting layer uses some "initialdelay task.delay" for 4 seconds. //so the token is cancelled before the delay completed.. - var msg = await _here.Ask<(string, IActorRef)>("ping", TimeSpan.FromSeconds(1.5)); - Assert.Equal("pong", msg.Item1); - Assert.IsType(msg.Item2); + var (msg, actorRef) = await _here.Ask<(string, IActorRef)>("ping", TimeSpan.FromSeconds(1.5)); + Assert.Equal("pong", msg); + Assert.IsType(actorRef); } - [Fact] + [Fact(Skip = "Racy")] public async Task Ask_does_not_deadlock() { // see https://github.com/akkadotnet/akka.net/issues/2546 diff --git a/src/core/Akka.Remote.Tests/Transport/Bug3370DotNettyLinuxBufferPoolSpec.cs b/src/core/Akka.Remote.Tests/Transport/Bug3370DotNettyLinuxBufferPoolSpec.cs deleted file mode 100644 index 0d12256a75f..00000000000 --- a/src/core/Akka.Remote.Tests/Transport/Bug3370DotNettyLinuxBufferPoolSpec.cs +++ /dev/null @@ -1,93 +0,0 @@ -//----------------------------------------------------------------------- -// -// Copyright (C) 2009-2019 Lightbend Inc. -// Copyright (C) 2013-2019 .NET Foundation -// -//----------------------------------------------------------------------- - -using System.Threading.Tasks; -using Akka.Actor; -using Akka.Actor.Dsl; -using Hocon; using Akka.Configuration; -using Akka.Remote.Transport.DotNetty; -using Akka.TestKit; -using DotNetty.Buffers; -using FluentAssertions; -using Xunit; - -namespace Akka.Remote.Tests.Transport -{ - /// - /// Spec designed to verify that https://github.com/akkadotnet/akka.net/issues/3370 - /// - public class Bug3370DotNettyLinuxBufferPoolSpec : AkkaSpec - { - private static readonly Config Config = ConfigurationFactory.ParseString(@" - akka { - loglevel = DEBUG - actor.provider = ""Akka.Remote.RemoteActorRefProvider,Akka.Remote"" - remote { - dot-netty.tcp { - port = 0 - hostname = ""127.0.0.1"" - log-transport = true - enable-pooling = false - } - } - }"); - - public Bug3370DotNettyLinuxBufferPoolSpec() : base(Config) - { - - } - - [Fact] - public async Task DotNettyTcpTransport_should_start_without_pooling() - { - var config = Sys.Settings.Config.GetConfig("akka.remote.dot-netty.tcp"); - Assert.False(config.IsNullOrEmpty()); - - var t1 = new TcpTransport(Sys, config); - 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(); // verify we are not using pooling - sc.Allocator.Should().BeOfType(); - } - finally - { - await t1.Shutdown(); - } - } - - [Fact] - public void DotNettyTcpTransport_should_communicate_without_pooling() - { - var sys2 = ActorSystem.Create(Sys.Name, Sys.Settings.Config); - - InitializeLogger(sys2); - try - { - var echo = sys2.ActorOf(act => { act.ReceiveAny((o, context) => context.Sender.Tell(o)); }, "echo"); - - var address1 = RARP.For(Sys).Provider.DefaultAddress; - var address2 = RARP.For(sys2).Provider.DefaultAddress; - var echoPath = new RootActorPath(address2) / "user" / "echo"; - var probe = CreateTestProbe(); - Sys.ActorSelection(echoPath).Tell("hello", probe.Ref); - probe.ExpectMsg("hello"); - } - finally - { - Shutdown(sys2); - } - } - } -} diff --git a/src/core/Akka.Tests/Actor/FSMTimingSpec.cs b/src/core/Akka.Tests/Actor/FSMTimingSpec.cs index a1e883a26ce..a36bd3cb698 100644 --- a/src/core/Akka.Tests/Actor/FSMTimingSpec.cs +++ b/src/core/Akka.Tests/Actor/FSMTimingSpec.cs @@ -19,13 +19,13 @@ namespace Akka.Tests.Actor { public class FSMTimingSpec : AkkaSpec { - public IActorRef fsm { get; } + public IActorRef FSM { get; } public FSMTimingSpec() { - fsm = Sys.ActorOf(Props.Create(() => new StateMachine(TestActor)), "fsm"); - fsm.Tell(new SubscribeTransitionCallBack(TestActor)); - ExpectMsg(new CurrentState(fsm, FsmState.Initial), 1.Seconds()); + FSM = Sys.ActorOf(Props.Create(() => new StateMachine(TestActor)), "fsm"); + FSM.Tell(new SubscribeTransitionCallBack(TestActor)); + ExpectMsg(new CurrentState(FSM, FsmState.Initial)); } [Fact] @@ -35,9 +35,9 @@ public void FSM_must_receive_StateTimeout() { Within(500.Milliseconds(), 1.Seconds(), () => { - fsm.Tell(FsmState.TestStateTimeout); - ExpectMsg(new Transition(fsm, FsmState.Initial, FsmState.TestStateTimeout)); - ExpectMsg(new Transition(fsm, FsmState.TestStateTimeout, FsmState.Initial)); + FSM.Tell(FsmState.TestStateTimeout); + ExpectMsg(new Transition(FSM, FsmState.Initial, FsmState.TestStateTimeout)); + ExpectMsg(new Transition(FSM, FsmState.TestStateTimeout, FsmState.Initial)); }); ExpectNoMsg(50.Milliseconds()); }); @@ -48,11 +48,11 @@ public void FSM_must_cancel_a_StateTimeout() { Within(1.Seconds(), () => { - fsm.Tell(FsmState.TestStateTimeout); - fsm.Tell(Cancel.Instance); - ExpectMsg(new Transition(fsm, FsmState.Initial, FsmState.TestStateTimeout)); + FSM.Tell(FsmState.TestStateTimeout); + FSM.Tell(Cancel.Instance); + ExpectMsg(new Transition(FSM, FsmState.Initial, FsmState.TestStateTimeout)); ExpectMsg(); - ExpectMsg(new Transition(fsm, FsmState.TestStateTimeout, FsmState.Initial)); + ExpectMsg(new Transition(FSM, FsmState.TestStateTimeout, FsmState.Initial)); ExpectNoMsg(50.Milliseconds()); }); } @@ -76,16 +76,16 @@ public void FSM_must_allow_StateTimeout_override() //the timeout in state TestStateTimeout is 800ms, then it will change back to Initial Within(400.Milliseconds(), () => { - fsm.Tell(FsmState.TestStateTimeoutOverride); - ExpectMsg(new Transition(fsm, FsmState.Initial, FsmState.TestStateTimeout)); + FSM.Tell(FsmState.TestStateTimeoutOverride); + ExpectMsg(new Transition(FSM, FsmState.Initial, FsmState.TestStateTimeout)); ExpectNoMsg(300.Milliseconds()); }); Within(1.Seconds(), () => { - fsm.Tell(Cancel.Instance); + FSM.Tell(Cancel.Instance); ExpectMsg(); - ExpectMsg(new Transition(fsm, FsmState.TestStateTimeout, FsmState.Initial)); + ExpectMsg(new Transition(FSM, FsmState.TestStateTimeout, FsmState.Initial)); }); } @@ -96,10 +96,10 @@ public void FSM_must_receive_single_shot_timer() { Within(500.Milliseconds(), 1.Seconds(), () => { - fsm.Tell(FsmState.TestSingleTimer); - ExpectMsg(new Transition(fsm, FsmState.Initial, FsmState.TestSingleTimer)); + FSM.Tell(FsmState.TestSingleTimer); + ExpectMsg(new Transition(FSM, FsmState.Initial, FsmState.TestSingleTimer)); ExpectMsg(); - ExpectMsg(new Transition(fsm, FsmState.TestSingleTimer, FsmState.Initial)); + ExpectMsg(new Transition(FSM, FsmState.TestSingleTimer, FsmState.Initial)); }); ExpectNoMsg(500.Milliseconds()); }); @@ -112,15 +112,15 @@ public void FSM_must_resubmit_single_shot_timer() { Within(500.Milliseconds(), 1.Seconds(), () => { - fsm.Tell(FsmState.TestSingleTimerResubmit); - ExpectMsg(new Transition(fsm, FsmState.Initial, FsmState.TestSingleTimerResubmit)); + FSM.Tell(FsmState.TestSingleTimerResubmit); + ExpectMsg(new Transition(FSM, FsmState.Initial, FsmState.TestSingleTimerResubmit)); ExpectMsg(); }); Within(1.Seconds(), () => { ExpectMsg(); - ExpectMsg(new Transition(fsm, FsmState.TestSingleTimerResubmit, FsmState.Initial)); + ExpectMsg(new Transition(FSM, FsmState.TestSingleTimerResubmit, FsmState.Initial)); }); ExpectNoMsg(500.Milliseconds()); }); @@ -129,11 +129,11 @@ public void FSM_must_resubmit_single_shot_timer() [Fact] public void FSM_must_correctly_cancel_a_named_timer() { - fsm.Tell(FsmState.TestCancelTimer); - ExpectMsg(new Transition(fsm, FsmState.Initial, FsmState.TestCancelTimer)); + FSM.Tell(FsmState.TestCancelTimer); + ExpectMsg(new Transition(FSM, FsmState.Initial, FsmState.TestCancelTimer)); Within(500.Milliseconds(), () => { - fsm.Tell(Tick.Instance); + FSM.Tell(Tick.Instance); ExpectMsg(); }); @@ -141,33 +141,33 @@ public void FSM_must_correctly_cancel_a_named_timer() { ExpectMsg(); }); - fsm.Tell(Cancel.Instance); - ExpectMsg(new Transition(fsm, FsmState.TestCancelTimer, FsmState.Initial), 1.Seconds()); + FSM.Tell(Cancel.Instance); + ExpectMsg(new Transition(FSM, FsmState.TestCancelTimer, FsmState.Initial), 1.Seconds()); } [Fact] public void FSM_must_not_get_confused_between_named_and_state_timers() { - fsm.Tell(FsmState.TestCancelStateTimerInNamedTimerMessage); - fsm.Tell(Tick.Instance); - ExpectMsg(new Transition(fsm, FsmState.Initial, FsmState.TestCancelStateTimerInNamedTimerMessage)); + FSM.Tell(FsmState.TestCancelStateTimerInNamedTimerMessage); + FSM.Tell(Tick.Instance); + ExpectMsg(new Transition(FSM, FsmState.Initial, FsmState.TestCancelStateTimerInNamedTimerMessage)); ExpectMsg(500.Milliseconds()); Task.Delay(200.Milliseconds()); - Resume(fsm); - ExpectMsg(new Transition(fsm, FsmState.TestCancelStateTimerInNamedTimerMessage, FsmState.TestCancelStateTimerInNamedTimerMessage2), 500.Milliseconds()); - fsm.Tell(Cancel.Instance); + Resume(FSM); + ExpectMsg(new Transition(FSM, FsmState.TestCancelStateTimerInNamedTimerMessage, FsmState.TestCancelStateTimerInNamedTimerMessage2), 500.Milliseconds()); + FSM.Tell(Cancel.Instance); Within(500.Milliseconds(), () => { ExpectMsg(); - ExpectMsg(new Transition(fsm, FsmState.TestCancelStateTimerInNamedTimerMessage2, FsmState.Initial)); + ExpectMsg(new Transition(FSM, FsmState.TestCancelStateTimerInNamedTimerMessage2, FsmState.Initial)); }); } [Fact] public void FSM_must_receive_and_cancel_a_repeated_timer() { - fsm.Tell(FsmState.TestRepeatedTimer); - ExpectMsg(new Transition(fsm, FsmState.Initial, FsmState.TestRepeatedTimer)); + FSM.Tell(FsmState.TestRepeatedTimer); + ExpectMsg(new Transition(FSM, FsmState.Initial, FsmState.TestRepeatedTimer)); var seq = ReceiveWhile(2.Seconds(), o => { if (o is Tick) @@ -177,7 +177,7 @@ public void FSM_must_receive_and_cancel_a_repeated_timer() seq.Should().HaveCount(5); Within(500.Milliseconds(), () => { - ExpectMsg(new Transition(fsm, FsmState.TestRepeatedTimer, FsmState.Initial)); + ExpectMsg(new Transition(FSM, FsmState.TestRepeatedTimer, FsmState.Initial)); }); } @@ -191,18 +191,18 @@ public void FSM_must_notify_unhandled_messages() // .ExpectOne( // () => // { - fsm.Tell(FsmState.TestUnhandled); - ExpectMsg(new Transition(fsm, FsmState.Initial, FsmState.TestUnhandled)); + FSM.Tell(FsmState.TestUnhandled); + ExpectMsg(new Transition(FSM, FsmState.Initial, FsmState.TestUnhandled)); Within(3.Seconds(), () => { - fsm.Tell(Tick.Instance); - fsm.Tell(SetHandler.Instance); - fsm.Tell(Tick.Instance); + FSM.Tell(Tick.Instance); + FSM.Tell(SetHandler.Instance); + FSM.Tell(Tick.Instance); ExpectMsg().Msg.Should().BeOfType(); - fsm.Tell(new Unhandled("test")); - fsm.Tell(Cancel.Instance); + FSM.Tell(new Unhandled("test")); + FSM.Tell(Cancel.Instance); var transition = ExpectMsg>(); - transition.FsmRef.Should().Be(fsm); + transition.FsmRef.Should().Be(FSM); transition.From.Should().Be(FsmState.TestUnhandled); transition.To.Should().Be(FsmState.Initial); });