Skip to content
Merged
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
13 changes: 10 additions & 3 deletions src/core/Akka.Streams.Tests/IO/TcpSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,21 @@ await this.AssertAllStagesStoppedAsync(async () =>
var tcpWriteProbe = new TcpWriteProbe(this);
var tcpReadProbe = new TcpReadProbe(this);

Source.FromPublisher(tcpWriteProbe.PublisherProbe)
.Via(Sys.TcpStream().OutgoingConnection(server.Address))
// Wait for TCP connection to be fully established before aborting
var connectionTask = Source.FromPublisher(tcpWriteProbe.PublisherProbe)
.ViaMaterialized(Sys.TcpStream().OutgoingConnection(server.Address), Keep.Right)
.To(Sink.FromSubscriber(tcpReadProbe.SubscriberProbe))
.Run(Materializer);

var serverConnection = await server.WaitAcceptAsync();
var clientConnection = await connectionTask;

// Start active reading to ensure Linux can detect TCP RST
var readSub = await tcpReadProbe.SubscriberProbe.ExpectSubscriptionAsync();
readSub.Request(1);

serverConnection.Abort();
await tcpReadProbe.SubscriberProbe.ExpectSubscriptionAndErrorAsync();
await tcpReadProbe.SubscriberProbe.ExpectErrorAsync();
var subscription = await tcpWriteProbe.TcpWriteSubscription();
await subscription.ExpectCancellationAsync();

Expand Down