Skip to content

Commit

Permalink
Fix ClusterLogSpec, EventFilter does not play nice with Within (#6041)
Browse files Browse the repository at this point in the history
* Fix ClusterLogSpec, EventFilter can not be used inside Within

* Fix timeout
  • Loading branch information
Arkatufus committed Jul 13, 2022
1 parent b21f5fa commit 32040a3
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions src/core/Akka.Cluster.Tests/ClusterLogSpec.cs
Expand Up @@ -64,20 +64,17 @@ protected async Task AwaitUpAsync()
/// </summary>
protected async Task JoinAsync(string expected)
{
await WithinAsync(TimeSpan.FromSeconds(10), async () =>
{
await EventFilter
.Info(contains: expected)
.ExpectOneAsync(async () => {
var tcs = new TaskCompletionSource<bool>();
_cluster.RegisterOnMemberUp(() =>
{
tcs.TrySetResult(true);
});
_cluster.Join(_selfAddress);
await tcs.Task.ShouldCompleteWithin(Remaining);
await EventFilter
.Info(contains: expected)
.ExpectOneAsync(10.Seconds(), async () => {
var tcs = new TaskCompletionSource<bool>();
_cluster.RegisterOnMemberUp(() =>
{
tcs.TrySetResult(true);
});
});
_cluster.Join(_selfAddress);
await tcs.Task.ShouldCompleteWithin(10.Seconds());
});
}

/// <summary>
Expand All @@ -86,21 +83,18 @@ await EventFilter
/// <param name="expected"></param>
protected async Task DownAsync(string expected)
{
await WithinAsync(TimeSpan.FromSeconds(10), async () =>
{
await EventFilter
await EventFilter
.Info(contains: expected)
.ExpectOneAsync(async () =>
.ExpectOneAsync(10.Seconds(), async () =>
{
var tcs = new TaskCompletionSource<bool>();
_cluster.RegisterOnMemberRemoved(() =>
{
tcs.TrySetResult(true);
});
_cluster.Down(_selfAddress);
await tcs.Task.ShouldCompleteWithin(Remaining);
await tcs.Task.ShouldCompleteWithin(10.Seconds());
});
});
}
}

Expand Down Expand Up @@ -131,9 +125,9 @@ public ClusterLogVerboseDefaultSpec(ITestOutputHelper output)
public async Task A_cluster_must_not_log_verbose_cluster_events_by_default()
{
_cluster.Settings.LogInfoVerbose.ShouldBeFalse();
await JoinAsync(upLogMessage).ShouldThrowWithin<TrueException>(10.Seconds());
await JoinAsync(upLogMessage).ShouldThrowWithin<TrueException>(11.Seconds());
await AwaitUpAsync();
await DownAsync(downLogMessage).ShouldThrowWithin<TrueException>(10.Seconds());
await DownAsync(downLogMessage).ShouldThrowWithin<TrueException>(11.Seconds());
}
}

Expand Down

0 comments on commit 32040a3

Please sign in to comment.