Skip to content

Commit b4e91fc

Browse files
authored
Users/vdeepar/update metrics (#520)
* adding openssl version to metadata dependencies * trim version value rxd from stdout * adding version to logMetrics * fix Logging and add toolversion in metadata scenario * set env variable before invoking openssl version command * make getversion as async and add unit test * remove printing to console from unittest * adding AddForScenario as it was * fix failing unit test due to StandardOutput overwrite * async fix to captureMetrics * update Function name to include Async keyword * fixing parameter order to getopensslversionasync function
1 parent b465b54 commit b4e91fc

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/VirtualClient/VirtualClient.Actions.UnitTests/OpenSSL/OpenSslExecutorTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ await executor.ExecuteAsync(CancellationToken.None)
289289
}
290290

291291
[Test]
292-
public async Task OpenSslExecutorExecutesGetOpensslVersion()
292+
public async Task OpenSslExecutorExecutesGetOpensslVersionAsync()
293293
{
294294
this.SetupDefaultBehaviors();
295295
this.SetupOpensslVersionBehavior();
@@ -300,7 +300,7 @@ public async Task OpenSslExecutorExecutesGetOpensslVersion()
300300
await executor.ExecuteAsync(CancellationToken.None)
301301
.ConfigureAwait(false);
302302

303-
var messages = this.fixture.Logger.MessagesLogged($"{nameof(OpenSslExecutor)}.GetOpenSslVersion");
303+
var messages = this.fixture.Logger.MessagesLogged($"{nameof(OpenSslExecutor)}.GetOpenSslVersionAsync");
304304
Assert.IsNotEmpty(messages);
305305
Assert.IsTrue(messages.All(msg => (msg.Item3 as EventContext).Properties["opensslVersion"].ToString() == "OpenSSL 3.5.0 8 Apr 2025 (Library: OpenSSL 3.5.0 8 Apr 2025)"));
306306
}

src/VirtualClient/VirtualClient.Actions/OpenSSL/OpenSslExecutor.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ await this.InitializeWorkloadToolsetsAsync(cancellationToken)
9494
/// <summary>
9595
/// Gets openssl version by running openssl version command.
9696
/// </summary>
97-
private async Task GetOpenSslVersion(CancellationToken cancellationToken, string toolCommand)
97+
private async Task GetOpenSslVersionAsync(string toolCommand, CancellationToken cancellationToken)
9898
{
9999
// The OpenSSL version is not available in the workload output. We need to run a separate command to get the version.
100100
// The command 'openssl version' will return the version of OpenSSL installed on the system.
@@ -115,7 +115,7 @@ private async Task GetOpenSslVersion(CancellationToken cancellationToken, string
115115
}
116116

117117
this.MetadataContract.Add("OpenSSLVersion", opensslVersion, MetadataContractCategory.Dependencies);
118-
this.Logger.LogMessage($"{nameof(OpenSslExecutor)}.GetOpenSslVersion", LogLevel.Information, EventContext.Persisted().AddContext("opensslVersion", opensslVersion));
118+
this.Logger.LogMessage($"{nameof(OpenSslExecutor)}.GetOpenSslVersionAsync", LogLevel.Information, EventContext.Persisted().AddContext("opensslVersion", opensslVersion));
119119

120120
this.MetadataContract.AddForScenario(
121121
"OpenSSL Speed",
@@ -126,14 +126,14 @@ private async Task GetOpenSslVersion(CancellationToken cancellationToken, string
126126

127127
}
128128

129-
private void CaptureMetrics(IProcessProxy workloadProcess, string commandArguments, EventContext telemetryContext, CancellationToken cancellationToken)
129+
private async Task CaptureMetricsAsync(IProcessProxy workloadProcess, string commandArguments, EventContext telemetryContext, CancellationToken cancellationToken)
130130
{
131131
if (workloadProcess.ExitCode == 0)
132132
{
133133
try
134134
{
135135
// Retrieve OpenSSL version
136-
this.GetOpenSslVersion(cancellationToken, workloadProcess.FullCommand());
136+
await this.GetOpenSslVersionAsync(workloadProcess.FullCommand(), cancellationToken);
137137

138138
this.MetadataContract.Apply(telemetryContext);
139139

@@ -189,7 +189,7 @@ private Task ExecuteWorkloadAsync(EventContext telemetryContext, CancellationTok
189189
await this.LogProcessDetailsAsync(process, telemetryContext, "OpenSSL", logToFile: true);
190190

191191
process.ThrowIfWorkloadFailed();
192-
this.CaptureMetrics(process, commandArguments, telemetryContext, cancellationToken);
192+
await this.CaptureMetricsAsync(process, commandArguments, telemetryContext, cancellationToken);
193193
}
194194
}
195195
finally

0 commit comments

Comments
 (0)