Instrument the historian plugin with runtime query health counters and read-only cluster failover so operators can detect silent query degradation and keep serving history when a single cluster node goes down
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ArchestrA;
|
||||
using ZB.MOM.WW.LmxOpcUa.Historian.Aveva;
|
||||
using ZB.MOM.WW.LmxOpcUa.Host.Configuration;
|
||||
@@ -11,15 +12,38 @@ namespace ZB.MOM.WW.LmxOpcUa.Historian.Aveva.Tests
|
||||
/// </summary>
|
||||
internal sealed class FakeHistorianConnectionFactory : IHistorianConnectionFactory
|
||||
{
|
||||
/// <summary>
|
||||
/// Exception thrown on every CreateAndConnect call unless a more specific rule in
|
||||
/// <see cref="ServerBehaviors"/> or <see cref="OnConnect"/> fires first.
|
||||
/// </summary>
|
||||
public Exception? ConnectException { get; set; }
|
||||
|
||||
public int ConnectCallCount { get; private set; }
|
||||
|
||||
public Action<int>? OnConnect { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Per-server-name override: if the requested <c>config.ServerName</c> has an entry
|
||||
/// whose value is non-null, that exception is thrown instead of the global
|
||||
/// <see cref="ConnectException"/>. Lets tests script cluster failover behavior like
|
||||
/// "node A always fails; node B always succeeds".
|
||||
/// </summary>
|
||||
public Dictionary<string, Exception?> ServerBehaviors { get; } =
|
||||
new Dictionary<string, Exception?>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>
|
||||
/// Ordered history of server names passed to CreateAndConnect so tests can assert the
|
||||
/// picker's iteration order and failover sequence.
|
||||
/// </summary>
|
||||
public List<string> ConnectHistory { get; } = new List<string>();
|
||||
|
||||
public HistorianAccess CreateAndConnect(HistorianConfiguration config, HistorianConnectionType type)
|
||||
{
|
||||
ConnectCallCount++;
|
||||
ConnectHistory.Add(config.ServerName);
|
||||
|
||||
if (ServerBehaviors.TryGetValue(config.ServerName, out var serverException) && serverException != null)
|
||||
throw serverException;
|
||||
|
||||
if (OnConnect != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user