fix: wire DCL connection state changes into ISiteHealthCollector
DataConnectionActor now calls UpdateConnectionHealth() on state transitions (Connecting/Connected/Reconnecting) and UpdateTagResolution() on connection establishment. DataConnectionManagerActor calls RemoveConnection() on actor removal. Health reports now include data connection statuses when instances are deployed with bindings.
This commit is contained in:
@@ -4,6 +4,7 @@ using NSubstitute;
|
||||
using ScadaLink.Commons.Interfaces.Protocol;
|
||||
using ScadaLink.Commons.Messages.DataConnection;
|
||||
using ScadaLink.DataConnectionLayer.Actors;
|
||||
using ScadaLink.HealthMonitoring;
|
||||
|
||||
namespace ScadaLink.DataConnectionLayer.Tests;
|
||||
|
||||
@@ -14,11 +15,13 @@ public class DataConnectionManagerActorTests : TestKit
|
||||
{
|
||||
private readonly IDataConnectionFactory _mockFactory;
|
||||
private readonly DataConnectionOptions _options;
|
||||
private readonly ISiteHealthCollector _mockHealthCollector;
|
||||
|
||||
public DataConnectionManagerActorTests()
|
||||
: base(@"akka.loglevel = DEBUG")
|
||||
{
|
||||
_mockFactory = Substitute.For<IDataConnectionFactory>();
|
||||
_mockHealthCollector = Substitute.For<ISiteHealthCollector>();
|
||||
_options = new DataConnectionOptions
|
||||
{
|
||||
ReconnectInterval = TimeSpan.FromMilliseconds(100),
|
||||
@@ -30,7 +33,7 @@ public class DataConnectionManagerActorTests : TestKit
|
||||
public void WriteToUnknownConnection_ReturnsError()
|
||||
{
|
||||
var manager = Sys.ActorOf(Props.Create(() =>
|
||||
new DataConnectionManagerActor(_mockFactory, _options)));
|
||||
new DataConnectionManagerActor(_mockFactory, _options, _mockHealthCollector)));
|
||||
|
||||
manager.Tell(new WriteTagRequest(
|
||||
"corr1", "nonexistent", "tag1", 42, DateTimeOffset.UtcNow));
|
||||
@@ -44,7 +47,7 @@ public class DataConnectionManagerActorTests : TestKit
|
||||
public void SubscribeToUnknownConnection_ReturnsError()
|
||||
{
|
||||
var manager = Sys.ActorOf(Props.Create(() =>
|
||||
new DataConnectionManagerActor(_mockFactory, _options)));
|
||||
new DataConnectionManagerActor(_mockFactory, _options, _mockHealthCollector)));
|
||||
|
||||
manager.Tell(new SubscribeTagsRequest(
|
||||
"corr1", "inst1", "nonexistent", ["tag1"], DateTimeOffset.UtcNow));
|
||||
@@ -64,7 +67,7 @@ public class DataConnectionManagerActorTests : TestKit
|
||||
.Returns(mockAdapter);
|
||||
|
||||
var manager = Sys.ActorOf(Props.Create(() =>
|
||||
new DataConnectionManagerActor(_mockFactory, _options)));
|
||||
new DataConnectionManagerActor(_mockFactory, _options, _mockHealthCollector)));
|
||||
|
||||
manager.Tell(new CreateConnectionCommand(
|
||||
"conn1", "OpcUa", new Dictionary<string, string>()));
|
||||
|
||||
Reference in New Issue
Block a user