diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/CoordinatedShutdownShardingSpec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/CoordinatedShutdownShardingSpec.cs
index 7200930ade6..21ea9941665 100644
--- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/CoordinatedShutdownShardingSpec.cs
+++ b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/CoordinatedShutdownShardingSpec.cs
@@ -103,9 +103,9 @@ protected override void BeforeTermination()
///
/// Using region 2 as it is not shutdown in either test.
///
- private void PingEntities()
+ private async Task PingEntities()
{
- AwaitAssert(() =>
+ await AwaitAssertAsync(() =>
{
_region2.Tell(1, _probe2.Ref);
_probe2.ExpectMsg(1.Seconds()).Should().Be(1);
@@ -117,22 +117,22 @@ private void PingEntities()
}
[Fact]
- public void Sharding_and_CoordinatedShutdown_must_run_successfully()
+ public async Task Sharding_and_CoordinatedShutdown_must_run_successfully()
{
- InitCluster();
- RunCoordinatedShutdownWhenLeaving();
- RunCoordinatedShutdownWhenDowning();
+ await InitCluster();
+ await RunCoordinatedShutdownWhenLeaving();
+ await RunCoordinatedShutdownWhenDowning();
}
- private void InitCluster()
+ private async Task InitCluster()
{
Cluster.Get(_sys1).Join(Cluster.Get(_sys1).SelfAddress); // coordinator will initially run on sys1
- AwaitAssert(() => Cluster.Get(_sys1).SelfMember.Status.Should().Be(MemberStatus.Up));
+ await AwaitAssertAsync(() => Cluster.Get(_sys1).SelfMember.Status.Should().Be(MemberStatus.Up));
Cluster.Get(_sys2).Join(Cluster.Get(_sys1).SelfAddress);
- Within(10.Seconds(), () =>
+ await WithinAsync(10.Seconds(), async () =>
{
- AwaitAssert(() =>
+ await AwaitAssertAsync(() =>
{
Cluster.Get(_sys1).State.Members.Count.Should().Be(2);
Cluster.Get(_sys1).State.Members.All(x => x.Status == MemberStatus.Up).Should().BeTrue();
@@ -142,9 +142,9 @@ private void InitCluster()
});
Cluster.Get(_sys3).Join(Cluster.Get(_sys1).SelfAddress);
- Within(10.Seconds(), () =>
+ await WithinAsync(10.Seconds(), async () =>
{
- AwaitAssert(() =>
+ await AwaitAssertAsync(() =>
{
Cluster.Get(_sys1).State.Members.Count.Should().Be(3);
Cluster.Get(_sys1).State.Members.All(x => x.Status == MemberStatus.Up).Should().BeTrue();
@@ -155,59 +155,59 @@ private void InitCluster()
});
});
- PingEntities();
+ await PingEntities();
}
- private void RunCoordinatedShutdownWhenLeaving()
+ private async Task RunCoordinatedShutdownWhenLeaving()
{
Cluster.Get(_sys3).Leave(Cluster.Get(_sys1).SelfAddress);
_probe1.ExpectMsg("CS-unbind-1");
- Within(20.Seconds(), () =>
+ await WithinAsync(20.Seconds(), async () =>
{
- AwaitAssert(() =>
+ await AwaitAssertAsync(() =>
{
Cluster.Get(_sys2).State.Members.Count.Should().Be(2);
Cluster.Get(_sys3).State.Members.Count.Should().Be(2);
});
});
- Within(10.Seconds(), () =>
+ await WithinAsync(10.Seconds(), async () =>
{
- AwaitAssert(() =>
+ await AwaitAssertAsync(() =>
{
Cluster.Get(_sys1).IsTerminated.Should().BeTrue();
_sys1.WhenTerminated.IsCompleted.Should().BeTrue();
});
});
- PingEntities();
+ await PingEntities();
}
- private void RunCoordinatedShutdownWhenDowning()
+ private async Task RunCoordinatedShutdownWhenDowning()
{
// coordinator is on Sys2
Cluster.Get(_sys2).Down(Cluster.Get(_sys3).SelfAddress);
_probe3.ExpectMsg("CS-unbind-3");
- Within(20.Seconds(), () =>
+ await WithinAsync(20.Seconds(), async () =>
{
- AwaitAssert(() =>
+ await AwaitAssertAsync(() =>
{
Cluster.Get(_sys2).State.Members.Count.Should().Be(1);
});
});
- Within(10.Seconds(), () =>
+ await WithinAsync(10.Seconds(), async () =>
{
- AwaitAssert(() =>
+ await AwaitAssertAsync(() =>
{
Cluster.Get(_sys3).IsTerminated.Should().BeTrue();
_sys3.WhenTerminated.IsCompleted.Should().BeTrue();
});
});
- PingEntities();
+ await PingEntities();
}
}
}
diff --git a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/PersistentShardSpec.cs b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/PersistentShardSpec.cs
index b6b3082f7e1..6ba8d325ec5 100644
--- a/src/contrib/cluster/Akka.Cluster.Sharding.Tests/PersistentShardSpec.cs
+++ b/src/contrib/cluster/Akka.Cluster.Sharding.Tests/PersistentShardSpec.cs
@@ -53,7 +53,7 @@ public PersistentShardSpec(ITestOutputHelper helper) : base(SpecConfig, helper)
}
[Fact]
- public void Persistent_Shard_must_remember_entities_started_with_StartEntity()
+ public async Task Persistent_Shard_must_remember_entities_started_with_StartEntity()
{
Func ep = id => Props.Create(() => new EntityActor(id));
@@ -82,7 +82,7 @@ public void Persistent_Shard_must_remember_entities_started_with_StartEntity()
var secondIncarnation = Sys.ActorOf(props);
secondIncarnation.Tell(Shard.GetShardStats.Instance);
- AwaitAssert(() =>
+ await AwaitAssertAsync(() =>
{
ExpectMsgAllOf(new Shard.ShardStats("shard-1", 1));
});
diff --git a/src/contrib/cluster/Akka.Cluster.Tools.Tests/Singleton/ClusterSingletonLeavingSpeedSpec.cs b/src/contrib/cluster/Akka.Cluster.Tools.Tests/Singleton/ClusterSingletonLeavingSpeedSpec.cs
index 8b45e3ab3e3..f4a2fb7753c 100644
--- a/src/contrib/cluster/Akka.Cluster.Tools.Tests/Singleton/ClusterSingletonLeavingSpeedSpec.cs
+++ b/src/contrib/cluster/Akka.Cluster.Tools.Tests/Singleton/ClusterSingletonLeavingSpeedSpec.cs
@@ -10,6 +10,7 @@
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
+using System.Threading.Tasks;
using Akka.Actor;
using Akka.Cluster.Tools.Singleton;
using Akka.Configuration;
@@ -72,7 +73,7 @@ public ClusterSingletonLeavingSpeedSpec() : base(@"
_probes = _systems.Select(i => CreateTestProbe()).ToArray();
}
- public void Join(ActorSystem from, ActorSystem to, IActorRef probe)
+ public async Task JoinAsync(ActorSystem from, ActorSystem to, IActorRef probe)
{
from.ActorOf(ClusterSingletonManager.Props(
TheSingleton.props(probe),
@@ -81,9 +82,9 @@ public void Join(ActorSystem from, ActorSystem to, IActorRef probe)
Cluster.Get(from).Join(Cluster.Get(to).SelfAddress);
- Within(TimeSpan.FromSeconds(15), () =>
+ await WithinAsync(TimeSpan.FromSeconds(15), async () =>
{
- AwaitAssert(() =>
+ await AwaitAssertAsync(() =>
{
Cluster.Get(from).State.Members.Select(x => x.UniqueAddress).Should().Contain(Cluster.Get(from).SelfUniqueAddress);
Cluster.Get(from)
@@ -96,24 +97,24 @@ public void Join(ActorSystem from, ActorSystem to, IActorRef probe)
}
[Fact]
- public void ClusterSingleton_that_is_leaving_must()
+ public async Task ClusterSingleton_that_is_leaving_must()
{
- ClusterSingleton_that_is_leaving_must_join_cluster();
- ClusterSingleton_that_is_leaving_must_quickly_hand_over_to_next_oldest();
+ await ClusterSingleton_that_is_leaving_must_join_cluster();
+ await ClusterSingleton_that_is_leaving_must_quickly_hand_over_to_next_oldest();
}
- private void ClusterSingleton_that_is_leaving_must_join_cluster()
+ private async Task ClusterSingleton_that_is_leaving_must_join_cluster()
{
for (int i = 0; i < _systems.Length; i++)
- Join(_systems[i], _systems[0], _probes[i]);
+ await JoinAsync(_systems[i], _systems[0], _probes[i]);
// leader is most likely on system, lowest port
- Join(Sys, _systems[0], TestActor);
+ await JoinAsync(Sys, _systems[0], TestActor);
_probes[0].ExpectMsg("started");
}
- private void ClusterSingleton_that_is_leaving_must_quickly_hand_over_to_next_oldest()
+ private async Task ClusterSingleton_that_is_leaving_must_quickly_hand_over_to_next_oldest()
{
List<(TimeSpan, TimeSpan)> durations = new List<(TimeSpan, TimeSpan)>();
Stopwatch sw = new Stopwatch();
@@ -132,9 +133,9 @@ private void ClusterSingleton_that_is_leaving_must_quickly_hand_over_to_next_old
var startedDuration = sw.Elapsed;
- Within(TimeSpan.FromSeconds(15), () =>
+ await WithinAsync(TimeSpan.FromSeconds(15), async () =>
{
- AwaitAssert(() =>
+ await AwaitAssertAsync(() =>
{
Cluster.Get(_systems[i]).IsTerminated.Should().BeTrue();
Cluster.Get(Sys).State.Members.Select(m => m.Address).Should().NotContain(leaveAddress);
diff --git a/src/contrib/cluster/Akka.Cluster.Tools.Tests/Singleton/ClusterSingletonRestart2Spec.cs b/src/contrib/cluster/Akka.Cluster.Tools.Tests/Singleton/ClusterSingletonRestart2Spec.cs
index 6b8c3727b10..a7cf5125c07 100644
--- a/src/contrib/cluster/Akka.Cluster.Tools.Tests/Singleton/ClusterSingletonRestart2Spec.cs
+++ b/src/contrib/cluster/Akka.Cluster.Tools.Tests/Singleton/ClusterSingletonRestart2Spec.cs
@@ -44,7 +44,7 @@ public ClusterSingletonRestart2Spec() : base(@"
.WithFallback(Sys.Settings.Config));
}
- public void Join(ActorSystem from, ActorSystem to)
+ public async Task JoinAsync(ActorSystem from, ActorSystem to)
{
if (Cluster.Get(from).SelfRoles.Contains("singleton"))
{
@@ -54,9 +54,9 @@ public void Join(ActorSystem from, ActorSystem to)
}
- Within(TimeSpan.FromSeconds(45), () =>
+ await WithinAsync(TimeSpan.FromSeconds(45), async () =>
{
- AwaitAssert(() =>
+ await AwaitAssertAsync(() =>
{
Cluster.Get(from).Join(Cluster.Get(to).SelfAddress);
Cluster.Get(from).State.Members.Select(x => x.UniqueAddress).Should().Contain(Cluster.Get(from).SelfUniqueAddress);
@@ -70,18 +70,18 @@ public void Join(ActorSystem from, ActorSystem to)
}
[Fact]
- public void Restarting_cluster_node_during_hand_over_must_restart_singletons_in_restarted_node()
+ public async Task Restarting_cluster_node_during_hand_over_must_restart_singletons_in_restarted_node()
{
- Join(_sys1, _sys1);
- Join(_sys2, _sys1);
- Join(_sys3, _sys1);
+ await JoinAsync(_sys1, _sys1);
+ await JoinAsync(_sys2, _sys1);
+ await JoinAsync(_sys3, _sys1);
var proxy3 = _sys3.ActorOf(
ClusterSingletonProxy.Props("user/echo", ClusterSingletonProxySettings.Create(_sys3).WithRole("singleton")), "proxy3");
- Within(TimeSpan.FromSeconds(5), () =>
+ await WithinAsync(TimeSpan.FromSeconds(5), async () =>
{
- AwaitAssert(() =>
+ await AwaitAssertAsync(() =>
{
var probe = CreateTestProbe(_sys3);
proxy3.Tell("hello", probe.Ref);
@@ -104,14 +104,14 @@ public void Restarting_cluster_node_during_hand_over_must_restart_singletons_in_
.WithFallback(_sys1.Settings.Config);
_sys4 = ActorSystem.Create(_sys1.Name, sys4Config);
- Join(_sys4, _sys3);
+ await JoinAsync(_sys4, _sys3);
// let it stabilize
Task.Delay(TimeSpan.FromSeconds(5)).Wait();
- Within(TimeSpan.FromSeconds(10), () =>
+ await WithinAsync(TimeSpan.FromSeconds(10), async () =>
{
- AwaitAssert(() =>
+ await AwaitAssertAsync(() =>
{
var probe = CreateTestProbe(_sys3);
proxy3.Tell("hello2", probe.Ref);
diff --git a/src/contrib/cluster/Akka.Cluster.Tools.Tests/Singleton/ClusterSingletonRestartSpec.cs b/src/contrib/cluster/Akka.Cluster.Tools.Tests/Singleton/ClusterSingletonRestartSpec.cs
index 80cdace2d6a..cb91bacac47 100644
--- a/src/contrib/cluster/Akka.Cluster.Tools.Tests/Singleton/ClusterSingletonRestartSpec.cs
+++ b/src/contrib/cluster/Akka.Cluster.Tools.Tests/Singleton/ClusterSingletonRestartSpec.cs
@@ -8,6 +8,7 @@
using System;
using System.Collections.Immutable;
using System.Linq;
+using System.Threading.Tasks;
using Akka.Actor;
using Akka.Cluster.Tools.Singleton;
using Akka.Configuration;
@@ -39,15 +40,15 @@ public ClusterSingletonRestartSpec() : base(@"
_sys2 = ActorSystem.Create(Sys.Name, Sys.Settings.Config);
}
- public void Join(ActorSystem from, ActorSystem to)
+ public async Task JoinAsync(ActorSystem from, ActorSystem to)
{
from.ActorOf(ClusterSingletonManager.Props(Echo.Props,
PoisonPill.Instance,
ClusterSingletonManagerSettings.Create(from)), "echo");
- Within(TimeSpan.FromSeconds(10), () =>
+ await WithinAsync(TimeSpan.FromSeconds(10), async () =>
{
- AwaitAssert(() =>
+ await AwaitAssertAsync(() =>
{
Cluster.Get(from).Join(Cluster.Get(to).SelfAddress);
Cluster.Get(from).State.Members.Select(x => x.UniqueAddress).Should().Contain(Cluster.Get(from).SelfUniqueAddress);
@@ -61,17 +62,17 @@ public void Join(ActorSystem from, ActorSystem to)
}
[Fact]
- public void Restarting_cluster_node_with_same_hostname_and_port_must_handover_to_next_oldest()
+ public async Task Restarting_cluster_node_with_same_hostname_and_port_must_handover_to_next_oldest()
{
- Join(_sys1, _sys1);
- Join(_sys2, _sys1);
+ await JoinAsync(_sys1, _sys1);
+ await JoinAsync(_sys2, _sys1);
var proxy2 = _sys2.ActorOf(
ClusterSingletonProxy.Props("user/echo", ClusterSingletonProxySettings.Create(_sys2)), "proxy2");
- Within(TimeSpan.FromSeconds(5), () =>
+ await WithinAsync(TimeSpan.FromSeconds(5), async () =>
{
- AwaitAssert(() =>
+ await AwaitAssertAsync(() =>
{
var probe = CreateTestProbe(_sys2);
proxy2.Tell("hello", probe.Ref);
@@ -88,11 +89,11 @@ public void Restarting_cluster_node_with_same_hostname_and_port_must_handover_to
.WithFallback(_sys1.Settings.Config);
_sys3 = ActorSystem.Create(_sys1.Name, sys3Config);
- Join(_sys3, _sys2);
+ await JoinAsync(_sys3, _sys2);
- Within(TimeSpan.FromSeconds(5), () =>
+ await WithinAsync(TimeSpan.FromSeconds(5), async () =>
{
- AwaitAssert(() =>
+ await AwaitAssertAsync(() =>
{
var probe = CreateTestProbe(_sys2);
proxy2.Tell("hello2", probe.Ref);
@@ -102,9 +103,9 @@ public void Restarting_cluster_node_with_same_hostname_and_port_must_handover_to
Cluster.Get(_sys2).Leave(Cluster.Get(_sys2).SelfAddress);
- Within(TimeSpan.FromSeconds(15), () =>
+ await WithinAsync(TimeSpan.FromSeconds(15), async () =>
{
- AwaitAssert(() =>
+ await AwaitAssertAsync(() =>
{
Cluster.Get(_sys3)
.State.Members.Select(x => x.UniqueAddress)
@@ -117,9 +118,9 @@ public void Restarting_cluster_node_with_same_hostname_and_port_must_handover_to
_sys3.ActorOf(ClusterSingletonProxy.Props("user/echo", ClusterSingletonProxySettings.Create(_sys3)),
"proxy3");
- Within(TimeSpan.FromSeconds(5), () =>
+ await WithinAsync(TimeSpan.FromSeconds(5), async () =>
{
- AwaitAssert(() =>
+ await AwaitAssertAsync(() =>
{
var probe = CreateTestProbe(_sys3);
proxy3.Tell("hello3", probe.Ref);
diff --git a/src/contrib/cluster/Akka.DistributedData.Tests/LocalConcurrencySpec.cs b/src/contrib/cluster/Akka.DistributedData.Tests/LocalConcurrencySpec.cs
index 37d4ef5a3ed..0a3758a68c8 100644
--- a/src/contrib/cluster/Akka.DistributedData.Tests/LocalConcurrencySpec.cs
+++ b/src/contrib/cluster/Akka.DistributedData.Tests/LocalConcurrencySpec.cs
@@ -6,6 +6,7 @@
//-----------------------------------------------------------------------
using System.Collections.Immutable;
+using System.Threading.Tasks;
using Akka.Actor;
using Akka.Configuration;
using Xunit;
@@ -46,7 +47,7 @@ public LocalConcurrencySpec(ITestOutputHelper output)
}
[Fact]
- public void Updates_from_same_node_should_be_possible_to_do_from_two_actors()
+ public async Task Updates_from_same_node_should_be_possible_to_do_from_two_actors()
{
var updater1 = ActorOf(Props.Create(), "updater1");
var updater2 = ActorOf(Props.Create(), "updater2");
@@ -64,7 +65,7 @@ public void Updates_from_same_node_should_be_possible_to_do_from_two_actors()
}
var expected = b.ToImmutable();
- AwaitAssert(() =>
+ await AwaitAssertAsync(() =>
{
_replicator.Tell(Dsl.Get(Updater.Key, ReadLocal.Instance));
var msg = ExpectMsg();
diff --git a/src/contrib/dependencyinjection/Akka.DI.TestKit/DiResolverSpec.cs b/src/contrib/dependencyinjection/Akka.DI.TestKit/DiResolverSpec.cs
index 0af0c185ed2..4c43caf247c 100644
--- a/src/contrib/dependencyinjection/Akka.DI.TestKit/DiResolverSpec.cs
+++ b/src/contrib/dependencyinjection/Akka.DI.TestKit/DiResolverSpec.cs
@@ -331,61 +331,61 @@ public void DependencyResolver_should_inject_instances_into_DiChildActor()
}
[Fact]
- public void DependencyResolver_should_inject_into_normal_mailbox_Actor()
+ public async Task DependencyResolver_should_inject_into_normal_mailbox_Actor()
{
var stashActorProps = Sys.DI().Props();
var stashActor = Sys.ActorOf(stashActorProps);
var internalRef = (RepointableActorRef)stashActor;
- AwaitCondition(() => internalRef.IsStarted);
+ await AwaitConditionAsync(() => internalRef.IsStarted);
Assert.IsType(internalRef.Underlying.AsInstanceOf().Mailbox.MessageQueue);
}
[Fact]
- public void DependencyResolver_should_inject_into_UnboundedStash_Actor()
+ public async Task DependencyResolver_should_inject_into_UnboundedStash_Actor()
{
var stashActorProps = Sys.DI().Props();
var stashActor = Sys.ActorOf(stashActorProps);
var internalRef = (RepointableActorRef)stashActor;
- AwaitCondition(() => internalRef.IsStarted);
+ await AwaitConditionAsync(() => internalRef.IsStarted);
Assert.IsType(internalRef.Underlying.AsInstanceOf().Mailbox.MessageQueue);
}
[Fact]
- public void DependencyResolver_should_inject_into_BoundedStash_Actor()
+ public async Task DependencyResolver_should_inject_into_BoundedStash_Actor()
{
var stashActorProps = Sys.DI().Props();
var stashActor = Sys.ActorOf(stashActorProps);
var internalRef = (RepointableActorRef)stashActor;
- AwaitCondition(() => internalRef.IsStarted);
+ await AwaitConditionAsync(() => internalRef.IsStarted);
Assert.IsType(internalRef.Underlying.AsInstanceOf().Mailbox.MessageQueue);
}
[Fact]
- public void DependencyResolver_should_dispose_IDisposable_instances_on_Actor_Termination()
+ public async Task DependencyResolver_should_dispose_IDisposable_instances_on_Actor_Termination()
{
var disposableActorProps = Sys.DI().Props();
var disposableActor = Sys.ActorOf(disposableActorProps);
var currentDisposeCounter = _disposeCounter.Current;
Assert.True(disposableActor.GracefulStop(TimeSpan.FromSeconds(1)).Result);
- AwaitAssert(() => Assert.True(currentDisposeCounter + 1 == _disposeCounter.Current), TimeSpan.FromSeconds(2), TimeSpan.FromMilliseconds(50));
+ await AwaitAssertAsync(() => Assert.True(currentDisposeCounter + 1 == _disposeCounter.Current), TimeSpan.FromSeconds(2), TimeSpan.FromMilliseconds(50));
}
[Fact]
- public void DependencyResolver_should_dispose_IDisposable_instances_on_Actor_Restart()
+ public async Task DependencyResolver_should_dispose_IDisposable_instances_on_Actor_Restart()
{
var disposableActorProps = Sys.DI().Props();
var disposableActor = Sys.ActorOf(disposableActorProps);
var currentDisposeCounter = _disposeCounter.Current;
disposableActor.Tell(new DisposableActor.Restart());
- AwaitAssert(() => Assert.True(currentDisposeCounter + 1 == _disposeCounter.Current), TimeSpan.FromSeconds(2), TimeSpan.FromMilliseconds(50));
+ await AwaitAssertAsync(() => Assert.True(currentDisposeCounter + 1 == _disposeCounter.Current), TimeSpan.FromSeconds(2), TimeSpan.FromMilliseconds(50));
}
#endregion
diff --git a/src/core/Akka.Cluster.TestKit/MultiNodeClusterSpec.cs b/src/core/Akka.Cluster.TestKit/MultiNodeClusterSpec.cs
index b7b4fff671d..4f50414141d 100644
--- a/src/core/Akka.Cluster.TestKit/MultiNodeClusterSpec.cs
+++ b/src/core/Akka.Cluster.TestKit/MultiNodeClusterSpec.cs
@@ -11,6 +11,7 @@
using System.Collections.Immutable;
using System.Linq;
using System.Text.RegularExpressions;
+using System.Threading.Tasks;
using Akka.Actor;
using Akka.Cluster.Tests.MultiNode;
using Akka.Configuration;
@@ -271,13 +272,13 @@ public void AwaitClusterUp(params RoleName[] roles)
EnterBarrier(roles.Select(r => r.Name).Aggregate((a, b) => a + "-" + b) + "-joined");
}
- public void JoinWithin(RoleName joinNode, TimeSpan? max = null, TimeSpan? interval = null)
+ public async Task JoinWithinAsync(RoleName joinNode, TimeSpan? max = null, TimeSpan? interval = null)
{
if (max == null) max = RemainingOrDefault;
if (interval == null) interval = TimeSpan.FromSeconds(1);
Cluster.Join(GetAddress(joinNode));
- AwaitCondition(() =>
+ await AwaitConditionAsync(() =>
{
ClusterView.RefreshCurrentState();
if (MemberInState(GetAddress(joinNode), new[] { MemberStatus.Up }) &&
@@ -287,7 +288,6 @@ public void JoinWithin(RoleName joinNode, TimeSpan? max = null, TimeSpan? interv
Cluster.Join(GetAddress(joinNode));
return false;
}, max, interval);
-
}
private bool MemberInState(Address member, IEnumerable status)
diff --git a/src/core/Akka.Cluster.Tests/ClusterSpec.cs b/src/core/Akka.Cluster.Tests/ClusterSpec.cs
index 21fd1c99a85..434b2ce0552 100644
--- a/src/core/Akka.Cluster.Tests/ClusterSpec.cs
+++ b/src/core/Akka.Cluster.Tests/ClusterSpec.cs
@@ -66,16 +66,16 @@ public void A_cluster_must_use_the_address_of_the_remote_transport()
}
[Fact]
- public void A_cluster_must_initially_become_singleton_cluster_when_joining_itself_and_reach_convergence()
+ public async Task A_cluster_must_initially_become_singleton_cluster_when_joining_itself_and_reach_convergence()
{
ClusterView.Members.Count.Should().Be(0);
_cluster.Join(_selfAddress);
LeaderActions(); // Joining -> Up
- AwaitCondition(() => ClusterView.IsSingletonCluster);
+ await AwaitConditionAsync(() => ClusterView.IsSingletonCluster);
ClusterView.Self.Address.Should().Be(_selfAddress);
ClusterView.Members.Select(m => m.Address).ToImmutableHashSet()
.Should().BeEquivalentTo(ImmutableHashSet.Create(_selfAddress));
- AwaitAssert(() => ClusterView.Status.Should().Be(MemberStatus.Up));
+ await AwaitAssertAsync(() => ClusterView.Status.Should().Be(MemberStatus.Up));
}
[Fact]
@@ -167,7 +167,7 @@ public void BugFix_2442_RegisterOnMemberUp_should_fire_if_node_already_up()
}
[Fact]
- public void A_cluster_must_complete_LeaveAsync_task_upon_being_removed()
+ public async Task A_cluster_must_complete_LeaveAsync_task_upon_being_removed()
{
var sys2 = ActorSystem.Create("ClusterSpec2", ConfigurationFactory.ParseString(@"
akka.actor.provider = ""cluster""
@@ -192,14 +192,14 @@ public void A_cluster_must_complete_LeaveAsync_task_upon_being_removed()
var removed = (ClusterEvent.MemberRemoved)probe.FishForMessage(m => m is ClusterEvent.MemberRemoved);
removed.PreviousStatus.ShouldBeEquivalentTo(MemberStatus.Exiting);
- AwaitCondition(() => leaveTask.IsCompleted);
+ await AwaitConditionAsync(() => leaveTask.IsCompleted);
// A second call for LeaveAsync should complete immediately (should be the same task as before)
Cluster.Get(sys2).LeaveAsync().IsCompleted.Should().BeTrue();
}
[Fact]
- public void A_cluster_must_return_completed_LeaveAsync_task_if_member_already_removed()
+ public async Task A_cluster_must_return_completed_LeaveAsync_task_if_member_already_removed()
{
// Join cluster
_cluster.Join(_selfAddress);
@@ -222,11 +222,11 @@ public void A_cluster_must_return_completed_LeaveAsync_task_if_member_already_re
});
// LeaveAsync() task expected to complete immediately
- AwaitCondition(() => _cluster.LeaveAsync().IsCompleted);
+ await AwaitConditionAsync(() => _cluster.LeaveAsync().IsCompleted);
}
[Fact]
- public void A_cluster_must_cancel_LeaveAsync_task_if_CancellationToken_fired_before_node_left()
+ public async Task A_cluster_must_cancel_LeaveAsync_task_if_CancellationToken_fired_before_node_left()
{
// Join cluster
_cluster.Join(_selfAddress);
@@ -245,9 +245,9 @@ public void A_cluster_must_cancel_LeaveAsync_task_if_CancellationToken_fired_bef
// Cancelling the first task
cts.Cancel();
- AwaitCondition(() => task1.IsCanceled, null, "Task should be cancelled");
+ await AwaitConditionAsync(() => task1.IsCanceled, null, "Task should be cancelled");
- Within(TimeSpan.FromSeconds(10), () =>
+ await WithinAsync(TimeSpan.FromSeconds(10), async () =>
{
// Second task should continue awaiting for cluster leave
task2.IsCompleted.Should().BeFalse();
@@ -260,16 +260,16 @@ public void A_cluster_must_cancel_LeaveAsync_task_if_CancellationToken_fired_bef
ExpectMsg().Member.Address.Should().Be(_selfAddress);
// Second task should complete (not cancelled)
- AwaitCondition(() => task2.IsCompleted && !task2.IsCanceled, null, "Task should be completed, but not cancelled.");
+ await AwaitConditionAsync(() => task2.IsCompleted && !task2.IsCanceled, null, "Task should be completed, but not cancelled.");
});
// Subsequent LeaveAsync() tasks expected to complete immediately (not cancelled)
var task3 = _cluster.LeaveAsync();
- AwaitCondition(() => task3.IsCompleted && !task3.IsCanceled, null, "Task should be completed, but not cancelled.");
+ await AwaitConditionAsync(() => task3.IsCompleted && !task3.IsCanceled, null, "Task should be completed, but not cancelled.");
}
[Fact]
- public void A_cluster_must_be_allowed_to_join_and_leave_with_local_address()
+ public async Task A_cluster_must_be_allowed_to_join_and_leave_with_local_address()
{
var sys2 = ActorSystem.Create("ClusterSpec2", ConfigurationFactory.ParseString(@"akka.actor.provider = ""Akka.Cluster.ClusterActorRefProvider, Akka.Cluster""
akka.remote.dot-netty.tcp.port = 0"));
@@ -278,9 +278,9 @@ public void A_cluster_must_be_allowed_to_join_and_leave_with_local_address()
{
var @ref = sys2.ActorOf(Props.Empty);
Cluster.Get(sys2).Join(@ref.Path.Address); // address doesn't contain full address information
- Within(5.Seconds(), () =>
+ await WithinAsync(5.Seconds(), async () =>
{
- AwaitAssert(() =>
+ await AwaitAssertAsync(() =>
{
Cluster.Get(sys2).State.Members.Count.Should().Be(1);
Cluster.Get(sys2).State.Members.First().Status.Should().Be(MemberStatus.Up);
@@ -289,9 +289,9 @@ public void A_cluster_must_be_allowed_to_join_and_leave_with_local_address()
Cluster.Get(sys2).Leave(@ref.Path.Address);
- Within(5.Seconds(), () =>
+ await WithinAsync(5.Seconds(), async () =>
{
- AwaitAssert(() =>
+ await AwaitAssertAsync(() =>
{
Cluster.Get(sys2).IsTerminated.Should().BeTrue();
});
@@ -489,7 +489,7 @@ public void A_cluster_must_leave_via_CoordinatedShutdownRun_when_member_status_i
}
[Fact]
- public void A_cluster_must_terminate_ActorSystem_via_leave_CoordinatedShutdown()
+ public async Task A_cluster_must_terminate_ActorSystem_via_leave_CoordinatedShutdown()
{
var sys2 = ActorSystem.Create("ClusterSpec2", ConfigurationFactory.ParseString(@"
akka.actor.provider = ""cluster""
@@ -511,7 +511,7 @@ public void A_cluster_must_terminate_ActorSystem_via_leave_CoordinatedShutdown()
// MemberExited might not be published before MemberRemoved
var removed = (ClusterEvent.MemberRemoved)probe.FishForMessage(m => m is ClusterEvent.MemberRemoved);
removed.PreviousStatus.ShouldBeEquivalentTo(MemberStatus.Exiting);
- AwaitCondition(() => sys2.WhenTerminated.IsCompleted, TimeSpan.FromSeconds(10));
+ await AwaitConditionAsync(() => sys2.WhenTerminated.IsCompleted, TimeSpan.FromSeconds(10));
Cluster.Get(sys2).IsTerminated.Should().BeTrue();
CoordinatedShutdown.Get(sys2).ShutdownReason.Should().BeOfType();
}
@@ -522,7 +522,7 @@ public void A_cluster_must_terminate_ActorSystem_via_leave_CoordinatedShutdown()
}
[Fact]
- public void A_cluster_must_terminate_ActorSystem_via_Down_CoordinatedShutdown()
+ public async Task A_cluster_must_terminate_ActorSystem_via_Down_CoordinatedShutdown()
{
var sys3 = ActorSystem.Create("ClusterSpec3", ConfigurationFactory.ParseString(@"
akka.actor.provider = ""cluster""
@@ -544,7 +544,7 @@ public void A_cluster_must_terminate_ActorSystem_via_Down_CoordinatedShutdown()
probe.ExpectMsg();
probe.ExpectMsg();
- AwaitCondition(() => sys3.WhenTerminated.IsCompleted, TimeSpan.FromSeconds(10));
+ await AwaitConditionAsync(() => sys3.WhenTerminated.IsCompleted, TimeSpan.FromSeconds(10));
Cluster.Get(sys3).IsTerminated.Should().BeTrue();
CoordinatedShutdown.Get(sys3).ShutdownReason.Should().BeOfType();
}
diff --git a/src/core/Akka.Cluster.Tests/DowningProviderSpec.cs b/src/core/Akka.Cluster.Tests/DowningProviderSpec.cs
index a9a8263c3d8..796874c1659 100644
--- a/src/core/Akka.Cluster.Tests/DowningProviderSpec.cs
+++ b/src/core/Akka.Cluster.Tests/DowningProviderSpec.cs
@@ -7,6 +7,7 @@
using System;
using System.Threading;
+using System.Threading.Tasks;
using Akka.Actor;
using Akka.Configuration;
using Akka.TestKit;
@@ -87,7 +88,7 @@ public void Downing_provider_should_use_AutoDowning_if_auto_down_unreachable_aft
}
[Fact]
- public void Downing_provider_should_use_specified_downing_provider()
+ public async Task Downing_provider_should_use_specified_downing_provider()
{
var config = ConfigurationFactory.ParseString(
@"akka.cluster.downing-provider-class = ""Akka.Cluster.Tests.DummyDowningProvider, Akka.Cluster.Tests""");
@@ -95,14 +96,14 @@ public void Downing_provider_should_use_specified_downing_provider()
{
var downingProvider = Cluster.Get(system).DowningProvider;
downingProvider.Should().BeOfType();
- AwaitCondition(() =>
+ await AwaitConditionAsync(() =>
(downingProvider as DummyDowningProvider).ActorPropsAccessed.Value,
TimeSpan.FromSeconds(3));
}
}
[Fact]
- public void Downing_provider_should_stop_the_cluster_if_the_downing_provider_throws_exception_in_props()
+ public async Task Downing_provider_should_stop_the_cluster_if_the_downing_provider_throws_exception_in_props()
{
var config = ConfigurationFactory.ParseString(
@"akka.cluster.downing-provider-class = ""Akka.Cluster.Tests.FailingDowningProvider, Akka.Cluster.Tests""");
@@ -112,7 +113,7 @@ public void Downing_provider_should_stop_the_cluster_if_the_downing_provider_thr
var cluster = Cluster.Get(system);
cluster.Join(cluster.SelfAddress);
- AwaitCondition(() => cluster.IsTerminated, TimeSpan.FromSeconds(3));
+ await AwaitConditionAsync(() => cluster.IsTerminated, TimeSpan.FromSeconds(3));
Shutdown(system);
}
diff --git a/src/core/Akka.Cluster.Tests/ShutdownAfterJoinSeedNodesSpec.cs b/src/core/Akka.Cluster.Tests/ShutdownAfterJoinSeedNodesSpec.cs
index e4461abfac1..230c6d9ef02 100644
--- a/src/core/Akka.Cluster.Tests/ShutdownAfterJoinSeedNodesSpec.cs
+++ b/src/core/Akka.Cluster.Tests/ShutdownAfterJoinSeedNodesSpec.cs
@@ -7,6 +7,7 @@
using System;
using System.Collections.Immutable;
+using System.Threading.Tasks;
using Akka.Actor;
using Akka.Configuration;
using Akka.TestKit;
@@ -46,7 +47,7 @@ protected override void AfterTermination()
}
[Fact]
- public void Joining_seed_nodes_must_be_aborted_after_shutdown_after_unsuccessful_join_seed_nodes()
+ public async Task Joining_seed_nodes_must_be_aborted_after_shutdown_after_unsuccessful_join_seed_nodes()
{
var seedNodes = ImmutableList.Create(
Cluster.Get(_seed1).SelfAddress,
@@ -57,8 +58,8 @@ public void Joining_seed_nodes_must_be_aborted_after_shutdown_after_unsuccessful
Cluster.Get(_seed2).JoinSeedNodes(seedNodes);
Cluster.Get(_ordinary1).JoinSeedNodes(seedNodes);
- AwaitCondition(() => _seed2.WhenTerminated.IsCompleted, Cluster.Get(_seed2).Settings.ShutdownAfterUnsuccessfulJoinSeedNodes + TimeSpan.FromSeconds(10));
- AwaitCondition(() => _ordinary1.WhenTerminated.IsCompleted, Cluster.Get(_ordinary1).Settings.ShutdownAfterUnsuccessfulJoinSeedNodes + TimeSpan.FromSeconds(10));
+ await AwaitConditionAsync(() => _seed2.WhenTerminated.IsCompleted, Cluster.Get(_seed2).Settings.ShutdownAfterUnsuccessfulJoinSeedNodes + TimeSpan.FromSeconds(10));
+ await AwaitConditionAsync(() => _ordinary1.WhenTerminated.IsCompleted, Cluster.Get(_ordinary1).Settings.ShutdownAfterUnsuccessfulJoinSeedNodes + TimeSpan.FromSeconds(10));
}
}
}
diff --git a/src/core/Akka.Docs.Tests/Streams/KillSwitchDocTests.cs b/src/core/Akka.Docs.Tests/Streams/KillSwitchDocTests.cs
index e1260dabcb2..8a68de38461 100644
--- a/src/core/Akka.Docs.Tests/Streams/KillSwitchDocTests.cs
+++ b/src/core/Akka.Docs.Tests/Streams/KillSwitchDocTests.cs
@@ -1,5 +1,6 @@
using System;
using System.Linq;
+using System.Threading.Tasks;
using Akka.Streams;
using Akka.Streams.Dsl;
using Akka.TestKit.Xunit2;
@@ -24,7 +25,7 @@ private void DoSomethingElse()
}
[Fact]
- public void Unique_kill_switch_must_control_graph_completion_with_shutdown()
+ public async Task Unique_kill_switch_must_control_graph_completion_with_shutdown()
{
#region unique-shutdown
var countingSrc = Source.From(Enumerable.Range(1, int.MaxValue)).Delay(1.Seconds(), DelayOverflowStrategy.Backpressure);
@@ -39,7 +40,7 @@ public void Unique_kill_switch_must_control_graph_completion_with_shutdown()
killSwitch.Shutdown();
- AwaitCondition(() => last.IsCompleted);
+ await AwaitConditionAsync(() => last.IsCompleted);
#endregion
}
@@ -64,7 +65,7 @@ public void Unique_kill_switch_must_control_graph_completion_with_abort()
}
[Fact]
- public void Shared_kill_switch_must_control_graph_completion_with_shutdown()
+ public async Task Shared_kill_switch_must_control_graph_completion_with_shutdown()
{
#region shared-shutdown
var countingSrc = Source.From(Enumerable.Range(1, int.MaxValue)).Delay(1.Seconds(), DelayOverflowStrategy.Backpressure);
@@ -84,8 +85,8 @@ public void Shared_kill_switch_must_control_graph_completion_with_shutdown()
sharedKillSwitch.Shutdown();
- AwaitCondition(() => last.IsCompleted);
- AwaitCondition(() => delayedLast.IsCompleted);
+ await AwaitConditionAsync(() => last.IsCompleted);
+ await AwaitConditionAsync(() => delayedLast.IsCompleted);
#endregion
}
diff --git a/src/core/Akka.Docs.Tests/Testkit/TestKitSampleTest.cs b/src/core/Akka.Docs.Tests/Testkit/TestKitSampleTest.cs
index e2b7397dba2..6ffb64fa226 100644
--- a/src/core/Akka.Docs.Tests/Testkit/TestKitSampleTest.cs
+++ b/src/core/Akka.Docs.Tests/Testkit/TestKitSampleTest.cs
@@ -1,4 +1,5 @@
using System;
+using System.Threading.Tasks;
using Akka.Actor;
using Akka.TestKit.Xunit2;
using Xunit;
@@ -31,7 +32,7 @@ public class TestKitSampleTest : TestKit
private TimeSpan EpsilonValueForWithins => new TimeSpan(0, 0, 1); // https://github.com/akkadotnet/akka.net/issues/2130
[Fact]
- public void Test()
+ public async Task Test()
{
var subject = this.Sys.ActorOf();
@@ -44,12 +45,12 @@ public void Test()
ExpectMsg("done", TimeSpan.FromSeconds(1));
// the action needs to finish within 3 seconds
- Within(TimeSpan.FromSeconds(3), () => {
+ await WithinAsync(TimeSpan.FromSeconds(3), async () => {
subject.Tell("hello", this.TestActor);
// This is a demo: would normally use expectMsgEquals().
// Wait time is bounded by 3-second deadline above.
- AwaitCondition(() => probe.HasMessages);
+ await AwaitConditionAsync(() => probe.HasMessages);
// response must have been enqueued to us before probe
ExpectMsg("world", TimeSpan.FromSeconds(0));
diff --git a/src/core/Akka.Docs.Tutorials/Tutorial3/DeviceGroupSpec.cs b/src/core/Akka.Docs.Tutorials/Tutorial3/DeviceGroupSpec.cs
index 88f330bd089..57047f08120 100644
--- a/src/core/Akka.Docs.Tutorials/Tutorial3/DeviceGroupSpec.cs
+++ b/src/core/Akka.Docs.Tutorials/Tutorial3/DeviceGroupSpec.cs
@@ -1,4 +1,5 @@
using System;
+using System.Threading.Tasks;
using Akka.Actor;
using Akka.TestKit.Xunit2;
using FluentAssertions;
@@ -83,7 +84,7 @@ public void DeviceGroup_actor_must_be_able_to_list_active_devices()
}
[Fact]
- public void DeviceGroup_actor_must_be_able_to_list_active_devices_after_one_shuts_down()
+ public async Task DeviceGroup_actor_must_be_able_to_list_active_devices_after_one_shuts_down()
{
var probe = CreateTestProbe();
var groupActor = Sys.ActorOf(DeviceGroup.Props("group"));
@@ -106,7 +107,7 @@ public void DeviceGroup_actor_must_be_able_to_list_active_devices_after_one_shut
// using awaitAssert to retry because it might take longer for the groupActor
// to see the Terminated, that order is undefined
- probe.AwaitAssert(() =>
+ await probe.AwaitAssertAsync(() =>
{
groupActor.Tell(new RequestDeviceList(requestId: 1), probe.Ref);
probe.ExpectMsg(s => s.RequestId == 1 && s.Ids.Contains("device2"));
diff --git a/src/core/Akka.Docs.Tutorials/Tutorial4/DeviceGroupSpec.cs b/src/core/Akka.Docs.Tutorials/Tutorial4/DeviceGroupSpec.cs
index c661bea3a16..94f810cf037 100644
--- a/src/core/Akka.Docs.Tutorials/Tutorial4/DeviceGroupSpec.cs
+++ b/src/core/Akka.Docs.Tutorials/Tutorial4/DeviceGroupSpec.cs
@@ -1,4 +1,5 @@
using System;
+using System.Threading.Tasks;
using Akka.Actor;
using Akka.TestKit.Xunit2;
using Akka.Util.Internal;
@@ -79,7 +80,7 @@ public void DeviceGroup_actor_must_be_able_to_list_active_devices()
}
[Fact]
- public void DeviceGroup_actor_must_be_able_to_list_active_devices_after_one_shuts_down()
+ public async Task DeviceGroup_actor_must_be_able_to_list_active_devices_after_one_shuts_down()
{
var probe = CreateTestProbe();
var groupActor = Sys.ActorOf(DeviceGroup.Props("group"));
@@ -102,7 +103,7 @@ public void DeviceGroup_actor_must_be_able_to_list_active_devices_after_one_shut
// using awaitAssert to retry because it might take longer for the groupActor
// to see the Terminated, that order is undefined
- probe.AwaitAssert(() =>
+ await probe.AwaitAssertAsync(() =>
{
groupActor.Tell(new RequestDeviceList(requestId: 1), probe.Ref);
probe.ExpectMsg(s => s.RequestId == 1 && s.Ids.Contains("device2"));
diff --git a/src/core/Akka.Persistence.TCK/Query/CurrentEventsByPersistenceIdSpec.cs b/src/core/Akka.Persistence.TCK/Query/CurrentEventsByPersistenceIdSpec.cs
index 090c1c5dd7c..e448df5151f 100644
--- a/src/core/Akka.Persistence.TCK/Query/CurrentEventsByPersistenceIdSpec.cs
+++ b/src/core/Akka.Persistence.TCK/Query/CurrentEventsByPersistenceIdSpec.cs
@@ -6,6 +6,7 @@
//-----------------------------------------------------------------------
using System;
+using System.Threading.Tasks;
using Akka.Actor;
using Akka.Configuration;
using Akka.Persistence.Query;
@@ -85,39 +86,39 @@ public virtual void ReadJournal_CurrentEventsByPersistenceId_should_not_see_new_
}
[Fact]
- public virtual void ReadJournal_CurrentEventsByPersistenceId_should_return_empty_stream_for_cleaned_journal_from_0_to_MaxLong()
+ public virtual async Task ReadJournal_CurrentEventsByPersistenceId_should_return_empty_stream_for_cleaned_journal_from_0_to_MaxLong()
{
var queries = ReadJournal.AsInstanceOf();
var pref = Setup("g1");
pref.Tell(new TestActor.DeleteCommand(3));
- AwaitAssert(() => ExpectMsg("3-deleted"));
+ await AwaitAssertAsync(() => ExpectMsg("3-deleted"));
var src = queries.CurrentEventsByPersistenceId("g1", 0, long.MaxValue);
src.Select(x => x.Event).RunWith(this.SinkProbe