diff --git a/src/core/Akka.Remote.Tests/BugFixes/BugFix4384Spec.cs b/src/core/Akka.Remote.Tests/BugFixes/BugFix4384Spec.cs index 092dc05420e..b77f6e8f7be 100644 --- a/src/core/Akka.Remote.Tests/BugFixes/BugFix4384Spec.cs +++ b/src/core/Akka.Remote.Tests/BugFixes/BugFix4384Spec.cs @@ -17,7 +17,7 @@ using Xunit; using Xunit.Abstractions; -namespace Akka.Tests.Actor +namespace Akka.Remote.Tests.BugFixes { public class BugFix4384Spec : TestKit.Xunit2.TestKit { @@ -47,6 +47,14 @@ public BugFix4384Spec(ITestOutputHelper outputHelper) : base(nameof(BugFix4384Sp InitializeLogger(Sys2); } + protected override async Task AfterAllAsync() + { + await Task.WhenAll( + base.AfterAllAsync(), + ShutdownAsync(Sys1), + ShutdownAsync(Sys2)); + } + [Fact] public async Task Ask_from_local_actor_without_remote_association_should_work() { @@ -84,24 +92,27 @@ public async Task ConsistentHashingPoolRoutersShouldWorkAsExpectedWithHashMappin var secondActor = Sys1.ActorOf(act => act.ReceiveAny((o, ctx) => ctx.Sender.Tell(o)), "foo"); Sys2.ActorSelection(new RootActorPath(Sys1Address) / "user" / secondActor.Path.Name).Tell("foo", sys2Probe); - sys2Probe.ExpectMsg("foo"); + await sys2Probe.ExpectMsgAsync("foo"); // have ActorSystem2 message it via tell var sel = Sys2.ActorSelection(new RootActorPath(Sys1Address) / "user" / "router1"); sel.Tell(new HashableString("foo")); - ExpectMsg(str => str.Str.Equals("foo")); + await ExpectMsgAsync(str => str.Str.Equals("foo")); - // have ActorSystem2 message it via Ask - sel.Ask(new Identify("bar2"), TimeSpan.FromSeconds(3)).PipeTo(sys2Probe); - var remoteRouter = sys2Probe.ExpectMsg(x => x.MessageId.Equals("bar2"), TimeSpan.FromSeconds(5)).Subject; + // have ActorSystem2 message it via Ask. Task is intentionally not awaited. + var task = sel.Ask(new Identify("bar2"), TimeSpan.FromSeconds(3)).PipeTo(sys2Probe); + var remoteRouter = (await sys2Probe.ExpectMsgAsync(x => x.MessageId.Equals("bar2"), TimeSpan.FromSeconds(5))).Subject; var s2Actor = Sys2.ActorOf(act => { act.ReceiveAny((o, ctx) => - sel.Ask(new Identify(o), TimeSpan.FromSeconds(3)).PipeTo(sys2Probe)); + { + // Task is intentionally not awaited. + var task = sel.Ask(new Identify(o), TimeSpan.FromSeconds(3)).PipeTo(sys2Probe); + }); }); s2Actor.Tell("hit"); - sys2Probe.ExpectMsg(x => x.MessageId.Equals("hit"), TimeSpan.FromSeconds(5)); + await sys2Probe.ExpectMsgAsync(x => x.MessageId.Equals("hit"), TimeSpan.FromSeconds(5)); } class ReporterActor : ReceiveActor