Skip to content

Commit ef36751

Browse files
author
Rakeshwar Reddy Kambaiahgari
committed
commit changes
1 parent fde4b63 commit ef36751

9 files changed

Lines changed: 40 additions & 33 deletions

File tree

src/VirtualClient/VirtualClient.Actions.UnitTests/AspNetBench/BombardierExecutorTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ public TestBombardierExecutor(IServiceCollection dependencies, IDictionary<strin
9797
set => base.PackageDirectory = value;
9898
}
9999

100-
public new string GetBombardierVersion(EventContext telemetryContext, CancellationToken cancellationToken)
100+
public new async Task<string> GetBombardierVersionAsync(EventContext telemetryContext, CancellationToken cancellationToken)
101101
{
102-
return base.GetBombardierVersion(telemetryContext, cancellationToken);
102+
return await base.GetBombardierVersionAsync(telemetryContext, cancellationToken);
103103
}
104104
}
105105
}

src/VirtualClient/VirtualClient.Actions.UnitTests/Wrk/WrkExecutorTest.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ public async Task WrkClientExecutorExecutesAsyncAsExpected(PlatformID platform,
569569
}
570570

571571
[Test]
572-
public void GetWrkVersionReturnsCorrectVersion()
572+
public async Task GetWrkVersionReturnsCorrectVersion()
573573
{
574574
this.mockFixture.Setup(PlatformID.Unix, Architecture.X64);
575575
TestWrkExecutor executor = new TestWrkExecutor(this.mockFixture);
@@ -584,7 +584,7 @@ public void GetWrkVersionReturnsCorrectVersion()
584584
.TrackProcesses()
585585
.SetupProcessOutput("--version", wrkOutput);
586586

587-
string actualVersion = executor.GetWrkVersion();
587+
string actualVersion = await executor.GetWrkVersionAsync();
588588

589589
Assert.AreEqual(expectedVersion, actualVersion);
590590
this.mockFixture.Tracking.AssertCommandsExecuted(true,
@@ -593,7 +593,7 @@ public void GetWrkVersionReturnsCorrectVersion()
593593
}
594594

595595
[Test]
596-
public void GetWrkVersion_ReturnsNull_WhenVersionCannotBeParsed()
596+
public async Task GetWrkVersion_ReturnsNull_WhenVersionCannotBeParsed()
597597
{
598598
this.mockFixture.Setup(PlatformID.Unix, Architecture.X64);
599599
TestWrkExecutor executor = new TestWrkExecutor(this.mockFixture);
@@ -606,7 +606,7 @@ public void GetWrkVersion_ReturnsNull_WhenVersionCannotBeParsed()
606606
.TrackProcesses()
607607
.SetupProcessOutput("--version", "Invalid output without version");
608608

609-
string version = executor.GetWrkVersion();
609+
string version = await executor.GetWrkVersionAsync();
610610
Assert.IsNull(version);
611611

612612
this.mockFixture.Tracking.AssertCommandsExecuted(true, "sudo bash .* --version");
@@ -648,9 +648,9 @@ public bool GetIsServerWarmedUp()
648648
return base.IsServerWarmedUp;
649649
}
650650

651-
public string GetWrkVersion()
651+
public async Task<string> GetWrkVersionAsync()
652652
{
653-
return base.GetWrkVersion(EventContext.None, CancellationToken.None);
653+
return await base.GetWrkVersionAsync(EventContext.None, CancellationToken.None);
654654
}
655655

656656
public void SetIsServerWarmedUp(bool value)

src/VirtualClient/VirtualClient.Actions/ASPNET/AspNetOrchardServerExecutor.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,13 +343,13 @@ private Task DeleteStateAsync(EventContext telemetryContext, CancellationToken c
343343
});
344344
}
345345

346-
private Task KillServerInstancesAsync(EventContext telemetryContext, CancellationToken cancellationToken)
346+
private async Task KillServerInstancesAsync(EventContext telemetryContext, CancellationToken cancellationToken)
347347
{
348348
this.Logger.LogTraceMessage($"{this.TypeName}.KillServerInstances");
349-
this.ExecuteCommandAsync("pkill", "OrchardCore", this.aspnetOrchardDirectory, telemetryContext, cancellationToken);
350-
this.ExecuteCommandAsync("fuser", $"-n tcp -k {this.ServerPort}", this.aspnetOrchardDirectory, telemetryContext, cancellationToken);
349+
await this.ExecuteCommandAsync("pkill", "OrchardCore", this.aspnetOrchardDirectory, telemetryContext, cancellationToken);
350+
await this.ExecuteCommandAsync("fuser", $"-n tcp -k {this.ServerPort}", this.aspnetOrchardDirectory, telemetryContext, cancellationToken);
351351

352-
return this.WaitAsync(TimeSpan.FromSeconds(3), cancellationToken);
352+
await this.WaitAsync(TimeSpan.FromSeconds(3), cancellationToken);
353353
}
354354

355355
private void StartServerInstances(EventContext telemetryContext, CancellationToken cancellationToken)

src/VirtualClient/VirtualClient.Actions/ASPNET/AspNetServerExecutor.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,15 +354,15 @@ private Task DeleteStateAsync(EventContext telemetryContext, CancellationToken c
354354
});
355355
}
356356

357-
private Task KillServerInstancesAsync(EventContext telemetryContext, CancellationToken cancellationToken)
357+
private async Task KillServerInstancesAsync(EventContext telemetryContext, CancellationToken cancellationToken)
358358
{
359359
this.Logger.LogTraceMessage($"{this.TypeName}.KillServerInstances");
360360

361-
this.ExecuteCommandAsync("pkill", "dotnet", this.aspnetBenchDirectory, telemetryContext, cancellationToken);
361+
await this.ExecuteCommandAsync("pkill", "dotnet", this.aspnetBenchDirectory, telemetryContext, cancellationToken);
362362

363-
this.ExecuteCommandAsync("fuser", $"-n tcp -k {this.ServerPort}", this.aspnetBenchDirectory, telemetryContext, cancellationToken);
363+
await this.ExecuteCommandAsync("fuser", $"-n tcp -k {this.ServerPort}", this.aspnetBenchDirectory, telemetryContext, cancellationToken);
364364

365-
return this.WaitAsync(TimeSpan.FromSeconds(3), cancellationToken);
365+
await this.WaitAsync(TimeSpan.FromSeconds(3), cancellationToken);
366366
}
367367

368368
private void StartServerInstances(EventContext telemetryContext, CancellationToken cancellationToken)

src/VirtualClient/VirtualClient.Actions/Bombardier/BombardierExecutor.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ protected async Task ExecuteWorkloadAsync(string commandArguments, string workin
416416

417417
if (!this.WarmUp)
418418
{
419-
this.CaptureMetrics(process, commandArguments, relatedContext, cancellationToken);
419+
await this.CaptureMetricsAsync(process, commandArguments, relatedContext, cancellationToken).ConfigureAwait(false);
420420
}
421421
}
422422
}
@@ -445,7 +445,7 @@ protected async Task ExecuteWorkloadAsync(string commandArguments, string workin
445445
/// <param name="telemetryContext">Provides context information that will be captured with telemetry events.</param>
446446
/// <param name="cancellationToken">A token that can be used to cancel the operation.</param>
447447
/// <returns>Bombardier Version</returns>
448-
protected string GetBombardierVersion(EventContext telemetryContext, CancellationToken cancellationToken)
448+
protected async Task<string> GetBombardierVersionAsync(EventContext telemetryContext, CancellationToken cancellationToken)
449449
{
450450
string bombardierPath = this.Combine(this.PackageDirectory, this.Platform == PlatformID.Unix ? "bombardier" : "bombardier.exe");
451451
string bombardierVersion = null;
@@ -458,11 +458,11 @@ protected string GetBombardierVersion(EventContext telemetryContext, Cancellatio
458458
string versionPattern = @"bombardier\s+(?:version\s+)?v?(\d+\.\d+\.\d+)";
459459
Regex versionRegex = new Regex(versionPattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
460460

461-
using (IProcessProxy process = this.ExecuteCommandAsync(bombardierPath, commandArguments, workingDirectory: this.PackageDirectory, telemetryContext, cancellationToken, runElevated: true).Result)
461+
using (IProcessProxy process = await this.ExecuteCommandAsync(bombardierPath, commandArguments, workingDirectory: this.PackageDirectory, telemetryContext, cancellationToken, runElevated: true).ConfigureAwait(false))
462462
{
463463
if (!cancellationToken.IsCancellationRequested)
464464
{
465-
this.LogProcessDetailsAsync(process, telemetryContext, "BombardierVersion", logToFile: true).Wait();
465+
await this.LogProcessDetailsAsync(process, telemetryContext, "BombardierVersion", logToFile: true).ConfigureAwait(false);
466466
string output = process.StandardOutput.ToString();
467467
Match match = versionRegex.Match(output);
468468

@@ -489,7 +489,7 @@ protected string GetBombardierVersion(EventContext telemetryContext, Cancellatio
489489
return bombardierVersion;
490490
}
491491

492-
private void CaptureMetrics(IProcessProxy workloadProcess, string commandArguments, EventContext context, CancellationToken cancellationToken)
492+
private async Task CaptureMetricsAsync(IProcessProxy workloadProcess, string commandArguments, EventContext context, CancellationToken cancellationToken)
493493
{
494494
if (!cancellationToken.IsCancellationRequested)
495495
{
@@ -511,7 +511,7 @@ private void CaptureMetrics(IProcessProxy workloadProcess, string commandArgumen
511511
}
512512
}
513513

514-
string bombardierVersion = this.GetBombardierVersion(telemetryContext, cancellationToken);
514+
string bombardierVersion = await this.GetBombardierVersionAsync(telemetryContext, cancellationToken).ConfigureAwait(false);
515515

516516
this.MetadataContract.AddForScenario(
517517
toolName: this.PackageName,

src/VirtualClient/VirtualClient.Actions/Nginx/NginxServerExecutor.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,17 @@ protected override void Dispose(bool disposing)
247247
{
248248
if (disposing)
249249
{
250-
Task.Run((Func<Task>)(async () =>
250+
try
251251
{
252-
await this.ResetNginxAsync(EventContext.None, CancellationToken.None).ConfigureAwait(false);
253-
})).Wait();
252+
Task.Run(async () =>
253+
{
254+
await this.ResetNginxAsync(EventContext.None, CancellationToken.None).ConfigureAwait(false);
255+
}).Wait(TimeSpan.FromSeconds(30));
256+
}
257+
catch (AggregateException)
258+
{
259+
// Best-effort cleanup during dispose; exceptions are intentionally swallowed.
260+
}
254261
}
255262
}
256263

src/VirtualClient/VirtualClient.Actions/Wrk/WrkExecutor.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ protected async Task ExecuteWorkloadAsync(string commandArguments, string workin
463463

464464
if (!this.WarmUp)
465465
{
466-
this.CaptureMetrics(process, commandArguments, this.EmitLatencySpectrum, relatedContext, cancellationToken);
466+
await this.CaptureMetricsAsync(process, commandArguments, this.EmitLatencySpectrum, relatedContext, cancellationToken).ConfigureAwait(false);
467467
}
468468
}
469469
}
@@ -492,7 +492,7 @@ protected async Task ExecuteWorkloadAsync(string commandArguments, string workin
492492
/// <param name="telemetryContext">Provides context information that will be captured with telemetry events.</param>
493493
/// <param name="cancellationToken">A token that can be used to cancel the operation.</param>
494494
/// <returns>Wrk Version</returns>
495-
protected string GetWrkVersion(EventContext telemetryContext, CancellationToken cancellationToken)
495+
protected async Task<string> GetWrkVersionAsync(EventContext telemetryContext, CancellationToken cancellationToken)
496496
{
497497
string wrkVersion = null;
498498

@@ -506,11 +506,11 @@ protected string GetWrkVersion(EventContext telemetryContext, CancellationToken
506506
string versionPattern = @"wrk\s(\d+\.\d+\.\d+)";
507507
Regex versionRegex = new Regex(versionPattern, RegexOptions.Compiled);
508508

509-
using (IProcessProxy process = this.ExecuteCommandAsync(command, commandArguments, workingDirectory: this.PackageDirectory, telemetryContext, cancellationToken, runElevated: true).Result)
509+
using (IProcessProxy process = await this.ExecuteCommandAsync(command, commandArguments, workingDirectory: this.PackageDirectory, telemetryContext, cancellationToken, runElevated: true).ConfigureAwait(false))
510510
{
511511
if (!cancellationToken.IsCancellationRequested)
512512
{
513-
this.LogProcessDetailsAsync(process, telemetryContext, "WrkVersion", logToFile: true).Wait();
513+
await this.LogProcessDetailsAsync(process, telemetryContext, "WrkVersion", logToFile: true).ConfigureAwait(false);
514514
string output = process.StandardOutput.ToString();
515515
Match match = versionRegex.Match(output);
516516

@@ -537,7 +537,7 @@ protected string GetWrkVersion(EventContext telemetryContext, CancellationToken
537537
return wrkVersion;
538538
}
539539

540-
private void CaptureMetrics(IProcessProxy workloadProcess, string commandArguments, bool emitLatencySpectrum, EventContext context, CancellationToken cancellationToken)
540+
private async Task CaptureMetricsAsync(IProcessProxy workloadProcess, string commandArguments, bool emitLatencySpectrum, EventContext context, CancellationToken cancellationToken)
541541
{
542542
if (!cancellationToken.IsCancellationRequested)
543543
{
@@ -559,7 +559,7 @@ private void CaptureMetrics(IProcessProxy workloadProcess, string commandArgumen
559559
}
560560
}
561561

562-
string wrkVersion = this.GetWrkVersion(telemetryContext, cancellationToken);
562+
string wrkVersion = await this.GetWrkVersionAsync(telemetryContext, cancellationToken).ConfigureAwait(false);
563563

564564
this.MetadataContract.AddForScenario(
565565
toolName: this.PackageName,

src/VirtualClient/VirtualClient.Actions/Wrk/WrkMetricParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public WrkMetricParser(string resultsText)
4343
/// <returns></returns>
4444
public override IList<Metric> Parse()
4545
{
46-
return this.Parse();
46+
return this.Parse(emitLatencySpectrum: true);
4747
}
4848

4949
/// <summary>

src/VirtualClient/VirtualClient.Main/profiles/PERF-WEB-ASPNET-TEJSON-WRK.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"PackageName": "aspnetbenchmarks",
3737
"DotNetSdkPackageName": "dotnetsdk",
3838
"TargetFramework": "$.Parameters.TargetFramework",
39-
"Port": "$.Parameters.Port"
39+
"ServerPort": "$.Parameters.Port"
4040
}
4141
},
4242
{

0 commit comments

Comments
 (0)