2a8f9af5e4
A bad keep-alive now degrades health (LastSuccessfulRead preserved) and, once per outage, publishes BadNoCommunication (value retained) for every subscribed ref plus a quality-only annotation on subscribed alarm conditions. Good keep-alives and data/event notifications advance LastSuccessfulRead, so an idle-but-alive subscription never looks dead to the #527 watchdog. A keep-alive that recovers on the same session re-reads the Bad refs and republishes them Good; a session that does not come back is recovered by the watchdog's ShutdownAsync + InitializeAsync + re-subscribe. Deletes the SessionReconnectHandler wiring (it retried forever in SDK 1.5.378, cloned subscriptions the driver never re-tracked and kept health Healthy), OnReconnectComplete, TryRearmReconnect and the reconnect_* counters (new keepalive_recovered). Teardown of a lost session skips wire deletes and bounds CloseSession. SDK warnings reach the driver log. Wire test reworked: restart => Bad, then watchdog-style reinit => Good.
38 lines
1.6 KiB
C#
38 lines
1.6 KiB
C#
using Shouldly;
|
|
using Xunit;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient.Tests;
|
|
|
|
/// <summary>
|
|
/// Scaffold tests for the reconnect options. Since Gitea #670 the driver has no in-driver reconnect
|
|
/// handler (session loss is reported and the host's comms-loss watchdog re-initialises the driver);
|
|
/// <c>ReconnectPeriod</c> is retained for config compatibility only. Outage behaviour is covered by
|
|
/// <see cref="OpcUaClientSessionLossTests"/> and, over the wire, <c>OpcUaClientDriverReconnectWireTests</c>.
|
|
/// </summary>
|
|
[Trait("Category", "Unit")]
|
|
public sealed class OpcUaClientReconnectTests
|
|
{
|
|
/// <summary>Verifies that the default reconnect period matches the driver specification of 5 seconds.</summary>
|
|
[Fact]
|
|
public void Default_ReconnectPeriod_matches_driver_specs_5_seconds()
|
|
{
|
|
new OpcUaClientDriverOptions().ReconnectPeriod.ShouldBe(TimeSpan.FromSeconds(5));
|
|
}
|
|
|
|
/// <summary>Verifies that reconnect period can be configured for aggressive or relaxed retries.</summary>
|
|
[Fact]
|
|
public void Options_ReconnectPeriod_is_configurable_for_aggressive_or_relaxed_retry()
|
|
{
|
|
var opts = new OpcUaClientDriverOptions { ReconnectPeriod = TimeSpan.FromMilliseconds(500) };
|
|
opts.ReconnectPeriod.ShouldBe(TimeSpan.FromMilliseconds(500));
|
|
}
|
|
|
|
/// <summary>Verifies that the driver starts in the Unknown state before initialization.</summary>
|
|
[Fact]
|
|
public void Driver_starts_unknown_pre_init()
|
|
{
|
|
using var drv = new OpcUaClientDriver(new OpcUaClientDriverOptions(), "opcua-reconnect");
|
|
drv.GetHealth().State.ShouldBe(Core.Abstractions.DriverState.Unknown);
|
|
}
|
|
}
|