diff --git a/.pipelines/azure-pipelines-linux.yml b/.pipelines/azure-pipelines-linux.yml index 4e602ce5bb..6153c97acd 100644 --- a/.pipelines/azure-pipelines-linux.yml +++ b/.pipelines/azure-pipelines-linux.yml @@ -16,7 +16,7 @@ resources: options: --entrypoint="" variables: - VcVersion : 1.11.6 + VcVersion : 1.11.7 ROOT: $(Build.SourcesDirectory) CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)] # needed for onebranch.pipeline.version task https://aka.ms/obpipelines/versioning ENABLE_PRS_DELAYSIGN: 1 @@ -42,7 +42,7 @@ stages: displayName: 'Allow scripts to be executable on Linux' # Ensure the artifact output/bin/obj directories are clean. - # - script: $(Build.SourcesDirectory)/clean.cmd + # - script: $(Build.SourcesDirectory)/clean.cmd # displayName: 'Clean Output Directories' # Build the repo. diff --git a/.pipelines/azure-pipelines.yml b/.pipelines/azure-pipelines.yml index d5680df981..439a98df51 100644 --- a/.pipelines/azure-pipelines.yml +++ b/.pipelines/azure-pipelines.yml @@ -18,7 +18,7 @@ pool: vmImage: windows-latest variables: - VcVersion : 1.11.6 + VcVersion : 1.11.7 ROOT: $(Build.SourcesDirectory) CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)] # needed for onebranch.pipeline.version task https://aka.ms/obpipelines/versioning ENABLE_PRS_DELAYSIGN: 1 diff --git a/src/VirtualClient/VirtualClient.Actions/3DMark/ThreeDMarkExecutor.cs b/src/VirtualClient/VirtualClient.Actions/3DMark/ThreeDMarkExecutor.cs index 438cb715cb..96792358c5 100644 --- a/src/VirtualClient/VirtualClient.Actions/3DMark/ThreeDMarkExecutor.cs +++ b/src/VirtualClient/VirtualClient.Actions/3DMark/ThreeDMarkExecutor.cs @@ -244,65 +244,68 @@ private Task ExecuteWorkloadAsync(EventContext telemetryContext, CancellationTok } } - // Run Workload DateTime startTime = DateTime.UtcNow; - foreach (string definition in this.Definitions) + using (BackgroundOperations profiling = BackgroundOperations.BeginProfiling(this, cancellationToken)) { - this.OutFileName = $"{DateTimeOffset.Now.ToUnixTimeSeconds()}.out"; - - // Workload execution - string arguments = this.GenerateCommandArguments(definition); - string commandArguments = $"{baseArg} {this.ExecutablePath} {arguments}"; - - using (IProcessProxy process = this.systemManagement.ProcessManager.CreateProcess(psexec, commandArguments, this.psexecDir)) + // Run Workload + foreach (string definition in this.Definitions) { - this.CleanupTasks.Add(() => process.SafeKill()); + this.OutFileName = $"{DateTimeOffset.Now.ToUnixTimeSeconds()}.out"; + + // Workload execution + string arguments = this.GenerateCommandArguments(definition); + string commandArguments = $"{baseArg} {this.ExecutablePath} {arguments}"; - try + using (IProcessProxy process = this.systemManagement.ProcessManager.CreateProcess(psexec, commandArguments, this.psexecDir)) { - await process.StartAndWaitAsync(cancellationToken).ConfigureAwait(false); + this.CleanupTasks.Add(() => process.SafeKill()); - if (!cancellationToken.IsCancellationRequested) + try { - await this.LogProcessDetailsAsync(process, telemetryContext); - process.ThrowIfErrored(ProcessProxy.DefaultSuccessCodes, errorReason: ErrorReason.WorkloadFailed); + await process.StartAndWaitAsync(cancellationToken).ConfigureAwait(false); + + if (!cancellationToken.IsCancellationRequested) + { + await this.LogProcessDetailsAsync(process, telemetryContext); + process.ThrowIfErrored(ProcessProxy.DefaultSuccessCodes, errorReason: ErrorReason.WorkloadFailed); + } } - } - finally - { - if (!process.HasExited) + finally { - process.Kill(); + if (!process.HasExited) + { + process.Kill(); + } } } - } - // Result Preparation - string commandArguments2 = $"{baseArg} {this.ExecutablePath} --in={this.OutFileName} --export=result.xml"; - using (IProcessProxy process = this.systemManagement.ProcessManager.CreateProcess(psexec, commandArguments2, this.psexecDir)) - { - this.CleanupTasks.Add(() => process.SafeKill()); - - try + // Result Preparation + string commandArguments2 = $"{baseArg} {this.ExecutablePath} --in={this.OutFileName} --export=result.xml"; + using (IProcessProxy process = this.systemManagement.ProcessManager.CreateProcess(psexec, commandArguments2, this.psexecDir)) { - await process.StartAndWaitAsync(cancellationToken).ConfigureAwait(false); + this.CleanupTasks.Add(() => process.SafeKill()); - if (!cancellationToken.IsCancellationRequested) + try { - await this.LogProcessDetailsAsync(process, telemetryContext); - process.ThrowIfErrored(ProcessProxy.DefaultSuccessCodes, errorReason: ErrorReason.WorkloadFailed); - foreach (Metric metric in this.CaptureResults(process, commandArguments, definition, telemetryContext)) + await process.StartAndWaitAsync(cancellationToken).ConfigureAwait(false); + + if (!cancellationToken.IsCancellationRequested) { - metrics.Add(metric); + await this.LogProcessDetailsAsync(process, telemetryContext); + process.ThrowIfErrored(ProcessProxy.DefaultSuccessCodes, errorReason: ErrorReason.WorkloadFailed); + foreach (Metric metric in this.CaptureResults(process, commandArguments, definition, telemetryContext)) + { + metrics.Add(metric); + } } } - } - finally - { - if (!process.HasExited) + finally { - process.Kill(); + if (!process.HasExited) + { + process.Kill(); + } } } } diff --git a/src/VirtualClient/VirtualClient.Actions/CoreMark/CoreMarkProExecutor.cs b/src/VirtualClient/VirtualClient.Actions/CoreMark/CoreMarkProExecutor.cs index 04b0271747..bf2a3d58f4 100644 --- a/src/VirtualClient/VirtualClient.Actions/CoreMark/CoreMarkProExecutor.cs +++ b/src/VirtualClient/VirtualClient.Actions/CoreMark/CoreMarkProExecutor.cs @@ -100,46 +100,49 @@ protected override async Task ExecuteAsync(EventContext telemetryContext, Cancel DateTime startTime = DateTime.UtcNow; string output = string.Empty; - switch (this.Platform) + using (BackgroundOperations profiling = BackgroundOperations.BeginProfiling(this, cancellationToken)) { - case PlatformID.Unix: - using (IProcessProxy process = await this.ExecuteCommandAsync("make", commandArguments, this.CoreMarkProDirectory, telemetryContext, cancellationToken)) - { - if (!cancellationToken.IsCancellationRequested) + switch (this.Platform) + { + case PlatformID.Unix: + using (IProcessProxy process = await this.ExecuteCommandAsync("make", commandArguments, this.CoreMarkProDirectory, telemetryContext, cancellationToken)) { - if (process.IsErrored()) + if (!cancellationToken.IsCancellationRequested) { + if (process.IsErrored()) + { + await this.LogProcessDetailsAsync(process, telemetryContext, "CoreMark Pro", logToFile: true); + process.ThrowIfWorkloadFailed(); + } + await this.LogProcessDetailsAsync(process, telemetryContext, "CoreMark Pro", logToFile: true); - process.ThrowIfWorkloadFailed(); + output = process.StandardOutput.ToString(); } - - await this.LogProcessDetailsAsync(process, telemetryContext, "CoreMark Pro", logToFile: true); - output = process.StandardOutput.ToString(); } - } - break; + break; - case PlatformID.Win32NT: - DependencyPath cygwinPackage = await this.packageManager.GetPackageAsync("cygwin", CancellationToken.None) - .ConfigureAwait(false); + case PlatformID.Win32NT: + DependencyPath cygwinPackage = await this.packageManager.GetPackageAsync("cygwin", CancellationToken.None) + .ConfigureAwait(false); - using (IProcessProxy process = await this.ExecuteCygwinBashAsync($"make {commandArguments}", this.CoreMarkProDirectory, cygwinPackage.Path, telemetryContext, cancellationToken)) - { - if (!cancellationToken.IsCancellationRequested) + using (IProcessProxy process = await this.ExecuteCygwinBashAsync($"make {commandArguments}", this.CoreMarkProDirectory, cygwinPackage.Path, telemetryContext, cancellationToken)) { - if (process.IsErrored()) + if (!cancellationToken.IsCancellationRequested) { + if (process.IsErrored()) + { + await this.LogProcessDetailsAsync(process, telemetryContext, "CoreMark Pro", logToFile: true); + process.ThrowIfWorkloadFailed(); + } + await this.LogProcessDetailsAsync(process, telemetryContext, "CoreMark Pro", logToFile: true); - process.ThrowIfWorkloadFailed(); + output = process.StandardOutput.ToString(); } - - await this.LogProcessDetailsAsync(process, telemetryContext, "CoreMark Pro", logToFile: true); - output = process.StandardOutput.ToString(); } - } - break; + break; + } } this.MetadataContract.AddForScenario( diff --git a/src/VirtualClient/VirtualClient.Actions/DCGMI/DCGMIExecutor.cs b/src/VirtualClient/VirtualClient.Actions/DCGMI/DCGMIExecutor.cs index 19c8477606..ffb7d8d6eb 100644 --- a/src/VirtualClient/VirtualClient.Actions/DCGMI/DCGMIExecutor.cs +++ b/src/VirtualClient/VirtualClient.Actions/DCGMI/DCGMIExecutor.cs @@ -296,98 +296,107 @@ await this.Logger.LogMessageAsync($"{typeof(TExecutor).Name}.ExecuteProcess", te private async Task ExecuteDCGMIDiagnosticsSubsystemAsync(EventContext telemetryContext, CancellationToken cancellationToken) { - string command = $"dcgmi diag -r {this.Level} -j"; - DateTime startTime = DateTime.UtcNow; - - string results = await this.ExecuteCommandAsync(command, Environment.CurrentDirectory, cancellationToken) - .ConfigureAwait(false); + using (BackgroundOperations profiling = BackgroundOperations.BeginProfiling(this, cancellationToken)) + { + string command = $"dcgmi diag -r {this.Level} -j"; + DateTime startTime = DateTime.UtcNow; - Console.WriteLine("results are " + results); + string results = await this.ExecuteCommandAsync(command, Environment.CurrentDirectory, cancellationToken) + .ConfigureAwait(false); - this.CaptureWorkloadResultsAsync(results, command, startTime, DateTime.UtcNow, telemetryContext, cancellationToken); + this.CaptureWorkloadResultsAsync(results, command, startTime, DateTime.UtcNow, telemetryContext, cancellationToken); + } } private async Task ExecuteDCGMIDiscoverySubsystemAsync(EventContext telemetryContext, CancellationToken cancellationToken) { - string command = "dcgmi discovery -l"; - DateTime startTime = DateTime.UtcNow; - - string results = await this.ExecuteCommandAsync(command, Environment.CurrentDirectory, cancellationToken) - .ConfigureAwait(false); + using (BackgroundOperations profiling = BackgroundOperations.BeginProfiling(this, cancellationToken)) + { + string command = "dcgmi discovery -l"; + DateTime startTime = DateTime.UtcNow; - Console.WriteLine("results are " + results); + string results = await this.ExecuteCommandAsync(command, Environment.CurrentDirectory, cancellationToken) + .ConfigureAwait(false); - this.CaptureWorkloadResultsAsync(results, command, startTime, DateTime.UtcNow, telemetryContext, cancellationToken); + this.CaptureWorkloadResultsAsync(results, command, startTime, DateTime.UtcNow, telemetryContext, cancellationToken); + } } private async Task ExecuteDCGMIFieldGroupSubsystemAsync(EventContext telemetryContext, CancellationToken cancellationToken) { - string command = "dcgmi fieldgroup -l"; - DateTime startTime = DateTime.UtcNow; - string results = await this.ExecuteCommandAsync(command, Environment.CurrentDirectory, cancellationToken) - .ConfigureAwait(false); - - Console.WriteLine("results are " + results); + using (BackgroundOperations profiling = BackgroundOperations.BeginProfiling(this, cancellationToken)) + { + string command = "dcgmi fieldgroup -l"; + DateTime startTime = DateTime.UtcNow; + string results = await this.ExecuteCommandAsync(command, Environment.CurrentDirectory, cancellationToken) + .ConfigureAwait(false); - this.CaptureWorkloadResultsAsync(results, command, startTime, DateTime.UtcNow, telemetryContext, cancellationToken); + this.CaptureWorkloadResultsAsync(results, command, startTime, DateTime.UtcNow, telemetryContext, cancellationToken); + } } private async Task ExecuteDCGMIGroupSubsystemAsync(EventContext telemetryContext, CancellationToken cancellationToken) { - string command = "dcgmi group -l"; - DateTime startTime = DateTime.UtcNow; - string results = await this.ExecuteCommandAsync(command, Environment.CurrentDirectory, cancellationToken) - .ConfigureAwait(false); - - Console.WriteLine("results are " + results); + using (BackgroundOperations profiling = BackgroundOperations.BeginProfiling(this, cancellationToken)) + { + string command = "dcgmi group -l"; + DateTime startTime = DateTime.UtcNow; + string results = await this.ExecuteCommandAsync(command, Environment.CurrentDirectory, cancellationToken) + .ConfigureAwait(false); - this.CaptureWorkloadResultsAsync(results, command, startTime, DateTime.UtcNow, telemetryContext, cancellationToken); + this.CaptureWorkloadResultsAsync(results, command, startTime, DateTime.UtcNow, telemetryContext, cancellationToken); + } } private async Task ExecuteDCGMIHealthSubsystemAsync(EventContext telemetryContext, CancellationToken cancellationToken) { - string command = "dcgmi health -c -j"; - DateTime startTime = DateTime.UtcNow; - string results = await this.ExecuteCommandAsync(command, Environment.CurrentDirectory, cancellationToken) - .ConfigureAwait(false); - - Console.WriteLine("results are " + results); + using (BackgroundOperations profiling = BackgroundOperations.BeginProfiling(this, cancellationToken)) + { + string command = "dcgmi health -c -j"; + DateTime startTime = DateTime.UtcNow; + string results = await this.ExecuteCommandAsync(command, Environment.CurrentDirectory, cancellationToken) + .ConfigureAwait(false); - this.CaptureWorkloadResultsAsync(results, command, startTime, DateTime.UtcNow, telemetryContext, cancellationToken); + this.CaptureWorkloadResultsAsync(results, command, startTime, DateTime.UtcNow, telemetryContext, cancellationToken); + } } private async Task ExecuteDCGMIModulesSubsystemAsync(EventContext telemetryContext, CancellationToken cancellationToken) { - string command = "dcgmi modules -l"; - DateTime startTime = DateTime.UtcNow; - string results = await this.ExecuteCommandAsync(command, Environment.CurrentDirectory, cancellationToken) - .ConfigureAwait(false); - - Console.WriteLine("results are " + results); + using (BackgroundOperations profiling = BackgroundOperations.BeginProfiling(this, cancellationToken)) + { + string command = "dcgmi modules -l"; + DateTime startTime = DateTime.UtcNow; + string results = await this.ExecuteCommandAsync(command, Environment.CurrentDirectory, cancellationToken) + .ConfigureAwait(false); - this.CaptureWorkloadResultsAsync(results, command, startTime, DateTime.UtcNow, telemetryContext, cancellationToken); + this.CaptureWorkloadResultsAsync(results, command, startTime, DateTime.UtcNow, telemetryContext, cancellationToken); + } } private async Task ExecuteDCGMIProfTesterSubsystemAsync(EventContext telemetryContext, CancellationToken cancellationToken) { - List> tasksList = new List>(); - string dcgmproftestercommand = $"/usr/bin/dcgmproftester11 --no-dcgm-validation -t {this.FieldIDProftester} -d 10"; - string dmoncommand = $"dcgmi dmon -e {this.ListOfFieldIDsDmon} -c 15"; - DateTime startTime = DateTime.UtcNow; + using (BackgroundOperations profiling = BackgroundOperations.BeginProfiling(this, cancellationToken)) + { + List> tasksList = new List>(); + string dcgmproftestercommand = $"/usr/bin/dcgmproftester11 --no-dcgm-validation -t {this.FieldIDProftester} -d 10"; + string dmoncommand = $"dcgmi dmon -e {this.ListOfFieldIDsDmon} -c 15"; + DateTime startTime = DateTime.UtcNow; - tasksList.Add(Task.Run(async () => await this.ExecuteCommandAsync(dcgmproftestercommand, Environment.CurrentDirectory, cancellationToken) - .ConfigureAwait(false))); + tasksList.Add(Task.Run(async () => await this.ExecuteCommandAsync(dcgmproftestercommand, Environment.CurrentDirectory, cancellationToken) + .ConfigureAwait(false))); - tasksList.Add(Task.Run(async () => await this.ExecuteCommandAsync(dmoncommand, Environment.CurrentDirectory, cancellationToken) - .ConfigureAwait(false))); + tasksList.Add(Task.Run(async () => await this.ExecuteCommandAsync(dmoncommand, Environment.CurrentDirectory, cancellationToken) + .ConfigureAwait(false))); - string[] outputresults = await Task.WhenAll(tasksList); + string[] outputresults = await Task.WhenAll(tasksList); - string dcgmiproftesterresults = outputresults[0]; - string dcgmidmonresults = outputresults[1]; + string dcgmiproftesterresults = outputresults[0]; + string dcgmidmonresults = outputresults[1]; - this.CaptureDmonResultsAsync(dcgmidmonresults, dmoncommand, this.StartTime, DateTime.Now, telemetryContext, cancellationToken); - this.CaptureWorkloadResultsAsync(dcgmiproftesterresults, dcgmproftestercommand, startTime, DateTime.UtcNow, telemetryContext, cancellationToken); + this.CaptureDmonResultsAsync(dcgmidmonresults, dmoncommand, this.StartTime, DateTime.Now, telemetryContext, cancellationToken); + this.CaptureWorkloadResultsAsync(dcgmiproftesterresults, dcgmproftestercommand, startTime, DateTime.UtcNow, telemetryContext, cancellationToken); + } } private void CaptureDmonResultsAsync(string results, string commandArguments, DateTime startTime, DateTime endTime, EventContext telemetryContext, CancellationToken cancellationToken) diff --git a/src/VirtualClient/VirtualClient.Actions/HPLinpack/HPLinpackExecutor.cs b/src/VirtualClient/VirtualClient.Actions/HPLinpack/HPLinpackExecutor.cs index 992bca0bf6..8e374347b3 100644 --- a/src/VirtualClient/VirtualClient.Actions/HPLinpack/HPLinpackExecutor.cs +++ b/src/VirtualClient/VirtualClient.Actions/HPLinpack/HPLinpackExecutor.cs @@ -167,7 +167,7 @@ protected override async Task InitializeAsync(EventContext telemetryContext, Can { await this.EvaluateParametersAsync(cancellationToken); this.ThrowIfPlatformIsNotSupported(); - await this.CheckDistroSupportAsync(telemetryContext, cancellationToken).ConfigureAwait(false); + await this.CheckDistroSupportAsync(telemetryContext, cancellationToken); this.coreCount = this.cpuInfo.LogicalCoreCount; MemoryInfo memoryInfo = await this.systemManagement.GetMemoryInfoAsync(CancellationToken.None); @@ -175,23 +175,16 @@ protected override async Task InitializeAsync(EventContext telemetryContext, Can this.ValidateParameters(); - DependencyPath workloadPackage = await this.packageManager.GetPlatformSpecificPackageAsync(this.PackageName, this.Platform, this.CpuArchitecture, cancellationToken) - .ConfigureAwait(false); + DependencyPath workloadPackage = await this.packageManager.GetPlatformSpecificPackageAsync(this.PackageName, this.Platform, this.CpuArchitecture, cancellationToken); this.HPLDirectory = workloadPackage.Path; - await this.ConfigurePerformanceLibrary(telemetryContext, cancellationToken).ConfigureAwait(false); - - await this.DeleteFileAsync(this.PlatformSpecifics.Combine(this.HPLDirectory, this.makeFileName)) - .ConfigureAwait(false); - - await this.DeleteFileAsync(this.PlatformSpecifics.Combine(this.HPLDirectory, "setup", this.makeFileName)) - .ConfigureAwait(false); + await this.ConfigurePerformanceLibrary(telemetryContext, cancellationToken); + await this.DeleteFileAsync(this.PlatformSpecifics.Combine(this.HPLDirectory, this.makeFileName)); + await this.DeleteFileAsync(this.PlatformSpecifics.Combine(this.HPLDirectory, "setup", this.makeFileName)); await this.ExecuteCommandAsync("bash", "-c \"source make_generic\"", this.PlatformSpecifics.Combine(this.HPLDirectory, $"setup"), telemetryContext, cancellationToken, runElevated: true); - - await this.ConfigureMakeFileAsync(telemetryContext, cancellationToken).ConfigureAwait(false); - + await this.ConfigureMakeFileAsync(telemetryContext, cancellationToken); await this.ExecuteCommandAsync("ln", $"-s {this.PlatformSpecifics.Combine(this.HPLDirectory, $"setup", this.makeFileName)} {this.makeFileName}", this.HPLDirectory, telemetryContext, cancellationToken); } diff --git a/src/VirtualClient/VirtualClient.Actions/Memcached/MemcachedServerExecutor.cs b/src/VirtualClient/VirtualClient.Actions/Memcached/MemcachedServerExecutor.cs index 76d4da7942..d8452f1f70 100644 --- a/src/VirtualClient/VirtualClient.Actions/Memcached/MemcachedServerExecutor.cs +++ b/src/VirtualClient/VirtualClient.Actions/Memcached/MemcachedServerExecutor.cs @@ -182,15 +182,18 @@ protected override Task ExecuteAsync(EventContext telemetryContext, Cancellation if (this.IsMultiRoleLayout()) { - await Task.WhenAny(this.serverProcesses); - - // A cancellation is request, then we allow each of the server instances - // to gracefully exit. If a cancellation was not requested, it means that one - // or more of the server instances exited and we will want to allow the component - // to start over restarting the servers. - if (cancellationToken.IsCancellationRequested) + using (BackgroundOperations profiling = BackgroundOperations.BeginProfiling(this, cancellationToken)) { - await Task.WhenAll(this.serverProcesses); + await Task.WhenAny(this.serverProcesses); + + // A cancellation is request, then we allow each of the server instances + // to gracefully exit. If a cancellation was not requested, it means that one + // or more of the server instances exited and we will want to allow the component + // to start over restarting the servers. + if (cancellationToken.IsCancellationRequested) + { + await Task.WhenAll(this.serverProcesses); + } } } } diff --git a/src/VirtualClient/VirtualClient.Actions/PostgreSQL/PostgreSQLClientExecutor.cs b/src/VirtualClient/VirtualClient.Actions/PostgreSQL/PostgreSQLClientExecutor.cs index ca5c607d50..0840f9c339 100644 --- a/src/VirtualClient/VirtualClient.Actions/PostgreSQL/PostgreSQLClientExecutor.cs +++ b/src/VirtualClient/VirtualClient.Actions/PostgreSQL/PostgreSQLClientExecutor.cs @@ -86,82 +86,85 @@ await this.ServerApiClient.PollForExpectedStateAsync( await this.Logger.LogMessageAsync($"{this.TypeName}.ExecuteWorkload", telemetryContext, async () => { - DateTime startTime = DateTime.UtcNow; - - string results = string.Empty; - if (this.Platform == PlatformID.Unix) + using (BackgroundOperations profiling = BackgroundOperations.BeginProfiling(this, cancellationToken)) { - string command = "bash"; - string commandArguments = $"-c \"{this.Combine(this.HammerDBPackagePath, "hammerdbcli")} auto {PostgreSQLServerExecutor.RunTransactionsTclName}\""; - - this.MetadataContract.AddForScenario( - "HammerDB", - $"{command} {commandArguments}", - toolVersion: null); - - this.MetadataContract.Apply(telemetryContext); - - using (IProcessProxy process = await this.ExecuteCommandAsync( - command, - commandArguments, - this.HammerDBPackagePath, - telemetryContext, - cancellationToken)) + DateTime startTime = DateTime.UtcNow; + + string results = string.Empty; + if (this.Platform == PlatformID.Unix) { - if (!cancellationToken.IsCancellationRequested) + string command = "bash"; + string commandArguments = $"-c \"{this.Combine(this.HammerDBPackagePath, "hammerdbcli")} auto {PostgreSQLServerExecutor.RunTransactionsTclName}\""; + + this.MetadataContract.AddForScenario( + "HammerDB", + $"{command} {commandArguments}", + toolVersion: null); + + this.MetadataContract.Apply(telemetryContext); + + using (IProcessProxy process = await this.ExecuteCommandAsync( + command, + commandArguments, + this.HammerDBPackagePath, + telemetryContext, + cancellationToken)) { - await this.LogProcessDetailsAsync(process, telemetryContext, "PostgreSQL", logToFile: true); - process.ThrowIfWorkloadFailed(); + if (!cancellationToken.IsCancellationRequested) + { + await this.LogProcessDetailsAsync(process, telemetryContext, "PostgreSQL", logToFile: true); + process.ThrowIfWorkloadFailed(); - results = process.StandardOutput.ToString(); + results = process.StandardOutput.ToString(); + } } } - } - else if (this.Platform == PlatformID.Win32NT) - { - Action setEnvironmentVariables = (process) => + else if (this.Platform == PlatformID.Win32NT) { - string existingPath = process.StartInfo.EnvironmentVariables[EnvironmentVariable.PATH]; - - process.StartInfo.EnvironmentVariables[EnvironmentVariable.PATH] = string.Join(';', new string[] + Action setEnvironmentVariables = (process) => { + string existingPath = process.StartInfo.EnvironmentVariables[EnvironmentVariable.PATH]; + + process.StartInfo.EnvironmentVariables[EnvironmentVariable.PATH] = string.Join(';', new string[] + { this.Combine(this.HammerDBPackagePath, "bin"), this.Combine(this.PostgreSqlInstallationPath, "bin"), existingPath - }); - }; - - string command = this.Combine(this.HammerDBPackagePath, "hammerdbcli.bat"); - string commandArguments = $"auto {PostgreSQLServerExecutor.RunTransactionsTclName}"; - - this.MetadataContract.AddForScenario( - "HammerDB", - $"{command} {commandArguments}", - toolVersion: null); - - this.MetadataContract.Apply(telemetryContext); - - using (IProcessProxy process = await this.ExecuteCommandAsync( - command, - commandArguments, - this.HammerDBPackagePath, - telemetryContext, - cancellationToken, - beforeExecution: setEnvironmentVariables)) - { - if (!cancellationToken.IsCancellationRequested) + }); + }; + + string command = this.Combine(this.HammerDBPackagePath, "hammerdbcli.bat"); + string commandArguments = $"auto {PostgreSQLServerExecutor.RunTransactionsTclName}"; + + this.MetadataContract.AddForScenario( + "HammerDB", + $"{command} {commandArguments}", + toolVersion: null); + + this.MetadataContract.Apply(telemetryContext); + + using (IProcessProxy process = await this.ExecuteCommandAsync( + command, + commandArguments, + this.HammerDBPackagePath, + telemetryContext, + cancellationToken, + beforeExecution: setEnvironmentVariables)) { - await this.LogProcessDetailsAsync(process, telemetryContext, "PostgreSQL", logToFile: true); - process.ThrowIfWorkloadFailed(); + if (!cancellationToken.IsCancellationRequested) + { + await this.LogProcessDetailsAsync(process, telemetryContext, "PostgreSQL", logToFile: true); + process.ThrowIfWorkloadFailed(); - results = process.StandardOutput.ToString(); + results = process.StandardOutput.ToString(); + } } } - } - if (!cancellationToken.IsCancellationRequested) - { - this.CaptureMetricsAsync(results, startTime, DateTime.UtcNow, telemetryContext, cancellationToken); + if (!cancellationToken.IsCancellationRequested) + { + this.CaptureMetricsAsync(results, startTime, DateTime.UtcNow, telemetryContext, cancellationToken); + } } }); } diff --git a/src/VirtualClient/VirtualClient.Actions/PostgreSQL/PostgreSQLServerExecutor.cs b/src/VirtualClient/VirtualClient.Actions/PostgreSQL/PostgreSQLServerExecutor.cs index 4dc67f0100..59ef56c79e 100644 --- a/src/VirtualClient/VirtualClient.Actions/PostgreSQL/PostgreSQLServerExecutor.cs +++ b/src/VirtualClient/VirtualClient.Actions/PostgreSQL/PostgreSQLServerExecutor.cs @@ -181,9 +181,12 @@ await this.stabilizationRetryPolicy.ExecuteAsync(async () => // server is running on a system separate from the client system. if (this.IsMultiRoleLayout()) { - this.Logger.LogMessage($"{this.TypeName}.KeepServerAlive", telemetryContext); - await this.WaitAsync(cancellationToken); - this.SetServerOnline(false); + using (BackgroundOperations profiling = BackgroundOperations.BeginProfiling(this, cancellationToken)) + { + this.Logger.LogMessage($"{this.TypeName}.KeepServerAlive", telemetryContext); + await this.WaitAsync(cancellationToken); + this.SetServerOnline(false); + } } } catch diff --git a/src/VirtualClient/VirtualClient.Actions/Redis/RedisServerExecutor.cs b/src/VirtualClient/VirtualClient.Actions/Redis/RedisServerExecutor.cs index b9a617a4c9..6d458d0cfb 100644 --- a/src/VirtualClient/VirtualClient.Actions/Redis/RedisServerExecutor.cs +++ b/src/VirtualClient/VirtualClient.Actions/Redis/RedisServerExecutor.cs @@ -196,15 +196,18 @@ protected override Task ExecuteAsync(EventContext telemetryContext, Cancellation if (this.IsMultiRoleLayout()) { - await Task.WhenAny(this.serverProcesses); - - // A cancellation is request, then we allow each of the server instances - // to gracefully exit. If a cancellation was not requested, it means that one - // or more of the server instances exited and we will want to allow the component - // to start over restarting the servers. - if (cancellationToken.IsCancellationRequested) + using (BackgroundOperations profiling = BackgroundOperations.BeginProfiling(this, cancellationToken)) { - await Task.WhenAll(this.serverProcesses); + await Task.WhenAny(this.serverProcesses); + + // A cancellation is request, then we allow each of the server instances + // to gracefully exit. If a cancellation was not requested, it means that one + // or more of the server instances exited and we will want to allow the component + // to start over restarting the servers. + if (cancellationToken.IsCancellationRequested) + { + await Task.WhenAll(this.serverProcesses); + } } } } diff --git a/src/VirtualClient/VirtualClient.Actions/SPECpower/SPECPowerExecutor.cs b/src/VirtualClient/VirtualClient.Actions/SPECpower/SPECPowerExecutor.cs index c228638402..90d855c2c7 100644 --- a/src/VirtualClient/VirtualClient.Actions/SPECpower/SPECPowerExecutor.cs +++ b/src/VirtualClient/VirtualClient.Actions/SPECpower/SPECPowerExecutor.cs @@ -232,86 +232,89 @@ private ImmutableList GetAllProcessComponents() /// private async Task MonitorProcessesAsync(EventContext telemetryContext, CancellationToken cancellationToken) { - // VC will be running SpecPower at a constant load at extended duration. Typically a day. - const int testTimeoutMinutes = 1440; - - ImmutableList allProcesses = this.GetAllProcesses(); - - bool testTimedOut = false; - bool foundErrorOutput = false; - while (!allProcesses.Any(process => process.HasExited) && !testTimedOut) - { - if (cancellationToken.IsCancellationRequested) - { - break; - } - - // This is reported as a metric so SPEC Power shows up on the dashboard - this.Logger.LogMetrics( - "SPECpower", - "MonitorProcess", - this.StartTime, - DateTime.UtcNow, - "Heartbeat", - 1.0, - string.Empty, - string.Empty, - string.Empty, - this.Tags, - telemetryContext, - MetricRelativity.HigherIsBetter); - - await Task.Delay(30000, cancellationToken).ConfigureAwait(false); - - // If the test hasn't changed in 30 minutes, assume it has failed. - testTimedOut = (DateTime.UtcNow - this.serverComponent.LastTestStartTime).TotalMinutes >= testTimeoutMinutes; - foundErrorOutput = allProcesses.Any(process => !string.IsNullOrEmpty(process.StandardError.ToString())); - } - - if (!cancellationToken.IsCancellationRequested) + using (BackgroundOperations profiling = BackgroundOperations.BeginProfiling(this, cancellationToken)) { - // Ensure if the programs are going to exit, they do so of their own accord. - await Task.Delay(10000, cancellationToken); + // VC will be running SpecPower at a constant load at extended duration. Typically a day. + const int testTimeoutMinutes = 1440; - // Kill any which didn't shutdown themselves. - allProcesses.ForEach(process => process.Kill()); - await Task.Delay(TimeSpan.FromSeconds(1)); + ImmutableList allProcesses = this.GetAllProcesses(); - if (foundErrorOutput) + bool testTimedOut = false; + bool foundErrorOutput = false; + while (!allProcesses.Any(process => process.HasExited) && !testTimedOut) { - allProcesses.ForEach(process => this.Logger.LogMessage( - $"{this.TypeName}.ProcessOutput", - telemetryContext.Clone().AddContext("output", process.StandardOutput.ToString()))); - - allProcesses.Where(p => !string.IsNullOrEmpty(p.StandardError.ToString())).ToList() - .ForEach(process => this.Logger.LogMessage( - $"{this.TypeName}.ProcessError", - telemetryContext.Clone().AddContext("processError", process.StandardError.ToString()))); - - string processNames = string.Join(',', allProcesses.Where(process => !string.IsNullOrEmpty(process.StandardError.ToString())).Select(process => process.Name)); - throw new WorkloadException($"SPEC Process(es) '{processNames}' encountered an error.", ErrorReason.WorkloadFailed); + if (cancellationToken.IsCancellationRequested) + { + break; + } + + // This is reported as a metric so SPEC Power shows up on the dashboard + this.Logger.LogMetrics( + "SPECpower", + "MonitorProcess", + this.StartTime, + DateTime.UtcNow, + "Heartbeat", + 1.0, + string.Empty, + string.Empty, + string.Empty, + this.Tags, + telemetryContext, + MetricRelativity.HigherIsBetter); + + await Task.Delay(30000, cancellationToken).ConfigureAwait(false); + + // If the test hasn't changed in 30 minutes, assume it has failed. + testTimedOut = (DateTime.UtcNow - this.serverComponent.LastTestStartTime).TotalMinutes >= testTimeoutMinutes; + foundErrorOutput = allProcesses.Any(process => !string.IsNullOrEmpty(process.StandardError.ToString())); } - else if (testTimedOut) - { - allProcesses.ForEach(process => this.Logger.LogMessage( - $"{this.TypeName}.ProcessOutput", - telemetryContext.Clone().AddContext("output", process.StandardOutput.ToString()))); - throw new WorkloadException( - $"Benchmark '{this.serverComponent.CurrentTestName}' has not completed in {testTimeoutMinutes} minutes. Assuming something has gone wrong.", - ErrorReason.WorkloadFailed); - } - else if (allProcesses.Any(process => process.ExitCode != 0)) + if (!cancellationToken.IsCancellationRequested) { - allProcesses.ForEach(process => this.Logger.LogMessage( - $"{this.TypeName}.ProcessOutput", - telemetryContext.Clone().AddContext("output", process.StandardOutput.ToString()))); - - allProcesses.ForEach(process => Console.WriteLine(process.StandardOutput.ToString())); - throw new WorkloadException("One or more processes failed with a non-zero exit code!", ErrorReason.WorkloadFailed); + // Ensure if the programs are going to exit, they do so of their own accord. + await Task.Delay(10000, cancellationToken); + + // Kill any which didn't shutdown themselves. + allProcesses.ForEach(process => process.Kill()); + await Task.Delay(TimeSpan.FromSeconds(1)); + + if (foundErrorOutput) + { + allProcesses.ForEach(process => this.Logger.LogMessage( + $"{this.TypeName}.ProcessOutput", + telemetryContext.Clone().AddContext("output", process.StandardOutput.ToString()))); + + allProcesses.Where(p => !string.IsNullOrEmpty(p.StandardError.ToString())).ToList() + .ForEach(process => this.Logger.LogMessage( + $"{this.TypeName}.ProcessError", + telemetryContext.Clone().AddContext("processError", process.StandardError.ToString()))); + + string processNames = string.Join(',', allProcesses.Where(process => !string.IsNullOrEmpty(process.StandardError.ToString())).Select(process => process.Name)); + throw new WorkloadException($"SPEC Process(es) '{processNames}' encountered an error.", ErrorReason.WorkloadFailed); + } + else if (testTimedOut) + { + allProcesses.ForEach(process => this.Logger.LogMessage( + $"{this.TypeName}.ProcessOutput", + telemetryContext.Clone().AddContext("output", process.StandardOutput.ToString()))); + + throw new WorkloadException( + $"Benchmark '{this.serverComponent.CurrentTestName}' has not completed in {testTimeoutMinutes} minutes. Assuming something has gone wrong.", + ErrorReason.WorkloadFailed); + } + else if (allProcesses.Any(process => process.ExitCode != 0)) + { + allProcesses.ForEach(process => this.Logger.LogMessage( + $"{this.TypeName}.ProcessOutput", + telemetryContext.Clone().AddContext("output", process.StandardOutput.ToString()))); + + allProcesses.ForEach(process => Console.WriteLine(process.StandardOutput.ToString())); + throw new WorkloadException("One or more processes failed with a non-zero exit code!", ErrorReason.WorkloadFailed); + } + + this.Logger.LogTraceMessage("SPEC Power Completed Successfully."); } - - this.Logger.LogTraceMessage("SPEC Power Completed Successfully."); } } } diff --git a/src/VirtualClient/VirtualClient.Actions/SPECview/SpecViewExecutor.cs b/src/VirtualClient/VirtualClient.Actions/SPECview/SpecViewExecutor.cs index b6d4bb396a..e6d165ac60 100644 --- a/src/VirtualClient/VirtualClient.Actions/SPECview/SpecViewExecutor.cs +++ b/src/VirtualClient/VirtualClient.Actions/SPECview/SpecViewExecutor.cs @@ -110,13 +110,16 @@ protected override async Task ExecuteAsync(EventContext telemetryContext, Cancel await this.SetUpEnvironmentVariable().ConfigureAwait(false); - using (IProcessProxy process = await this.ExecuteCommandAsync(this.ExecutablePath, commandArguments, this.Package.Path, relatedContext, cancellationToken).ConfigureAwait(false)) + using (BackgroundOperations profiling = BackgroundOperations.BeginProfiling(this, cancellationToken)) { - if (!cancellationToken.IsCancellationRequested) + using (IProcessProxy process = await this.ExecuteCommandAsync(this.ExecutablePath, commandArguments, this.Package.Path, relatedContext, cancellationToken).ConfigureAwait(false)) { - await this.LogProcessDetailsAsync(process, telemetryContext); - process.ThrowIfWorkloadFailed(); - this.CaptureMetrics(process, commandArguments, relatedContext); + if (!cancellationToken.IsCancellationRequested) + { + await this.LogProcessDetailsAsync(process, telemetryContext); + process.ThrowIfWorkloadFailed(); + this.CaptureMetrics(process, commandArguments, relatedContext); + } } } diff --git a/src/VirtualClient/VirtualClient.Actions/StressAppTest/StressAppTestExecutor.cs b/src/VirtualClient/VirtualClient.Actions/StressAppTest/StressAppTestExecutor.cs index 9cbdd1c4fd..4b91124965 100644 --- a/src/VirtualClient/VirtualClient.Actions/StressAppTest/StressAppTestExecutor.cs +++ b/src/VirtualClient/VirtualClient.Actions/StressAppTest/StressAppTestExecutor.cs @@ -182,28 +182,31 @@ private async Task ExecuteWorkloadAsync(EventContext telemetryContext, Cancellat { if (!cancellationToken.IsCancellationRequested) { - string commandLineArguments = this.CommandLine; - commandLineArguments += " -s " + this.TimeInSeconds; - if (this.UseCpuStressfulMemoryCopy && !commandLineArguments.Contains("-W")) + using (BackgroundOperations profiling = BackgroundOperations.BeginProfiling(this, cancellationToken)) { - commandLineArguments += " -W"; - } + string commandLineArguments = this.CommandLine; + commandLineArguments += " -s " + this.TimeInSeconds; + if (this.UseCpuStressfulMemoryCopy && !commandLineArguments.Contains("-W")) + { + commandLineArguments += " -W"; + } - // Example command with arguments: ./stressapptest -s 60 -l stressapptestLogs_202301131037407031.txt - string resultsFileName = $"stressapptestLogs_{DateTime.UtcNow.ToString("yyyyMMddHHmmssffff")}.txt"; - commandLineArguments += " -l " + resultsFileName; + // Example command with arguments: ./stressapptest -s 60 -l stressapptestLogs_202301131037407031.txt + string resultsFileName = $"stressapptestLogs_{DateTime.UtcNow.ToString("yyyyMMddHHmmssffff")}.txt"; + commandLineArguments += " -l " + resultsFileName; - using (IProcessProxy process = await this.ExecuteCommandAsync(this.ExecutableName, commandLineArguments.Trim(), this.PackageDirectory, telemetryContext, cancellationToken, runElevated: true)) - { - if (!cancellationToken.IsCancellationRequested) + using (IProcessProxy process = await this.ExecuteCommandAsync(this.ExecutableName, commandLineArguments.Trim(), this.PackageDirectory, telemetryContext, cancellationToken, runElevated: true)) { - if (process.IsErrored()) + if (!cancellationToken.IsCancellationRequested) { - await this.LogProcessDetailsAsync(process, telemetryContext, "StressAppTest"); - process.ThrowIfWorkloadFailed(); - } + if (process.IsErrored()) + { + await this.LogProcessDetailsAsync(process, telemetryContext, "StressAppTest"); + process.ThrowIfWorkloadFailed(); + } - await this.CaptureMetricsAsync(process, commandLineArguments, resultsFileName, telemetryContext, cancellationToken); + await this.CaptureMetricsAsync(process, commandLineArguments, resultsFileName, telemetryContext, cancellationToken); + } } } } diff --git a/src/VirtualClient/VirtualClient.Actions/SysbenchOLTP/SysbenchOLTPServerExecutor.cs b/src/VirtualClient/VirtualClient.Actions/SysbenchOLTP/SysbenchOLTPServerExecutor.cs index 4dbb08de04..7cb79b180c 100644 --- a/src/VirtualClient/VirtualClient.Actions/SysbenchOLTP/SysbenchOLTPServerExecutor.cs +++ b/src/VirtualClient/VirtualClient.Actions/SysbenchOLTP/SysbenchOLTPServerExecutor.cs @@ -115,8 +115,10 @@ protected override Task ExecuteAsync(EventContext telemetryContext, Cancellation if (this.IsMultiRoleLayout()) { - await this.WaitAsync(cancellationToken) - .ConfigureAwait(false); + using (BackgroundOperations profiling = BackgroundOperations.BeginProfiling(this, cancellationToken)) + { + await this.WaitAsync(cancellationToken); + } } } });