Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log Process Details in ExecuteCommandAsync #439

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
5 changes: 5 additions & 0 deletions src/VirtualClient/VirtualClient.Contracts/Enumerations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public enum ErrorReason : int
/// </summary>
DiskFilterNotSupported = 301,

/// <summary>
/// Process failed execution.
/// </summary>
ProcessFailed = 313,

/// <summary>
/// The workload failed during execution.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ public static async Task<IProcessProxy> ExecuteCommandAsync(
beforeExecution?.Invoke(process);
await process.StartAndWaitAsync(cancellationToken)
.ConfigureAwait(false);

await component.LogProcessDetailsAsync(process, telemetryContext, logToFile: true);
process.ThrowIfErrored<ProcessException>(process.StandardError.ToString(), ErrorReason.ProcessFailed);
}

return process;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ public void MySQLServerConfigurationThrowsExceptionWhenConfigureServerProcessIsE
this.fixture.Process.OnHasExited = () => true;

using TestMySQLServerConfiguration component = new TestMySQLServerConfiguration(this.fixture);
DependencyException exception = Assert.ThrowsAsync<DependencyException>(() => component.ExecuteAsync(CancellationToken.None));
Assert.AreEqual(ErrorReason.DependencyInstallationFailed, exception.Reason);
ProcessException exception = Assert.ThrowsAsync<ProcessException>(() => component.ExecuteAsync(CancellationToken.None));
Assert.AreEqual(ErrorReason.ProcessFailed, exception.Reason);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ public void PostgreSQLServerConfigurationThrowsExceptionWhenConfigureServerProce
};

using TestPostgreSQLServerConfiguration component = new TestPostgreSQLServerConfiguration(this.fixture);
DependencyException exception = Assert.ThrowsAsync<DependencyException>(() => component.ExecuteAsync(CancellationToken.None));
Assert.AreEqual(ErrorReason.DependencyInstallationFailed, exception.Reason);
ProcessException exception = Assert.ThrowsAsync<ProcessException>(() => component.ExecuteAsync(CancellationToken.None));
Assert.AreEqual(ErrorReason.ProcessFailed, exception.Reason);
}

[Test]
Expand Down
Loading