b211911f98
v2-ci / unit-tests (push) Failing after 13m22s
Akka.TestKit.Xunit2 -> Akka.TestKit.Xunit 1.5.62 (xunit.v3 TestKit; needs xunit.v3 3.2.2, set via VersionOverride on the four projects). Removes the xunit 2.9.3 pin. IAsyncLifetime returns ValueTask, SqlServerFactAttribute gains the source-info ctor, and xUnit1051 call sites pass TestContext.Current.CancellationToken. Test counts unchanged. Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
48 lines
1.9 KiB
C#
48 lines
1.9 KiB
C#
using System.Diagnostics;
|
|
using Shouldly;
|
|
using Xunit;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Host.Tests.Startup;
|
|
|
|
/// <summary>
|
|
/// #618 — a host that fails to start must END the process with a non-zero exit code and a Fatal line,
|
|
/// not linger as a half-started zombie. Spawns the built host assembly as a real child process.
|
|
/// </summary>
|
|
public sealed class FailStartExitTests
|
|
{
|
|
[Fact]
|
|
public async Task A_failed_start_exits_non_zero_and_logs_fatal()
|
|
{
|
|
var hostDll = typeof(ZB.MOM.WW.OtOpcUa.Host.Program).Assembly.Location;
|
|
var dir = Path.GetDirectoryName(hostDll)!;
|
|
|
|
var psi = new ProcessStartInfo("dotnet", $"\"{hostDll}\"")
|
|
{
|
|
WorkingDirectory = dir,
|
|
RedirectStandardOutput = true,
|
|
RedirectStandardError = true,
|
|
UseShellExecute = false,
|
|
};
|
|
// An invalid Akka seed address makes the cluster wiring throw before the host can ever run;
|
|
// no external service is touched.
|
|
psi.Environment["Cluster__Roles"] = "driver";
|
|
psi.Environment["Cluster__SeedNodes__0"] = "not-a-valid-address";
|
|
|
|
using var proc = Process.Start(psi)!;
|
|
var stdout = proc.StandardOutput.ReadToEndAsync(TestContext.Current.CancellationToken);
|
|
var stderr = proc.StandardError.ReadToEndAsync(TestContext.Current.CancellationToken);
|
|
|
|
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(60));
|
|
try { await proc.WaitForExitAsync(cts.Token); }
|
|
catch (OperationCanceledException)
|
|
{
|
|
proc.Kill(entireProcessTree: true);
|
|
Assert.Fail("host did not exit within 60 s of a failed start (#618): " + await stdout + await stderr);
|
|
}
|
|
|
|
var output = await stdout + await stderr;
|
|
proc.ExitCode.ShouldNotBe(0, output);
|
|
output.ShouldContain("terminated during startup", Case.Insensitive, "the failure must be logged as Fatal");
|
|
}
|
|
}
|