Skip to content

Commit 50b46d9

Browse files
committed
Bug fix. Networking workload (NTttcp). Handle OperationCanceledExceptions in ProcessProxy to avoid the need to handle them everywhere else in the code.
1 parent 93701ee commit 50b46d9

File tree

5 files changed

+14
-57
lines changed

5 files changed

+14
-57
lines changed

.pipelines/azure-pipelines-linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ resources:
1616
options: --entrypoint=""
1717

1818
variables:
19-
VcVersion : 1.13.12
19+
VcVersion : 1.13.13
2020
ROOT: $(Build.SourcesDirectory)
2121
CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)] # needed for onebranch.pipeline.version task https://aka.ms/obpipelines/versioning
2222
ENABLE_PRS_DELAYSIGN: 1

src/VirtualClient/Module.props

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,6 @@
125125
<!-- SSH.Net -->
126126
<SSH_Net_PackageVersion>2020.0.2</SSH_Net_PackageVersion>
127127

128-
<!-- Swashbuckle.AspNetCore -->
129-
<Swashbuckle_AspNetCore_PackageVersion>6.1.1</Swashbuckle_AspNetCore_PackageVersion>
130-
131128
<!-- System.CommandLine -->
132129
<System_CommandLine_PackageVersion>2.0.0-beta1.21308.1</System_CommandLine_PackageVersion>
133130

src/VirtualClient/VirtualClient.Common/ProcessProxy.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -348,15 +348,22 @@ public virtual IProcessProxy WriteInput(string input)
348348
/// </summary>
349349
public virtual async Task WaitForExitAsync(CancellationToken cancellationToken, TimeSpan? timeout = null)
350350
{
351-
if (timeout == null)
351+
try
352352
{
353-
await this.UnderlyingProcess.WaitForExitAsync(cancellationToken).ConfigureAwait(false);
354-
this.exitTime = DateTime.UtcNow;
353+
if (timeout == null)
354+
{
355+
await this.UnderlyingProcess.WaitForExitAsync(cancellationToken).ConfigureAwait(false);
356+
this.exitTime = DateTime.UtcNow;
357+
}
358+
else
359+
{
360+
await this.UnderlyingProcess.WaitForExitAsync(cancellationToken).WaitAsync(timeout.Value).ConfigureAwait(false);
361+
this.exitTime = DateTime.UtcNow;
362+
}
355363
}
356-
else
364+
catch (OperationCanceledException)
357365
{
358-
await this.UnderlyingProcess.WaitForExitAsync(cancellationToken).WaitAsync(timeout.Value).ConfigureAwait(false);
359-
this.exitTime = DateTime.UtcNow;
366+
// Expected whenever the CancellationToken receives a cancellation request.
360367
}
361368
}
362369

src/VirtualClient/VirtualClient.Main/ApiManager.cs

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
namespace VirtualClient
55
{
6-
using System;
76
using System.Collections.Generic;
87
using System.IO.Abstractions;
98
using System.Reflection;
@@ -15,8 +14,6 @@ namespace VirtualClient
1514
using Microsoft.Extensions.Configuration;
1615
using Microsoft.Extensions.DependencyInjection;
1716
using Microsoft.Extensions.Logging;
18-
using Microsoft.OpenApi.Models;
19-
using Swashbuckle.AspNetCore.SwaggerUI;
2017
using VirtualClient.Api;
2118
using VirtualClient.Common.Extensions;
2219
using VirtualClient.Contracts;
@@ -63,21 +60,6 @@ private void ConfigureApplication(IWebHostBuilder hostBuilder, IServiceCollectio
6360
{
6461
hostBuilder.Configure(apiService =>
6562
{
66-
// Enable middleware to serve generated Swagger as a JSON endpoint.
67-
apiService.UseSwagger();
68-
69-
// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
70-
// specifying the Swagger JSON endpoint.
71-
apiService.UseSwaggerUI(doc =>
72-
{
73-
doc.SwaggerEndpoint("/swagger/v1/swagger.json", "Virtual Client API (v1)");
74-
75-
// "Try it Out" only for GET methods.
76-
doc.SupportedSubmitMethods(SubmitMethod.Delete, SubmitMethod.Get, SubmitMethod.Head, SubmitMethod.Post, SubmitMethod.Put);
77-
doc.RoutePrefix = string.Empty;
78-
doc.ConfigObject.DefaultModelRendering = ModelRendering.Example;
79-
});
80-
8163
apiService.UseApiVersioning();
8264
apiService.UseMiddleware<ApiExceptionMiddleware>(dependencies.GetService<ILogger>());
8365
apiService.UseMvc();
@@ -147,34 +129,6 @@ private void ConfigureServices(IWebHostBuilder hostBuilder, IServiceCollection d
147129
options.AssumeDefaultVersionWhenUnspecified = true;
148130
options.DefaultApiVersion = new ApiVersion(1, 0);
149131
});
150-
151-
// Add OpenAPI/Swagger definition.
152-
// https://docs.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-3.1&tabs=visual-studio
153-
// https://github.com/domaindrivendev/Swashbuckle.AspNetCore
154-
// https://idratherbewriting.com/learnapidoc
155-
services.AddSwaggerGen(doc =>
156-
{
157-
doc.SwaggerDoc("v1", new OpenApiInfo
158-
{
159-
Version = "v1",
160-
Title = "Virtual Client API",
161-
Description = "Virtual Client REST API/service.",
162-
Contact = new OpenApiContact()
163-
{
164-
Name = "Virtual Client Team",
165-
Email = "[email protected]",
166-
Url = new Uri("https://microsoft.github.io/VirtualClient/")
167-
},
168-
License = new OpenApiLicense
169-
{
170-
Name = "API License",
171-
Url = new Uri("https://github.com/microsoft/VirtualClient/blob/main/LICENSE")
172-
},
173-
});
174-
175-
// All JSON input and output objects are expected to be in camel-case.
176-
doc.DescribeAllParametersInCamelCase();
177-
});
178132
});
179133
}
180134

src/VirtualClient/VirtualClient.Main/VirtualClient.Main.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
<!-- Global package dependency versions are defined in the Module.props for the solution. -->
1616
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="$(Microsoft_AspNetCore_Mvc_NewtonsoftJson_PackageVersion)" />
1717
<PackageReference Include="Microsoft.Win32.Registry" Version="$(Microsoft_Win32_Registry_PackageVersion)" />
18-
<PackageReference Include="Swashbuckle.AspNetCore" Version="$(Swashbuckle_AspNetCore_PackageVersion)" />
1918
<PackageReference Include="System.CommandLine" Version="$(System_CommandLine_PackageVersion)" />
2019
</ItemGroup>
2120

0 commit comments

Comments
 (0)