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 - RemoteMessageLocalDeliverySpec #5889

Merged
Changes from 2 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
35 changes: 17 additions & 18 deletions src/core/Akka.Remote.Tests/RemoteMessageLocalDeliverySpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Akka.Configuration;
using Akka.Remote.Transport;
using Akka.TestKit;
using Akka.TestKit.Extensions;
using Akka.TestKit.TestActors;
using Xunit;
using Xunit.Abstractions;
Expand Down Expand Up @@ -71,12 +72,12 @@ public void RemoteActorRefProvider_should_correctly_resolve_valid_LocalActorRef_
}

[Fact]
public void RemoteActorRefProvider_should_correctly_resolve_valid_LocalActorRef_from_second_remote_system()
public async Task RemoteActorRefProvider_should_correctly_resolve_valid_LocalActorRef_from_second_remote_system()
{
var sys2 = ActorSystem.Create("Sys2", RemoteConfiguration);
var sys2 = ActorSystem.Create("Sys2", RemoteConfiguration);
try
{
Within(TimeSpan.FromSeconds(15), () =>
await WithinAsync(TimeSpan.FromSeconds(15), async () =>
{
var actorRef = sys2.ActorOf(BlackHoleActor.Props, "myActor");
var sys2Address = RARP.For(sys2).Provider.DefaultAddress;
Expand All @@ -86,33 +87,31 @@ public void RemoteActorRefProvider_should_correctly_resolve_valid_LocalActorRef_
var remoteActorRef = Sys.ActorSelection(actorPath).ResolveOne(TimeSpan.FromSeconds(3)).Result;

// disconnect us from the second actorsystem
var mc =
RARP.For(Sys)
.Provider.Transport.ManagementCommand(new SetThrottle(sys2Address,
ThrottleTransportAdapter.Direction.Both, Blackhole.Instance));
Assert.True(mc.Wait(TimeSpan.FromSeconds(3)));
Assert.True(await RARP.For(Sys)
.Provider.Transport.ManagementCommand(new SetThrottle(sys2Address,
ThrottleTransportAdapter.Direction.Both, Blackhole.Instance))
.WithTimeout(TimeSpan.FromSeconds(3)));

// start deathwatch (won't be delivered initially)
Watch(remoteActorRef);
Task.Delay(TimeSpan.FromSeconds(3)).Wait(); // if we delay the initial send, this spec will fail
await Task.Delay(TimeSpan.FromSeconds(3)); // if we delay the initial send, this spec will fail

var mc2 =
RARP.For(Sys)
.Provider.Transport.ManagementCommand(new SetThrottle(sys2Address,
ThrottleTransportAdapter.Direction.Both, Unthrottled.Instance));
Assert.True(mc2.Wait(TimeSpan.FromSeconds(3)));
Assert.True(await RARP.For(Sys)
.Provider.Transport.ManagementCommand(new SetThrottle(sys2Address,
ThrottleTransportAdapter.Direction.Both, Unthrottled.Instance))
.WithTimeout(TimeSpan.FromSeconds(3)));

// fire off another non-system message
var ai =
Sys.ActorSelection(actorPath).Ask<ActorIdentity>(new Identify(null), TimeSpan.FromSeconds(3)).Result;
var ai =
await Sys.ActorSelection(actorPath).Ask<ActorIdentity>(new Identify(null), TimeSpan.FromSeconds(3));

remoteActorRef.Tell(PoisonPill.Instance); // WATCH should be applied first
ExpectTerminated(remoteActorRef);
await ExpectTerminatedAsync(remoteActorRef);
});
}
finally
{
Assert.True(sys2.Terminate().Wait(TimeSpan.FromSeconds(5)));
await ShutdownAsync(sys2);
}
}
}
Expand Down