Skip to content

Commit 8e3f86f

Browse files
authored
Merge branch 'microsoft:main' into Recording-Redis-Version
2 parents 5963b3b + 6d887a5 commit 8e3f86f

5 files changed

Lines changed: 57 additions & 9 deletions

File tree

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.0.19
1+
2.0.21

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

src/VirtualClient/VirtualClient.Core/Logging/SummaryFile/SummaryFileLogger.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ public SummaryFileLogger(string filePath, IAsyncPolicy retryPolicy = null)
5757
if (string.IsNullOrWhiteSpace(filePath))
5858
{
5959
PlatformSpecifics tempPlatformSpecifics = new PlatformSpecifics(Environment.OSVersion.Platform, RuntimeInformation.ProcessArchitecture);
60-
filePath = tempPlatformSpecifics.Combine(tempPlatformSpecifics.LogsDirectory, "summary.txt");
60+
ISystemInfo systemInfo = new SystemManagement();
61+
string experimentId = systemInfo.ExperimentId;
62+
string suffix = string.IsNullOrEmpty(experimentId) ? string.Empty : $"-{experimentId}";
63+
filePath = tempPlatformSpecifics.Combine(tempPlatformSpecifics.LogsDirectory, $"summary{suffix}.txt");
6164
}
6265

6366
this.filePath = filePath;

src/VirtualClient/VirtualClient.Monitors/FileUploadMonitor.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ await this.Logger.LogMessageAsync($"{this.TypeName}.ProcessSummaryFileUploads",
134134
// Upload the workload summary logs (e.g. metrics.csv) before exiting. We do this at the very end. Same as before, we do not
135135
// honor the cancellation token until ALL files have been successfully processed.
136136
await this.UploadCsvSummaryFilesAsync(blobManager, relatedContext);
137+
138+
// Upload specific summary.txt at root level of logs directory.
139+
await this.UploadSummaryFileAsync(blobManager, relatedContext);
137140
});
138141

139142
break;
@@ -233,6 +236,48 @@ private async Task<bool> UploadFilesAsync(IBlobManager blobManager, EventContext
233236
return filesFound;
234237
}
235238

239+
private async Task UploadSummaryFileAsync(IBlobManager blobManager, EventContext telemetryContext)
240+
{
241+
try
242+
{
243+
string suffix = string.IsNullOrEmpty(this.ExperimentId) ? string.Empty : $"-{this.ExperimentId}";
244+
string summaryTxtFileLocation = Path.Combine(this.PlatformSpecifics.LogsDirectory, $"summary{suffix}.txt");
245+
bool summaryTxtFileExists = this.fileSystem.File.Exists(summaryTxtFileLocation);
246+
telemetryContext
247+
.AddContext(nameof(summaryTxtFileLocation), summaryTxtFileLocation)
248+
.AddContext(nameof(summaryTxtFileExists), summaryTxtFileExists);
249+
250+
if (summaryTxtFileExists)
251+
{
252+
try
253+
{
254+
FileUploadDescriptor descriptor = this.CreateFileUploadDescriptor(
255+
new FileContext(
256+
this.fileSystem.FileInfo.New(summaryTxtFileLocation),
257+
"text/plain",
258+
Encoding.UTF8.WebName,
259+
this.ExperimentId,
260+
this.AgentId));
261+
262+
await this.UploadFileAsync(blobManager, this.fileSystem, descriptor, CancellationToken.None);
263+
}
264+
catch (IOException exc) when (exc.Message.Contains("being used by another process", StringComparison.OrdinalIgnoreCase))
265+
{
266+
// It is common that there will be read/write access errors at certain times while
267+
// upload request files are being created at the same time as attempts to read.
268+
}
269+
catch (Exception exc)
270+
{
271+
this.Logger.LogErrorMessage(exc, telemetryContext, LogLevel.Warning);
272+
}
273+
}
274+
}
275+
catch (Exception exc)
276+
{
277+
this.Logger.LogErrorMessage(exc, telemetryContext, LogLevel.Error);
278+
}
279+
}
280+
236281
private async Task UploadCsvSummaryFilesAsync(IBlobManager blobManager, EventContext telemetryContext)
237282
{
238283
try

0 commit comments

Comments
 (0)