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

[Async TestKit] Convert Akka.Remote.Tests to async - BugFixes.BugFix4384Spec #5905

Merged
Changes from 1 commit
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
27 changes: 19 additions & 8 deletions src/core/Akka.Remote.Tests/BugFixes/BugFix4384Spec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
using Xunit;
using Xunit.Abstractions;

namespace Akka.Tests.Actor
namespace Akka.Remote.Tests.BugFixes
{
public class BugFix4384Spec : TestKit.Xunit2.TestKit
{
Expand Down Expand Up @@ -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()
{
Expand Down Expand Up @@ -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<HashableString>(str => str.Str.Equals("foo"));
await ExpectMsgAsync<HashableString>(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<ActorIdentity>(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<ActorIdentity>(x => x.MessageId.Equals("bar2"), TimeSpan.FromSeconds(5))).Subject;

var s2Actor = Sys2.ActorOf(act =>
{
act.ReceiveAny((o, ctx) =>
sel.Ask<ActorIdentity>(new Identify(o), TimeSpan.FromSeconds(3)).PipeTo(sys2Probe));
{
// Task is intentionally not awaited.
var task = sel.Ask<ActorIdentity>(new Identify(o), TimeSpan.FromSeconds(3)).PipeTo(sys2Probe);
});
});
s2Actor.Tell("hit");
sys2Probe.ExpectMsg<ActorIdentity>(x => x.MessageId.Equals("hit"), TimeSpan.FromSeconds(5));
await sys2Probe.ExpectMsgAsync<ActorIdentity>(x => x.MessageId.Equals("hit"), TimeSpan.FromSeconds(5));
}

class ReporterActor : ReceiveActor
Expand Down