feat: verify Tornado PGM cut sequence

This commit is contained in:
2026-07-10 16:05:06 +09:00
parent 930424b752
commit d12a5d8095
15 changed files with 4344 additions and 74 deletions

View File

@@ -29,6 +29,8 @@ return parsed.Invocation.Kind switch
await RunIsolatedTestCommandAsync(parsed.Invocation, cancellation.Token),
SmokeCommandKind.PgmConnectDiagnostic =>
await RunPgmConnectDiagnosticAsync(parsed.Invocation, cancellation.Token),
SmokeCommandKind.PgmCutsSequence =>
await RunPgmCutsSequenceAsync(parsed.Invocation, cancellation.Token),
_ => Usage("unknown-command")
};
@@ -286,6 +288,75 @@ static async Task<int> RunPgmConnectDiagnosticAsync(
return report.OutcomeUnknown ? 5 : 4;
}
static async Task<int> RunPgmCutsSequenceAsync(
SmokeCommandInvocation invocation,
CancellationToken cancellationToken)
{
if (IsolatedTestCommandPreflight.HasPlayoutEnvironmentOverride(
Environment.GetEnvironmentVariables()))
{
WritePgmCutsSequenceFailure("environment-override-present");
return 65;
}
var request = new PgmCutsSequenceRequest(
invocation.Host ?? string.Empty,
invocation.Port ?? 0,
invocation.ExpectedPgmWindowTitle ?? string.Empty,
invocation.SceneRoot ?? string.Empty,
invocation.ObservationMilliseconds ?? 0);
PgmCutsSequenceReport report;
try
{
report = await new PgmCutsSequenceRunner()
.ExecuteAsync(
request,
stage =>
{
WriteProgressJson(new
{
@event = "observation-start",
stage = ToObservationWireValue(stage)
});
},
cancellationToken)
.ConfigureAwait(false);
}
catch
{
WritePgmCutsSequenceFailure("internal-sequence-failure");
return 70;
}
WriteJson(new
{
command = "pgm-cuts-sequence",
report.RequestValidated,
report.HashPinsPresent,
report.TargetGatePassed,
report.EngineCreated,
report.RenderCommandAttempted,
report.DisconnectAttempted,
report.QuarantineAttempted,
report.QuarantineCompleted,
report.Completed,
report.OutcomeUnknown,
commands = report.Commands.Select(command => new
{
stage = ToSequenceStageWireValue(command.Stage),
code = command.Code.ToString()
}),
report.ErrorCode
});
if (report.Completed && !report.OutcomeUnknown)
{
return 0;
}
return report.OutcomeUnknown ? 5 : 4;
}
static void WritePgmDiagnosticFailure(string errorCode) =>
WriteJson(new
{
@@ -313,6 +384,24 @@ static void WritePgmDiagnosticFailure(string errorCode) =>
errorCode
});
static void WritePgmCutsSequenceFailure(string errorCode) =>
WriteJson(new
{
command = "pgm-cuts-sequence",
requestValidated = false,
hashPinsPresent = false,
targetGatePassed = false,
engineCreated = false,
renderCommandAttempted = false,
disconnectAttempted = false,
quarantineAttempted = false,
quarantineCompleted = false,
completed = false,
outcomeUnknown = false,
commands = Array.Empty<object>(),
errorCode
});
static string ToWireValue(PlayoutKtapConnectState state) => state switch
{
PlayoutKtapConnectState.NotAttempted => "not-attempted",
@@ -322,6 +411,25 @@ static string ToWireValue(PlayoutKtapConnectState state) => state switch
_ => "not-attempted"
};
static string ToObservationWireValue(PgmCutsObservationStage stage) => stage switch
{
PgmCutsObservationStage.First => "first",
PgmCutsObservationStage.Next => "next",
PgmCutsObservationStage.TakeOut => "take-out",
_ => "unknown"
};
static string ToSequenceStageWireValue(PgmCutsSequenceStage stage) => stage switch
{
PgmCutsSequenceStage.Connect => "connect",
PgmCutsSequenceStage.PrepareFirst => "prepare-first",
PgmCutsSequenceStage.TakeIn => "take-in",
PgmCutsSequenceStage.Next => "next",
PgmCutsSequenceStage.TakeOut => "take-out",
PgmCutsSequenceStage.Disconnect => "disconnect",
_ => "unknown"
};
static void WritePreflightFailure(string command, string errorCode) =>
WriteJson(new
{
@@ -349,6 +457,15 @@ static void WriteJson<T>(T value) =>
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
}));
static void WriteProgressJson<T>(T value)
{
Console.WriteLine(JsonSerializer.Serialize(value, new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
}));
Console.Out.Flush();
}
static int Usage(string? errorCode)
{
WriteJson(new
@@ -366,7 +483,7 @@ static int Usage(string? errorCode)
errorCode = errorCode ?? "invalid-command-line"
});
Console.Error.WriteLine(
"Usage: MBN_STOCK_WEBVIEW.PlayoutSmoke [--probe|--dry-run|--test-plan|--test-connect|--test-sequence|--pgm-connect-diagnostic]");
"Usage: MBN_STOCK_WEBVIEW.PlayoutSmoke [--probe|--dry-run|--test-plan|--test-connect|--test-sequence|--pgm-connect-diagnostic|--pgm-cuts-sequence]");
Console.Error.WriteLine(
$"Test commands require {SmokeCommandLine.AcknowledgementFlag} and --config <absolute-path>.");
Console.Error.WriteLine(
@@ -375,5 +492,7 @@ static int Usage(string? errorCode)
"--test-connect and --test-sequence may request render-capable COM after all Test safety gates pass.");
Console.Error.WriteLine(
$"--pgm-connect-diagnostic requires {SmokeCommandLine.PgmConnectAcknowledgementFlag}, --host, --port and --expected-pgm-window-title; it exposes no render command.");
Console.Error.WriteLine(
$"--pgm-cuts-sequence requires {SmokeCommandLine.PgmCutsSequenceAcknowledgementFlag}, --host, --port, --expected-pgm-window-title and --scene-root; --observe-ms may only be 5000.");
return 64;
}