fix(dcl): log the initial connect to Site Event Logging like every other transition (review 2026-10-21 02/U4)

This commit is contained in:
Joseph Doherty
2026-10-22 06:31:23 -04:00
parent 3543a7f295
commit cfe95a7e5a
3 changed files with 33 additions and 3 deletions
@@ -6,12 +6,14 @@ using ZB.MOM.WW.ScadaBridge.Commons.Messages.DataConnection;
using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums;
using ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Actors;
using ZB.MOM.WW.ScadaBridge.HealthMonitoring;
using ZB.MOM.WW.ScadaBridge.SiteEventLogging;
namespace ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests.Actors;
/// <summary>
/// Low-severity housekeeping findings from review 2026-10-21 (02/L2, 02/L4): bookkeeping that
/// outlived the subscription or the session it belonged to.
/// Low-severity housekeeping findings from review 2026-10-21 (02/L2, 02/L4, 02/U4): bookkeeping
/// that outlived the subscription or the session it belonged to, and the connection-transition
/// event-log contract.
/// </summary>
[Collection("DataConnectionManagerActor")]
public class DataConnectionHousekeepingTests : TestKit
@@ -104,4 +106,24 @@ public class DataConnectionHousekeepingTests : TestKit
AwaitCondition(() => reseedToken.IsCancellationRequested, TimeSpan.FromSeconds(5));
}
/// <summary>
/// 02/U4(b): the spec says every connection transition is logged to Site Event Logging —
/// the INITIAL connect included, not just reconnect-restored / lost / failover.
/// </summary>
[Fact]
public void InitialConnect_IsLoggedToSiteEventLog()
{
const string name = "initial-connect-logged";
var eventLog = Substitute.For<ISiteEventLogger>();
var adapter = new FakeBatchDataConnection();
Sys.ActorOf(Props.Create(() => new DataConnectionActor(
name, adapter, Options(), _health, _factory, "OpcUa", null, null, 3, eventLog)), name);
AwaitCondition(() => eventLog.ReceivedCalls().Any(c =>
c.GetMethodInfo().Name == nameof(ISiteEventLogger.LogEventAsync)
&& c.GetArguments() is ["connection", "Info", null, name, string message, ..]
&& message.Contains("established", StringComparison.OrdinalIgnoreCase)),
TimeSpan.FromSeconds(5));
}
}