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

[Async TestKit] Convert Akka.Remote.Tests to async - DotNettySslSupportSpec #5894

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/core/Akka.Remote.Tests/RemoteDeathWatchSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public async Task Must_quarantine_systems_after_unsuccessful_system_message_deli

var probe = CreateTestProbe();
probe.Watch(extinctRef);
(await probe.ExpectMsgAsync<Terminated>()).ActorRef.ShouldBe(extinctRef);
probe.Unwatch(extinctRef);
Aaronontheweb marked this conversation as resolved.
Show resolved Hide resolved

await probe.ExpectNoMsgAsync(TimeSpan.FromSeconds(5));
Expand Down
62 changes: 31 additions & 31 deletions src/core/Akka.Remote.Tests/Transport/DotNettySslSupportSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,35 +81,35 @@ private static Config TestThumbprintConfig(string thumbPrint)
}");
}

private ActorSystem sys2;
private Address address1;
private Address address2;
private ActorSystem _sys2;
private Address _address1;
private Address _address2;

private ActorPath echoPath;
private ActorPath _echoPath;

private void Setup(string certPath, string password)
{
sys2 = ActorSystem.Create("sys2", TestConfig(certPath, password));
InitializeLogger(sys2);
_sys2 = ActorSystem.Create("sys2", TestConfig(certPath, password));
InitializeLogger(_sys2);

var echo = sys2.ActorOf(Props.Create<Echo>(), "echo");
var echo = _sys2.ActorOf(Props.Create<Echo>(), "echo");

address1 = RARP.For(Sys).Provider.DefaultAddress;
address2 = RARP.For(sys2).Provider.DefaultAddress;
echoPath = new RootActorPath(address2) / "user" / "echo";
_address1 = RARP.For(Sys).Provider.DefaultAddress;
_address2 = RARP.For(_sys2).Provider.DefaultAddress;
_echoPath = new RootActorPath(_address2) / "user" / "echo";
}

private void SetupThumbprint(string certPath, string password)
{
InstallCert();
sys2 = ActorSystem.Create("sys2", TestThumbprintConfig(Thumbprint));
InitializeLogger(sys2);
_sys2 = ActorSystem.Create("sys2", TestThumbprintConfig(Thumbprint));
InitializeLogger(_sys2);

var echo = sys2.ActorOf(Props.Create<Echo>(), "echo");
var echo = _sys2.ActorOf(Props.Create<Echo>(), "echo");

address1 = RARP.For(Sys).Provider.DefaultAddress;
address2 = RARP.For(sys2).Provider.DefaultAddress;
echoPath = new RootActorPath(address2) / "user" / "echo";
_address1 = RARP.For(Sys).Provider.DefaultAddress;
_address2 = RARP.For(_sys2).Provider.DefaultAddress;
_echoPath = new RootActorPath(_address2) / "user" / "echo";
}

#endregion
Expand All @@ -124,7 +124,7 @@ public DotNettySslSupportSpec(ITestOutputHelper output) : base(TestConfig(ValidC


[Fact]
public void Secure_transport_should_be_possible_between_systems_sharing_the_same_certificate()
public async Task Secure_transport_should_be_possible_between_systems_sharing_the_same_certificate()
{
// skip this test due to linux/mono certificate issues
if (IsMono) return;
Expand All @@ -133,15 +133,15 @@ public void Secure_transport_should_be_possible_between_systems_sharing_the_same

var probe = CreateTestProbe();

AwaitAssert(() =>
await AwaitAssertAsync(async () =>
{
Sys.ActorSelection(echoPath).Tell("hello", probe.Ref);
probe.ExpectMsg("hello", TimeSpan.FromSeconds(3));
Sys.ActorSelection(_echoPath).Tell("hello", probe.Ref);
await probe.ExpectMsgAsync("hello", TimeSpan.FromSeconds(3));
}, TimeSpan.FromSeconds(30), TimeSpan.FromMilliseconds(100));
}

[Fact]
public void Secure_transport_should_be_possible_between_systems_using_thumbprint()
public async Task Secure_transport_should_be_possible_between_systems_using_thumbprint()
{
// skip this test due to linux/mono certificate issues
if (IsMono) return;
Expand All @@ -151,12 +151,12 @@ public void Secure_transport_should_be_possible_between_systems_using_thumbprint

var probe = CreateTestProbe();

Within(TimeSpan.FromSeconds(12), () =>
await WithinAsync(TimeSpan.FromSeconds(12), async () =>
{
AwaitAssert(() =>
await AwaitAssertAsync(async () =>
{
Sys.ActorSelection(echoPath).Tell("hello", probe.Ref);
probe.ExpectMsg("hello", TimeSpan.FromMilliseconds(100));
Sys.ActorSelection(_echoPath).Tell("hello", probe.Ref);
await probe.ExpectMsgAsync("hello", TimeSpan.FromMilliseconds(100));
}, TimeSpan.FromSeconds(3), TimeSpan.FromMilliseconds(100));
});
}
Expand All @@ -167,23 +167,23 @@ public void Secure_transport_should_be_possible_between_systems_using_thumbprint
}

[Fact]
public void Secure_transport_should_NOT_be_possible_between_systems_using_SSL_and_one_not_using_it()
public async Task Secure_transport_should_NOT_be_possible_between_systems_using_SSL_and_one_not_using_it()
{
Setup(null, null);

var probe = CreateTestProbe();
Assert.Throws<RemoteTransportException>(() =>
await Assert.ThrowsAsync<RemoteTransportException>(async () =>
{
Sys.ActorSelection(echoPath).Tell("hello", probe.Ref);
probe.ExpectNoMsg();
Sys.ActorSelection(_echoPath).Tell("hello", probe.Ref);
await probe.ExpectNoMsgAsync();
});
}

#region helper classes / methods

protected override async Task AfterAllAsync()
{
await ShutdownAsync(sys2, TimeSpan.FromSeconds(3));
await ShutdownAsync(_sys2, TimeSpan.FromSeconds(3));
await base.AfterAllAsync();
}

Expand Down Expand Up @@ -213,7 +213,7 @@ private void RemoveCert()
}
}

public class Echo : ReceiveActor
private class Echo : ReceiveActor
{
public Echo()
{
Expand Down