Skip to content
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
3 changes: 0 additions & 3 deletions src/Docker.DotNet.NativeHttp/DockerHandlerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ namespace Docker.DotNet.NativeHttp;

public sealed class DockerHandlerFactory : IDockerHandlerFactory<NativeHttpTransportOptions>
{
private const int MaxConnectionsPerServer = 10;

private static readonly TimeSpan PooledConnectionLifetime = TimeSpan.FromMinutes(5);

private static readonly TimeSpan PooledConnectionIdleTimeout = TimeSpan.FromMinutes(2);
Expand Down Expand Up @@ -35,7 +33,6 @@ public ResolvedTransport CreateHandler(NativeHttpTransportOptions transportOptio
#if NET
var handler = new SocketsHttpHandler
{
MaxConnectionsPerServer = MaxConnectionsPerServer,
PooledConnectionLifetime = PooledConnectionLifetime,
PooledConnectionIdleTimeout = PooledConnectionIdleTimeout,
PlaintextStreamFilter = TrackingNetworkStream.EnableTrackingAsync,
Expand Down
29 changes: 29 additions & 0 deletions test/Docker.DotNet.Tests/ISystemOperations.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,35 @@ public async Task GetVersionAsync_Succeeds()
Assert.NotNull(version.APIVersion);
}

[Fact]
public async Task GetVersionAsync_ManyEventStreamsOpen_Succeeds()
{
using var cts = CancellationTokenSource.CreateLinkedTokenSource(_testFixture.Cts.Token);

// Each event stream holds its connection until it is cancelled.
var monitorTasks = Enumerable.Range(0, 16)
.Select(_ => _testFixture.DockerClient.System.MonitorEventsAsync(new ContainerEventsParameters(), new Progress<Message>(), cts.Token))
.ToArray();

try
{
using var timeoutCts = CancellationTokenSource.CreateLinkedTokenSource(_testFixture.Cts.Token);
timeoutCts.CancelAfter(TimeSpan.FromSeconds(10));

var version = await _testFixture.DockerClient.System.GetVersionAsync(timeoutCts.Token);
Assert.NotNull(version.APIVersion);
}
finally
{
await cts.CancelAsync();
}

foreach (var monitorTask in monitorTasks)
{
await Assert.ThrowsAnyAsync<OperationCanceledException>(() => monitorTask);
}
}

[Fact]
public async Task MonitorEventsAsync_EmptyContainersList_CanBeCancelled()
{
Expand Down