Skip to content

Commit

Permalink
Merge branch 'feature/merge-upstream-changes' of github.com:testconta…
Browse files Browse the repository at this point in the history
…iners/Docker.DotNet into feature/merge-upstream-changes
  • Loading branch information
HofmeisterAn committed Nov 7, 2024
2 parents e6167ae + 513a3fe commit ecbdcfd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/Docker.DotNet/Endpoints/PluginOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ internal PluginOperations(DockerClient client)

IQueryString queryParameters = new QueryString<PluginInstallParameters>(parameters);
return StreamUtil.MonitorStreamForMessagesAsync(
_client.MakeRequestForStreamAsync(_client.NoErrorHandlers, HttpMethod.Post, "plugins/pull", queryParameters, data, null, CancellationToken.None),
_client.MakeRequestForStreamAsync(_client.NoErrorHandlers, HttpMethod.Post, $"plugins/pull", queryParameters, data, null, CancellationToken.None),
_client,
cancellationToken,
progress);
Expand Down Expand Up @@ -145,7 +145,7 @@ public async Task<Plugin> InspectPluginAsync(string name, CancellationToken canc

var query = new QueryString<PluginCreateParameters>(parameters);
var data = new BinaryRequestContent(plugin, TarContentType);
return _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Post, "plugins/create", query, data, cancellationToken);
return _client.MakeRequestAsync(_client.NoErrorHandlers, HttpMethod.Post, $"plugins/create", query, data, cancellationToken);
}

public Task PushPluginAsync(string name, CancellationToken cancellationToken = default(CancellationToken))
Expand Down
29 changes: 15 additions & 14 deletions test/Docker.DotNet.Tests/ISystemOperations.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public ISystemOperationsTests(TestFixture testFixture, ITestOutputHelper outputH
[Fact]
public void Docker_IsRunning()
{
var dockerProcess = Process.GetProcesses().FirstOrDefault(process => process.ProcessName.Equals("docker", StringComparison.InvariantCultureIgnoreCase) || process.ProcessName.Equals("dockerd", StringComparison.InvariantCultureIgnoreCase));
var dockerProcess = Process.GetProcesses().FirstOrDefault(_ => _.ProcessName.Equals("docker", StringComparison.InvariantCultureIgnoreCase) || _.ProcessName.Equals("dockerd", StringComparison.InvariantCultureIgnoreCase));
Assert.NotNull(dockerProcess); // docker is not running
}

Expand All @@ -63,7 +63,7 @@ public async Task MonitorEventsAsync_EmptyContainersList_CanBeCancelled()
var progress = new Progress<Message>();

using var cts = new CancellationTokenSource();
await cts.CancelAsync();
cts.Cancel();
await Task.Delay(1);

await Assert.ThrowsAsync<TaskCanceledException>(() => _dockerClient.System.MonitorEventsAsync(new ContainerEventsParameters(), progress, cts.Token));
Expand Down Expand Up @@ -116,7 +116,7 @@ await _dockerClient.Images.DeleteImageAsync(
// Give it some time for output operation to complete before cancelling task
await Task.Delay(TimeSpan.FromSeconds(1));

await cts.CancelAsync();
cts.Cancel();

await Assert.ThrowsAsync<OperationCanceledException>(() => task).ConfigureAwait(false);

Expand Down Expand Up @@ -144,7 +144,7 @@ public async Task MonitorEventsAsync_IsCancelled_NoStreamCorruption()
cts.Token);

// (2) Wait for some time to make sure we get into blocking IO call
await Task.Delay(100, CancellationToken.None);
await Task.Delay(100);

// (3) Invoke another request that will attempt to grab the same buffer
var listImagesTask1 = _dockerClient.Images.TagImageAsync(
Expand All @@ -153,32 +153,33 @@ public async Task MonitorEventsAsync_IsCancelled_NoStreamCorruption()
{
RepositoryName = _repositoryName,
Tag = newImageTag,
}, CancellationToken.None);
},
default);

// (4) Wait for a short bit again and cancel the monitor task - if we get lucky, we the list images call will grab the same buffer while
sw.Restart();
var iterations = rand.Next(15000000);

for (var j = 0; j < iterations; j++)
for (int j = 0; j < iterations; j++)
{
// noop
}

_output.WriteLine($"Waited for {sw.Elapsed.TotalMilliseconds} ms");

await cts.CancelAsync();
cts.Cancel();

await listImagesTask1;
listImagesTask1.GetAwaiter().GetResult();

await _dockerClient.Images.TagImageAsync(
_dockerClient.Images.TagImageAsync(
$"{_repositoryName}:{_tag}",
new ImageTagParameters
{
RepositoryName = _repositoryName,
Tag = newImageTag,
}, CancellationToken.None);
}
).GetAwaiter().GetResult();

await monitorTask;
monitorTask.GetAwaiter().GetResult();
}
catch (OperationCanceledException)
{
Expand Down Expand Up @@ -261,7 +262,7 @@ await _dockerClient.Images.TagImageAsync(
await _dockerClient.Containers.RemoveContainerAsync(createContainerResponse.ID, new ContainerRemoveParameters(), cts.Token);

await Task.Delay(TimeSpan.FromSeconds(1));
await cts.CancelAsync();
cts.Cancel();

await Assert.ThrowsAsync<OperationCanceledException>(() => task);

Expand All @@ -275,4 +276,4 @@ public async Task PingAsync_Succeeds()
await _dockerClient.System.PingAsync();
}
}
}
}
Binary file added tools/specgen/specgen.exe
Binary file not shown.

0 comments on commit ecbdcfd

Please sign in to comment.