Skip to content

Commit

Permalink
harden ClusterLogSpec (#6031)
Browse files Browse the repository at this point in the history
* harden `ClusterLogSpec`

The `JoinAsync` method wasn't written correctly - need to force `JoinAsync` to run to completion for assertion to make any kind of sense.

* hardened `DownAsync` and `JoinAsync`

* Update ClusterLogSpec.cs

* fixed up `ClusterLogSpec`
  • Loading branch information
Aaronontheweb committed Jul 12, 2022
1 parent 0efdc18 commit 4b667c6
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/core/Akka.Cluster.Tests/ClusterLogSpec.cs
Expand Up @@ -68,7 +68,15 @@ protected async Task JoinAsync(string expected)
{
await EventFilter
.Info(contains: expected)
.ExpectOneAsync(async () => _cluster.Join(_selfAddress));
.ExpectOneAsync(async () => {
var tcs = new TaskCompletionSource<bool>();
_cluster.RegisterOnMemberUp(() =>
{
tcs.TrySetResult(true);
});
_cluster.Join(_selfAddress);
await tcs.Task.ShouldCompleteWithin(Remaining);
});
});
}

Expand All @@ -82,7 +90,16 @@ protected async Task DownAsync(string expected)
{
await EventFilter
.Info(contains: expected)
.ExpectOneAsync(async () => _cluster.Down(_selfAddress));
.ExpectOneAsync(async () =>
{
var tcs = new TaskCompletionSource<bool>();
_cluster.RegisterOnMemberRemoved(() =>
{
tcs.TrySetResult(true);
});
_cluster.Down(_selfAddress);
await tcs.Task.ShouldCompleteWithin(Remaining);
});
});
}
}
Expand Down

0 comments on commit 4b667c6

Please sign in to comment.