test(communication): M2.11 review nits — bridge-actor not-found test + dead-letter comment + toast wording (#24)
- Add DebugStreamBridgeActorTests: On_InstanceNotFound_Snapshot_Forwards_To_OnEvent_Does_Not_Open_Stream_And_Terminates — asserts _onEvent receives the not-found snapshot, SubscribeCalls remains empty, and the actor terminates cleanly via Watch/ExpectTerminated. - Add comment in DebugStreamBridgeActor near Context.Stop(Self) explaining that the subsequent StopDebugStream Tell from DebugStreamService.StopStream produces a benign expected dead-letter. - Reword not-found toast in DebugView.razor to "Instance not found on the selected site — check the deployment target." (accurate when the instance may be deployed to a different site).
This commit is contained in:
@@ -451,8 +451,7 @@
|
|||||||
{
|
{
|
||||||
DebugStreamService.StopStream(session.SessionId);
|
DebugStreamService.StopStream(session.SessionId);
|
||||||
_toast.ShowError(
|
_toast.ShowError(
|
||||||
$"Instance is not deployed on that site. " +
|
"Instance not found on the selected site — check the deployment target.");
|
||||||
$"Deploy it first or choose the correct site.");
|
|
||||||
_connecting = false;
|
_connecting = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,6 +98,10 @@ public class DebugStreamBridgeActor : ReceiveActor, IWithTimers
|
|||||||
_instanceUniqueName);
|
_instanceUniqueName);
|
||||||
_stopped = true;
|
_stopped = true;
|
||||||
_onEvent(snapshot); // resolves the snapshot TCS with InstanceNotFound=true
|
_onEvent(snapshot); // resolves the snapshot TCS with InstanceNotFound=true
|
||||||
|
// Note: after Context.Stop(Self) below the actor is dead. DebugStreamService
|
||||||
|
// inspects InitialSnapshot.InstanceNotFound and calls StopStream, which sends
|
||||||
|
// a StopDebugStream message. That Tell arrives after the actor has already
|
||||||
|
// stopped, producing a benign Akka dead-letter — expected and harmless.
|
||||||
Context.Stop(Self);
|
Context.Stop(Self);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,44 @@ public class DebugStreamBridgeActorTests : TestKit
|
|||||||
return new TestContext(actor, commProbe, mockClient, events, terminated);
|
return new TestContext(actor, commProbe, mockClient, events, terminated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void On_InstanceNotFound_Snapshot_Forwards_To_OnEvent_Does_Not_Open_Stream_And_Terminates()
|
||||||
|
{
|
||||||
|
// M2.11: when the site reports InstanceNotFound=true the bridge actor must
|
||||||
|
// (a) forward the not-found snapshot to _onEvent so DebugStreamService's TCS
|
||||||
|
// resolves and the caller can inspect the flag,
|
||||||
|
// (b) NOT open a gRPC stream (SubscribeCalls must remain empty), and
|
||||||
|
// (c) stop itself cleanly.
|
||||||
|
var ctx = CreateBridgeActor();
|
||||||
|
ctx.CommProbe.ExpectMsg<SiteEnvelope>(); // initial subscribe envelope
|
||||||
|
|
||||||
|
var notFoundSnapshot = new DebugViewSnapshot(
|
||||||
|
InstanceName,
|
||||||
|
new List<AttributeValueChanged>(),
|
||||||
|
new List<AlarmStateChanged>(),
|
||||||
|
DateTimeOffset.UtcNow,
|
||||||
|
InstanceNotFound: true);
|
||||||
|
|
||||||
|
Watch(ctx.BridgeActor);
|
||||||
|
ctx.BridgeActor.Tell(notFoundSnapshot);
|
||||||
|
|
||||||
|
// (a) _onEvent must receive the not-found snapshot
|
||||||
|
AwaitCondition(() => { lock (ctx.ReceivedEvents) { return ctx.ReceivedEvents.Count == 1; } },
|
||||||
|
TimeSpan.FromSeconds(3));
|
||||||
|
lock (ctx.ReceivedEvents)
|
||||||
|
{
|
||||||
|
var received = Assert.IsType<DebugViewSnapshot>(ctx.ReceivedEvents[0]);
|
||||||
|
Assert.True(received.InstanceNotFound);
|
||||||
|
}
|
||||||
|
|
||||||
|
// (b) no gRPC stream opened
|
||||||
|
ExpectTerminated(ctx.BridgeActor, TimeSpan.FromSeconds(3));
|
||||||
|
Assert.Empty(ctx.MockGrpcClient.SubscribeCalls);
|
||||||
|
|
||||||
|
// (c) actor terminates cleanly
|
||||||
|
// ExpectTerminated above already verified termination
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void PreStart_Sends_SubscribeDebugViewRequest_Via_ClusterClient()
|
public void PreStart_Sends_SubscribeDebugViewRequest_Via_ClusterClient()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user