Skip to content

Commit 06990ec

Browse files
authored
Convert Akka.Remote.Tests to async - RemoteDeathWatchSpec (#5890)
1 parent ac223da commit 06990ec

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/core/Akka.Remote.Tests/RemoteDeathWatchSpec.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ protected override async Task AfterAllAsync()
5959
}
6060

6161
[Fact]
62-
public void Must_receive_Terminated_when_system_of_deserialized_ActorRef_is_not_running()
62+
public async Task Must_receive_Terminated_when_system_of_deserialized_ActorRef_is_not_running()
6363
{
6464
var probe = CreateTestProbe();
6565
Sys.EventStream.Subscribe(probe.Ref, typeof(QuarantinedEvent));
6666
var rarp = RARP.For(Sys).Provider;
6767
// pick an unused port (not going to use a socket address generator here; just a port not used by either actor system)
68-
int port = rarp.DefaultAddress.Port.Value;
69-
while (port == rarp.DefaultAddress.Port.Value || port == 2666)
68+
var port = rarp.DefaultAddress.Port;
69+
while (port == rarp.DefaultAddress.Port || port == 2666)
7070
port = ThreadLocalRandom.Current.Next(1, 65535);
7171
// simulate de-serialized ActorRef
7272
var @ref = rarp.ResolveActorRef($"akka.tcp://OtherSystem@localhost:{port}/user/foo/bar#1752527294");
@@ -83,17 +83,17 @@ public void Must_receive_Terminated_when_system_of_deserialized_ActorRef_is_not_
8383
};
8484
Sys.ActorOf(Props.Create(() => new Act(act)).WithDeploy(Deploy.Local));
8585

86-
ExpectMsg(@ref, TimeSpan.FromSeconds(20));
86+
await ExpectMsgAsync(@ref, TimeSpan.FromSeconds(20));
8787
// we don't expect real quarantine when the UID is unknown, i.e. QuarantinedEvent is not published
88-
probe.ExpectNoMsg(TimeSpan.FromSeconds(3));
88+
await probe.ExpectNoMsgAsync(TimeSpan.FromSeconds(3));
8989
// The following verifies that re-delivery of Watch message is stopped.
9090
// It was observed as periodic logging of "address is now gated" when the gate was lifted.
9191
Sys.EventStream.Subscribe(probe.Ref, typeof(Warning));
92-
probe.ExpectNoMsg(TimeSpan.FromSeconds(rarp.RemoteSettings.RetryGateClosedFor.TotalSeconds*2));
92+
await probe.ExpectNoMsgAsync(TimeSpan.FromSeconds(rarp.RemoteSettings.RetryGateClosedFor.TotalSeconds*2));
9393
}
9494

9595
[Fact]
96-
public void Must_receive_terminated_when_watched_node_is_unknown_host()
96+
public async Task Must_receive_terminated_when_watched_node_is_unknown_host()
9797
{
9898
var path = new RootActorPath(new Address("akka.tcp", Sys.Name, "unknownhost", 2552)) / "user" / "subject";
9999
var rarp = RARP.For(Sys).Provider;
@@ -111,27 +111,27 @@ public void Must_receive_terminated_when_watched_node_is_unknown_host()
111111

112112
Sys.ActorOf(Props.Create(() => new Act(act)).WithDeploy(Deploy.Local), "observer2");
113113

114-
ExpectMsg(path, TimeSpan.FromSeconds(60));
114+
await ExpectMsgAsync(path, TimeSpan.FromSeconds(60));
115115
}
116116

117117
[Fact]
118-
public void Must_receive_ActorIdentity_null_when_identified_node_is_unknown_host()
118+
public async Task Must_receive_ActorIdentity_null_when_identified_node_is_unknown_host()
119119
{
120120
var path = new RootActorPath(new Address("akka.tcp", Sys.Name, "unknownhost2", 2552)) / "user" / "subject";
121121
Sys.ActorSelection(path).Tell(new Identify(path));
122-
var identify = ExpectMsg<ActorIdentity>(TimeSpan.FromSeconds(60));
122+
var identify = await ExpectMsgAsync<ActorIdentity>(TimeSpan.FromSeconds(60));
123123
identify.Subject.ShouldBe(null);
124124
identify.MessageId.ShouldBe(path);
125125
}
126126

127127
[Fact]
128-
public void Must_quarantine_systems_after_unsuccessful_system_message_delivery_if_have_not_communicated_before()
128+
public async Task Must_quarantine_systems_after_unsuccessful_system_message_delivery_if_have_not_communicated_before()
129129
{
130130
// Synthesize an ActorRef to a remote system this one has never talked to before.
131131
// This forces ReliableDeliverySupervisor to start with unknown remote system UID.
132132
var rarp = RARP.For(Sys).Provider;
133-
int port = rarp.DefaultAddress.Port.Value;
134-
while (port == rarp.DefaultAddress.Port.Value || port == 2666)
133+
var port = rarp.DefaultAddress.Port;
134+
while (port == rarp.DefaultAddress.Port || port == 2666)
135135
port = ThreadLocalRandom.Current.Next(1, 65535);
136136

137137
var extinctPath = new RootActorPath(new Address("akka.tcp", "extinct-system", "localhost", port)) / "user" / "noone";
@@ -143,9 +143,9 @@ public void Must_quarantine_systems_after_unsuccessful_system_message_delivery_i
143143
probe.Watch(extinctRef);
144144
probe.Unwatch(extinctRef);
145145

146-
probe.ExpectNoMsg(TimeSpan.FromSeconds(5));
146+
await probe.ExpectNoMsgAsync(TimeSpan.FromSeconds(5));
147147
Sys.EventStream.Subscribe(probe.Ref, typeof(Warning));
148-
probe.ExpectNoMsg(TimeSpan.FromSeconds(rarp.RemoteSettings.RetryGateClosedFor.TotalSeconds * 2));
148+
await probe.ExpectNoMsgAsync(TimeSpan.FromSeconds(rarp.RemoteSettings.RetryGateClosedFor.TotalSeconds * 2));
149149
}
150150
}
151151
}

0 commit comments

Comments
 (0)