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 - Transport.DotNettyTransportShutdownSpec #5896

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
5 changes: 4 additions & 1 deletion src/core/Akka.Remote.Tests/RemotingTerminatorSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ await WithinAsync(TimeSpan.FromSeconds(10), async () =>
public async Task RemotingTerminator_should_shutdown_promptly_with_some_associations()
{
_sys2 = ActorSystem.Create("System2", RemoteConfig);
InitializeLogger(_sys2);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't find what's wrong with the failing test, adding xunit logging support on the second ActorSystem so I can debug it better if it happens again. Need to see if the second system successfully shuts down gracefully.

var sys2Address = RARP.For(_sys2).Provider.DefaultAddress;

// open an association
Expand All @@ -78,6 +79,7 @@ public async Task RemotingTerminator_should_shutdown_promptly_with_some_associat
public async Task RemotingTerminator_should_shutdown_properly_with_remotely_deployed_actor()
{
_sys2 = ActorSystem.Create("System2", RemoteConfig);
InitializeLogger(_sys2);
var sys2Address = RARP.For(_sys2).Provider.DefaultAddress;

// open an association via remote deployment
Expand Down Expand Up @@ -105,6 +107,7 @@ await EventFilter.Exception<ShutDownAssociation>().ExpectAsync(0,
async () =>
{
_sys2 = ActorSystem.Create("System2", RemoteConfig);
InitializeLogger(_sys2);
var sys2Address = RARP.For(_sys2).Provider.DefaultAddress;

// open an association via remote deployment
Expand All @@ -113,7 +116,7 @@ await EventFilter.Exception<ShutDownAssociation>().ExpectAsync(0,
Watch(associated);

// verify that the association is open (don't terminate until handshake is finished)
associated.Ask<ActorIdentity>(new Identify("foo"), RemainingOrDefault).Result.MessageId.ShouldBe("foo");
(await associated.Ask<ActorIdentity>(new Identify("foo"), RemainingOrDefault)).MessageId.ShouldBe("foo");

// terminate the DEPLOYED system
Assert.True(await _sys2.Terminate().AwaitWithTimeout(10.Seconds()), "Expected to terminate within 10 seconds, but didn't.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,22 @@ public async Task DotNettyTcpTransport_should_cleanly_terminate_active_endpoints
// t1 --> t2 association
var handle = await t1.Associate(c2.Item1);
handle.ReadHandlerSource.SetResult(new ActorHandleEventListener(p1));
var inboundHandle = p2.ExpectMsg<InboundAssociation>().Association; // wait for the inbound association handle to show up
var inboundHandle = (await p2.ExpectMsgAsync<InboundAssociation>()).Association; // wait for the inbound association handle to show up
inboundHandle.ReadHandlerSource.SetResult(new ActorHandleEventListener(p2));

AwaitCondition(() => t1.ConnectionGroup.Count == 2);
AwaitCondition(() => t2.ConnectionGroup.Count == 2);
await AwaitConditionAsync(() => t1.ConnectionGroup.Count == 2);
await AwaitConditionAsync(() => t2.ConnectionGroup.Count == 2);

var chan1 = t1.ConnectionGroup.Single(x => !x.Id.Equals(t1.ServerChannel.Id));
var chan2 = t2.ConnectionGroup.Single(x => !x.Id.Equals(t2.ServerChannel.Id));

// force a disassociation
handle.Disassociate();
handle.Disassociate("Dissociation test", Log);

// verify that the connections are terminated
p1.ExpectMsg<Disassociated>();
AwaitCondition(() => t1.ConnectionGroup.Count == 1);
AwaitCondition(() => t2.ConnectionGroup.Count == 1);
await p1.ExpectMsgAsync<Disassociated>();
await AwaitConditionAsync(() => t1.ConnectionGroup.Count == 1);
await AwaitConditionAsync(() => t2.ConnectionGroup.Count == 1);

// verify that the connection channels were terminated on both ends
chan1.CloseCompletion.IsCompleted.Should().BeTrue();
Expand Down Expand Up @@ -142,22 +142,22 @@ public async Task DotNettyTcpTransport_should_cleanly_terminate_active_endpoints
// t1 --> t2 association
var handle = await t1.Associate(c2.Item1);
handle.ReadHandlerSource.SetResult(new ActorHandleEventListener(p1));
var inboundHandle = p2.ExpectMsg<InboundAssociation>().Association; // wait for the inbound association handle to show up
var inboundHandle = (await p2.ExpectMsgAsync<InboundAssociation>()).Association; // wait for the inbound association handle to show up
inboundHandle.ReadHandlerSource.SetResult(new ActorHandleEventListener(p2));

AwaitCondition(() => t1.ConnectionGroup.Count == 2);
AwaitCondition(() => t2.ConnectionGroup.Count == 2);
await AwaitConditionAsync(() => t1.ConnectionGroup.Count == 2);
await AwaitConditionAsync(() => t2.ConnectionGroup.Count == 2);

var chan1 = t1.ConnectionGroup.Single(x => !x.Id.Equals(t1.ServerChannel.Id));
var chan2 = t2.ConnectionGroup.Single(x => !x.Id.Equals(t2.ServerChannel.Id));

// shutdown remoting on t1
await t1.Shutdown();

p2.ExpectMsg<Disassociated>();
await p2.ExpectMsgAsync<Disassociated>();
// verify that the connections are terminated
AwaitCondition(() => t1.ConnectionGroup.Count == 0, null, message: $"Expected 0 open connection but found {t1.ConnectionGroup.Count}");
AwaitCondition(() => t2.ConnectionGroup.Count == 1, null,message: $"Expected 1 open connection but found {t2.ConnectionGroup.Count}");
await AwaitConditionAsync(() => t1.ConnectionGroup.Count == 0, null, message: $"Expected 0 open connection but found {t1.ConnectionGroup.Count}");
await AwaitConditionAsync(() => t2.ConnectionGroup.Count == 1, null,message: $"Expected 1 open connection but found {t2.ConnectionGroup.Count}");

// verify that the connection channels were terminated on both ends
chan1.CloseCompletion.IsCompleted.Should().BeTrue();
Expand Down Expand Up @@ -192,21 +192,21 @@ public async Task DotNettyTcpTransport_should_cleanly_terminate_active_endpoints
// t1 --> t2 association
var handle = await t1.Associate(c2.Item1);
handle.ReadHandlerSource.SetResult(new ActorHandleEventListener(p1));
var inboundHandle = p2.ExpectMsg<InboundAssociation>().Association; // wait for the inbound association handle to show up
var inboundHandle = (await p2.ExpectMsgAsync<InboundAssociation>()).Association; // wait for the inbound association handle to show up
inboundHandle.ReadHandlerSource.SetResult(new ActorHandleEventListener(p2));

AwaitCondition(() => t1.ConnectionGroup.Count == 2);
AwaitCondition(() => t2.ConnectionGroup.Count == 2);
await AwaitConditionAsync(() => t1.ConnectionGroup.Count == 2);
await AwaitConditionAsync(() => t2.ConnectionGroup.Count == 2);

var chan1 = t1.ConnectionGroup.Single(x => !x.Id.Equals(t1.ServerChannel.Id));
var chan2 = t2.ConnectionGroup.Single(x => !x.Id.Equals(t2.ServerChannel.Id));

// force a disassociation
inboundHandle.Disassociate();
inboundHandle.Disassociate("Dissociation test", Log);

// verify that the connections are terminated
AwaitCondition(() => t1.ConnectionGroup.Count == 1, null, message: $"Expected 1 open connection but found {t1.ConnectionGroup.Count}");
AwaitCondition(() => t2.ConnectionGroup.Count == 1, null, message: $"Expected 1 open connection but found {t2.ConnectionGroup.Count}");
await AwaitConditionAsync(() => t1.ConnectionGroup.Count == 1, null, message: $"Expected 1 open connection but found {t1.ConnectionGroup.Count}");
await AwaitConditionAsync(() => t2.ConnectionGroup.Count == 1, null, message: $"Expected 1 open connection but found {t2.ConnectionGroup.Count}");

// verify that the connection channels were terminated on both ends
chan1.CloseCompletion.IsCompleted.Should().BeTrue();
Expand Down Expand Up @@ -241,11 +241,11 @@ public async Task DotNettyTcpTransport_should_cleanly_terminate_active_endpoints
// t1 --> t2 association
var handle = await t1.Associate(c2.Item1);
handle.ReadHandlerSource.SetResult(new ActorHandleEventListener(p1));
var inboundHandle = p2.ExpectMsg<InboundAssociation>().Association; // wait for the inbound association handle to show up
var inboundHandle = (await p2.ExpectMsgAsync<InboundAssociation>()).Association; // wait for the inbound association handle to show up
inboundHandle.ReadHandlerSource.SetResult(new ActorHandleEventListener(p2));

AwaitCondition(() => t1.ConnectionGroup.Count == 2);
AwaitCondition(() => t2.ConnectionGroup.Count == 2);
await AwaitConditionAsync(() => t1.ConnectionGroup.Count == 2);
await AwaitConditionAsync(() => t2.ConnectionGroup.Count == 2);

var chan1 = t1.ConnectionGroup.Single(x => !x.Id.Equals(t1.ServerChannel.Id));
var chan2 = t2.ConnectionGroup.Single(x => !x.Id.Equals(t2.ServerChannel.Id));
Expand All @@ -254,8 +254,8 @@ public async Task DotNettyTcpTransport_should_cleanly_terminate_active_endpoints
await t2.Shutdown();

// verify that the connections are terminated
AwaitCondition(() => t1.ConnectionGroup.Count == 1, null, message: $"Expected 1 open connection but found {t1.ConnectionGroup.Count}");
AwaitCondition(() => t2.ConnectionGroup.Count == 0, null, message: $"Expected 0 open connection but found {t2.ConnectionGroup.Count}");
await AwaitConditionAsync(() => t1.ConnectionGroup.Count == 1, null, message: $"Expected 1 open connection but found {t1.ConnectionGroup.Count}");
await AwaitConditionAsync(() => t2.ConnectionGroup.Count == 0, null, message: $"Expected 0 open connection but found {t2.ConnectionGroup.Count}");

// verify that the connection channels were terminated on both ends
chan1.CloseCompletion.IsCompleted.Should().BeTrue();
Expand Down Expand Up @@ -290,7 +290,7 @@ await Assert.ThrowsAsync<InvalidAssociationException>(async () =>
});


AwaitCondition(() => t1.ConnectionGroup.Count == 1);
await AwaitConditionAsync(() => t1.ConnectionGroup.Count == 1);
}
finally
{
Expand Down