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

Convert all unit test to proper async #6945

Draft
wants to merge 10 commits into
base: dev
Choose a base branch
from
3 changes: 3 additions & 0 deletions src/Akka.sln
Expand Up @@ -277,6 +277,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.Persistence.Query.InMe
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Akka.Persistence.Query.InMemory.Tests", "contrib\persistence\Akka.Persistence.Query.InMemory.Tests\Akka.Persistence.Query.InMemory.Tests.csproj", "{407DD6E2-F274-4773-BA5E-43541D5C8D0F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Junk", "Junk", "{CB7C415C-FD58-4527-AB88-FD084445A6A3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1418,6 +1420,7 @@ Global
{4022147A-4F95-4A04-BE09-01B7952BBDD9} = {A640E39E-F45C-4AE9-AABF-7F1432D357DA}
{A310BC3F-065A-4D0D-BC6A-9E444E96F10F} = {264C22A4-CAFC-41F6-B82C-4DDC5C196767}
{407DD6E2-F274-4773-BA5E-43541D5C8D0F} = {264C22A4-CAFC-41F6-B82C-4DDC5C196767}
{CB7C415C-FD58-4527-AB88-FD084445A6A3} = {D3AF8295-AEB5-4324-AA82-FCC0014AC310}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {03AD8E21-7507-4E68-A4E9-F4A7E7273164}
Expand Down
6 changes: 1 addition & 5 deletions src/Directory.Build.props
Expand Up @@ -6,11 +6,7 @@
<PackageIcon>akkalogo.png</PackageIcon>
<PackageProjectUrl>https://github.com/akkadotnet/akka.net</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/akkadotnet/akka.net/blob/master/LICENSE</PackageLicenseUrl>
<!--
xUnit1031 is a temporary fix, we will need to pay this technical debt
and make everything fully async in the future
-->
<NoWarn>$(NoWarn);CS1591;xUnit1013;xUnit1031</NoWarn>
<NoWarn>$(NoWarn);CS1591;xUnit1013</NoWarn>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<!-- Set the language version for C# if we're not inside an F# project -->
Expand Down
Expand Up @@ -245,11 +245,10 @@ private async Task Should_prefer_node_with_more_free_memory_capacity()

await RunOnAsync(async () =>
{
await WithinAsync(20.Seconds(), () => {
await WithinAsync(20.Seconds(), async () => {
Sys.ActorOf(Props.Create<AdaptiveLoadBalancingRouterConfig.MemoryAllocator>(), "memory-allocator")
.Tell(AdaptiveLoadBalancingRouterConfig.AllocateMemory.Instance);
ExpectMsg("done");
return Task.CompletedTask;
await ExpectMsgAsync("done");
});
}, _config.Node2);

Expand Down
Expand Up @@ -87,10 +87,10 @@ public async Task Stats_sample_should_illustrate_how_to_startup_cluster()

private async Task Should_startup_cluster()
{
await WithinAsync(15.Seconds(), () => {
await WithinAsync(15.Seconds(), async () => {
var cluster = Cluster.Get(Sys);
cluster.Subscribe(TestActor, typeof(ClusterEvent.MemberUp));
ExpectMsg<ClusterEvent.CurrentClusterState>();
await ExpectMsgAsync<ClusterEvent.CurrentClusterState>();

var firstAddress = Node(_config.First).Address;
var secondAddress = Node(_config.Second).Address;
Expand All @@ -101,13 +101,12 @@ private async Task Should_startup_cluster()
Sys.ActorOf(Props.Create<StatsWorker>(), "statsWorker");
Sys.ActorOf(Props.Create<StatsService>(), "statsService");

ReceiveN(3).Select(m => (m as ClusterEvent.MemberUp).Member.Address).Distinct()
(await ReceiveNAsync(3).Select(m => (m as ClusterEvent.MemberUp).Member.Address).Distinct().ToListAsync())
.Should().BeEquivalentTo(firstAddress, secondAddress, thirdAddress);

cluster.Unsubscribe(TestActor);

EnterBarrier("all-up");
return Task.CompletedTask;
});
}

Expand All @@ -130,10 +129,10 @@ private async Task AssertServiceOk()
var service = Sys.ActorSelection(Node(_config.Third) / "user" / "statsService");
// eventually the service should be ok,
// first attempts might fail because worker actors not started yet
await AwaitAssertAsync(() =>
await AwaitAssertAsync(async () =>
{
service.Tell(new StatsJob("this is the text that will be analyzed"));
ExpectMsg<StatsResult>(1.Seconds()).MeanWordLength.Should().BeApproximately(3.875, 0.001);
(await ExpectMsgAsync<StatsResult>(1.Seconds())).MeanWordLength.Should().BeApproximately(3.875, 0.001);
});
}
}
Expand Down