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

Port Akka.Tests.Routing tests to async/await - RoundRobinSpec #5811

Merged
merged 2 commits into from
Apr 4, 2022
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
18 changes: 9 additions & 9 deletions src/core/Akka.Tests/Routing/RoundRobinSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ public RoundRobinLogicPropsActor()
}
}

private int RouteeSize(IActorRef router)
private async Task<int> RouteeSize(IActorRef router)
{
return router.Ask<Routees>(new GetRoutees()).Result.Members.Count();
return (await router.Ask<Routees>(new GetRoutees())).Members.Count();
}

[Fact]
Expand Down Expand Up @@ -221,22 +221,22 @@ public void Round_robin_pool_must_deliver_deliver_a_broadcast_message_using_Tell
}

[Fact]
public void Round_robin_pool_must_be_controlled_with_management_messages()
public async Task Round_robin_pool_must_be_controlled_with_management_messages()
{
IActorRef actor = Sys.ActorOf(new RoundRobinPool(3)
.Props(Props.Create<EmptyBehaviorActor>()), "round-robin-managed");

RouteeSize(actor).Should().Be(3);
(await RouteeSize(actor)).Should().Be(3);
actor.Tell(new AdjustPoolSize(4));
RouteeSize(actor).Should().Be(7);
(await RouteeSize(actor)).Should().Be(7);
actor.Tell(new AdjustPoolSize(-2));
RouteeSize(actor).Should().Be(5);
(await RouteeSize(actor)).Should().Be(5);

var other = new ActorSelectionRoutee(Sys.ActorSelection("/user/other"));
actor.Tell(new AddRoutee(other));
RouteeSize(actor).Should().Be(6);
(await RouteeSize(actor)).Should().Be(6);
actor.Tell(new RemoveRoutee(other));
RouteeSize(actor).Should().Be(5);
(await RouteeSize(actor)).Should().Be(5);
}

[Fact]
Expand Down Expand Up @@ -303,7 +303,7 @@ public async Task Round_robin_logic_used_in_actor_must_deliver_messages_in_a_rou

Watch(actor);
actor.Tell(new Broadcast("end"));
ExpectTerminated(actor);
await ExpectTerminatedAsync(actor);

replies.Values.ForEach(c => c.Should().Be(iterationCount));
}
Expand Down