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

Move GreaterThan2GBFile_SendsAllBytes to a non-parallel test collection #57946

Merged
merged 1 commit into from
Aug 24, 2021
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
Move GreaterThan2GBFile_SendsAllBytes to a non-parallel test collection
  • Loading branch information
antonfirsov committed Aug 23, 2021
commit 6eba23ce43c5f89f6f5bfe2b7761c671f5a1b4bb
113 changes: 74 additions & 39 deletions src/libraries/System.Net.Sockets/tests/FunctionalTests/SendFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,45 +235,6 @@ public async Task SliceBuffers_Success()
}
}

[ActiveIssue("https://github.com/dotnet/runtime/issues/42534", TestPlatforms.Windows)]
[OuterLoop("Creates and sends a file several gigabytes long")]
[Fact]
public async Task GreaterThan2GBFile_SendsAllBytes()
{
const long FileLength = 100L + int.MaxValue;

using var tmpFile = TempFile.Create();
using (FileStream fs = File.Create(tmpFile.Path))
{
fs.SetLength(FileLength);
}

using var client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
using var listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
listener.BindToAnonymousPort(IPAddress.Loopback);
listener.Listen(1);

client.Connect(listener.LocalEndPoint);
using Socket server = listener.Accept();

await new Task[]
{
SendFileAsync(server, tmpFile.Path),
Task.Run(() =>
{
byte[] buffer = new byte[100_000];
long count = 0;
while (count < FileLength)
{
int received = client.Receive(buffer);
Assert.NotEqual(0, received);
count += received;
}
Assert.Equal(0, client.Available);
})
}.WhenAllOrAnyFailed();
}

[Fact]
public async Task SendFileGetsCanceledByDispose()
{
Expand Down Expand Up @@ -503,4 +464,78 @@ public void EndSendFile_NullAsyncResult_Throws()
Assert.Throws<ArgumentNullException>(() => s.EndSendFile(null));
}
}

// Running all cases of GreaterThan2GBFile_SendsAllBytes in parallel may attempt to allocate Min(ProcessorCount, Subclass_Count) * 2GB of disk space
// in extreme cases. Some CI machines may run out of disk space if this happens.
[Collection(nameof(NoParallelTests))]
public class SendFile_NonParallel<T> : SocketTestHelperBase<T> where T : SocketHelperBase, new()
Copy link
Member

Choose a reason for hiding this comment

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

Abstract?

{
protected SendFile_NonParallel(ITestOutputHelper output) : base(output)
{
}

[ActiveIssue("https://github.com/dotnet/runtime/issues/42534", TestPlatforms.Windows)]
[OuterLoop("Creates and sends a file several gigabytes long")]
[Fact]
public async Task GreaterThan2GBFile_SendsAllBytes()
{
const long FileLength = 100L + int.MaxValue;

using var tmpFile = TempFile.Create();
using (FileStream fs = File.Create(tmpFile.Path))
{
fs.SetLength(FileLength);
}

using var client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
using var listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
listener.BindToAnonymousPort(IPAddress.Loopback);
listener.Listen(1);

client.Connect(listener.LocalEndPoint);
using Socket server = listener.Accept();

await new Task[]
{
SendFileAsync(server, tmpFile.Path),
Task.Run(() =>
{
byte[] buffer = new byte[100_000];
long count = 0;
while (count < FileLength)
{
int received = client.Receive(buffer);
Assert.NotEqual(0, received);
count += received;
}
Assert.Equal(0, client.Available);
})
}.WhenAllOrAnyFailed();
}
}

public sealed class SendFile_NonParallel_SyncSpan : SendFile_NonParallel<SocketHelperSpanSync>
{
public SendFile_NonParallel_SyncSpan(ITestOutputHelper output) : base(output) { }
}

public sealed class SendFile_NonParallel_SyncSpanForceNonBlocking : SendFile_NonParallel<SocketHelperSpanSyncForceNonBlocking>
{
public SendFile_NonParallel_SyncSpanForceNonBlocking(ITestOutputHelper output) : base(output) { }
}

public sealed class SendFile_NonParallel_ArraySync : SendFile_NonParallel<SocketHelperArraySync>
{
public SendFile_NonParallel_ArraySync(ITestOutputHelper output) : base(output) { }
}

public sealed class SendFile_NonParallel_Task : SendFile_NonParallel<SocketHelperTask>
{
public SendFile_NonParallel_Task(ITestOutputHelper output) : base(output) { }
}

public sealed class SendFile_NonParallel_Apm : SendFile_NonParallel<SocketHelperApm>
{
public SendFile_NonParallel_Apm(ITestOutputHelper output) : base(output) { }
}
Copy link
Member

@ManickaP ManickaP Aug 23, 2021

Choose a reason for hiding this comment

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

I assume that SocketHelperCancellableTask and SocketHelperSyncForceNonBlocking are left out on purpose?
I should have read the description first 😄

}