fix(dcl): broadcast SnapshotComplete sentinel to all alarm subscribers
The MxGateway alarm mapper emits the SnapshotComplete framing sentinel with
empty SourceReference/SourceObjectReference. HandleAlarmTransitionReceived
routed every transition by prefix match against the subscriber's source, so
the empty-ref sentinel ('' .StartsWith("<src>.") == false) was dropped for
any specific source. The NativeAlarmActor buffers snapshot conditions and only
flushes them on SnapshotComplete, so statically-active native alarms delivered
only in the initial snapshot (no later live transition) never surfaced.
Broadcast the SnapshotComplete sentinel to all alarm subscribers (bypassing the
source match + type filter) so each NativeAlarmActor's snapshot swap completes.
Adds a regression test using the real empty-ref sentinel against a specific
(prefix) source.
This commit was merged in pull request #3.
This commit is contained in:
+36
@@ -195,4 +195,40 @@ public class DataConnectionActorAlarmTests : TestKit
|
||||
"", "", "", "", "", null, DateTimeOffset.UtcNow, "", ""));
|
||||
ExpectMsg<NativeAlarmTransitionUpdate>(u => u.Transition.Kind == AlarmTransitionKind.SnapshotComplete);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SubscribeAlarms_RealEmptyRefSnapshotComplete_IsBroadcastToSpecificSource()
|
||||
{
|
||||
// Regression: the real MxGatewayAlarmMapper.SnapshotComplete() emits the
|
||||
// sentinel with EMPTY SourceReference / SourceObjectReference. With a
|
||||
// specific (prefix) source like "Reactor." the per-source match
|
||||
// ("".StartsWith("Reactor.") == false) used to drop it, stranding the
|
||||
// buffered snapshot in the NativeAlarmActor forever — statically-active
|
||||
// conditions (delivered only in the snapshot) never surfaced. The sentinel
|
||||
// must be broadcast to every subscriber so the snapshot swap completes.
|
||||
var (adapter, getCb) = BuildAlarmAdapter();
|
||||
var actor = Sys.ActorOf(Props.Create(() => new DataConnectionActor(
|
||||
"conn", adapter, _options, _health, _factory, "MxGateway")));
|
||||
|
||||
actor.Tell(new SubscribeAlarmsRequest("c", "inst", "conn", "Reactor.", null, DateTimeOffset.UtcNow));
|
||||
ExpectMsg<SubscribeAlarmsResponse>(m => m.Success);
|
||||
var cb = getCb();
|
||||
Assert.NotNull(cb);
|
||||
|
||||
// Active alarm under the source arrives in the snapshot and routes by prefix.
|
||||
cb!(new NativeAlarmTransition(
|
||||
"Galaxy!Area.Reactor.HeartbeatTimeoutAlarm", "Reactor.HeartbeatTimeoutAlarm", "Syst",
|
||||
AlarmTransitionKind.Snapshot,
|
||||
new AlarmConditionState(true, false, null, AlarmShelveState.Unshelved, false, 400),
|
||||
"Area", "", "", "", "", null, DateTimeOffset.UtcNow, "", ""));
|
||||
ExpectMsg<NativeAlarmTransitionUpdate>(u =>
|
||||
u.Transition.Kind == AlarmTransitionKind.Snapshot &&
|
||||
u.Transition.SourceObjectReference == "Reactor.HeartbeatTimeoutAlarm");
|
||||
|
||||
// Real sentinel with EMPTY refs — must still reach the "Reactor." subscriber.
|
||||
cb!(new NativeAlarmTransition("", "", "", AlarmTransitionKind.SnapshotComplete,
|
||||
new AlarmConditionState(false, true, null, AlarmShelveState.Unshelved, false, 0),
|
||||
"", "", "", "", "", null, DateTimeOffset.UtcNow, "", ""));
|
||||
ExpectMsg<NativeAlarmTransitionUpdate>(u => u.Transition.Kind == AlarmTransitionKind.SnapshotComplete);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user