Skip to content

Commit

Permalink
Fix racy Akka.Streams.IO.Tcp spec (#6430)
Browse files Browse the repository at this point in the history
* harden utgoing_TCP_stream_must_handle_when_connection_actor_terminates_unexpectedly

racy spec

* move delay out of tight loop
  • Loading branch information
Aaronontheweb committed Feb 22, 2023
1 parent 0e0bd83 commit 22255e3
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/core/Akka.Streams.Tests/IO/TcpSpec.cs
Expand Up @@ -496,10 +496,21 @@ public async Task Outgoing_TCP_stream_must_handle_when_connection_actor_terminat
// get initialized, otherwise Kill command may run into the void
await Task.Delay(500);

// Getting rid of existing connection actors by using a blunt instrument
system2.ActorSelection(system2.Tcp().Path / "$a" / "*").Tell(Kill.Instance);

await Awaiting(() => result.ShouldCompleteWithin(3.Seconds()))
await Awaiting(async () =>
{
await WithinAsync(TimeSpan.FromSeconds(15), async () =>
{
await AwaitAssertAsync(async () =>
{
// Getting rid of existing connection actors by using a blunt instrument
system2.ActorSelection(system2.Tcp().Path / "$a" / "*").Tell(Kill.Instance);
await result.ShouldCompleteWithin(3.Seconds());
}, interval:TimeSpan.FromSeconds(4));
});
})
.Should().ThrowAsync<StreamTcpException>();

await binding.Result.Unbind().ShouldCompleteWithin(3.Seconds());
Expand Down

0 comments on commit 22255e3

Please sign in to comment.