fix: add truthful KTAP monitoring diagnostics

This commit is contained in:
2026-07-10 12:17:42 +09:00
parent fc932b27f6
commit 306d3a70a1
15 changed files with 764 additions and 33 deletions

View File

@@ -191,6 +191,13 @@ internal sealed record SafeTestCommandReport(
string Mode,
bool ConnectRequestIssued,
bool? ComActivationAttempted,
string LastKtapConnectState,
bool KtapConnectAttempted,
bool? KtapConnectAccepted,
bool? KtapHelloObserved,
bool? NetworkMonitoringRecordExpected,
bool NetworkMonitoringCheckRequired,
bool? NetworkMonitoringVerified,
bool Completed,
bool OutcomeUnknown,
bool OutputMayBeActive,
@@ -228,6 +235,8 @@ internal static class IsolatedTestCommandExecutor
var connectRequestIssued = false;
var connectResultReceived = false;
bool? comActivationAttempted = false;
var lastKtapConnectState = PlayoutKtapConnectState.NotAttempted;
bool? ktapHelloObserved = null;
var completed = false;
var outcomeUnknown = false;
string? stoppedAfter = null;
@@ -248,6 +257,7 @@ internal static class IsolatedTestCommandExecutor
connectRequestIssued = true;
var connect = await engine.ConnectAsync(cancellationToken).ConfigureAwait(false);
connectResultReceived = true;
CaptureKtapEvidence();
AddStep(steps, "command", connect);
comActivationAttempted = InferComActivationAttempt(connect.Code);
if (!connect.IsSuccess)
@@ -355,6 +365,7 @@ internal static class IsolatedTestCommandExecutor
{
if (engine is not null)
{
CaptureKtapEvidence();
if (outputMayBeActive && !takeOutAttempted && !outcomeUnknown)
{
takeOutAttempted = true;
@@ -420,6 +431,7 @@ internal static class IsolatedTestCommandExecutor
try
{
await engine.DisposeAsync().ConfigureAwait(false);
CaptureKtapEvidence();
adapterDisposed = true;
}
catch
@@ -457,6 +469,23 @@ internal static class IsolatedTestCommandExecutor
"Test",
connectRequestIssued,
comActivationAttempted,
ToWireValue(lastKtapConnectState),
lastKtapConnectState != PlayoutKtapConnectState.NotAttempted,
lastKtapConnectState switch
{
PlayoutKtapConnectState.AcceptedUnconfirmed => true,
PlayoutKtapConnectState.NotAttempted => false,
_ => null
},
ktapHelloObserved,
lastKtapConnectState switch
{
PlayoutKtapConnectState.AcceptedUnconfirmed => true,
PlayoutKtapConnectState.NotAttempted => false,
_ => null
},
lastKtapConnectState != PlayoutKtapConnectState.NotAttempted,
null,
completed,
outcomeUnknown,
outputMayBeActive,
@@ -468,8 +497,29 @@ internal static class IsolatedTestCommandExecutor
quarantineAttempted,
quarantineCompleted,
adapterDisposed));
void CaptureKtapEvidence()
{
if (engine is null)
{
return;
}
var status = engine.Status;
lastKtapConnectState = status.LastKtapConnectState;
ktapHelloObserved = status.KtapHelloObserved;
}
}
private static string ToWireValue(PlayoutKtapConnectState state) => state switch
{
PlayoutKtapConnectState.NotAttempted => "not-attempted",
PlayoutKtapConnectState.Attempted => "attempted",
PlayoutKtapConnectState.AcceptedUnconfirmed => "accepted-unconfirmed",
PlayoutKtapConnectState.Failed => "failed",
_ => "not-attempted"
};
private static void AddStep(
ICollection<SafeCommandStep> steps,
string phase,