fix(options): bind + validate OperationTrackingOptions; register the site IOperationTrackingStore that two comments claimed AddSiteRuntime provides (plan R2-08 T8, arch-review 08r2 NF4)
VERIFY-THEN-FIX: the plan-authoring discovery is CONFIRMED. No code anywhere in src/ registered IOperationTrackingStore in DI, yet AkkaHostedService and AuditLog SCE both comment that AddSiteRuntime provides it. Every consumer resolved it via GetService (null-tolerant) and silently ran degraded: cached-drain scheduler never armed, PullSiteCalls reconciliation seam never wired, Tracking.Status degraded to audit-only. This is a FUNCTIONAL FIX riding the hygiene plan: AddSiteRuntime now registers the store (site-only), so site-local cached-call tracking runs in its intended mode. OperationTrackingOptions is now bound + eagerly validated in the Host site-options block.
This commit is contained in:
+40
@@ -0,0 +1,40 @@
|
||||
using ZB.MOM.WW.ScadaBridge.SiteRuntime.Tracking;
|
||||
|
||||
namespace ZB.MOM.WW.ScadaBridge.SiteRuntime.Tests.Tracking;
|
||||
|
||||
/// <summary>
|
||||
/// Eager startup validation for <see cref="OperationTrackingOptions"/>
|
||||
/// (arch-review 08 round 2 NF4). The store opens the SQLite connection string at
|
||||
/// construction, so an empty connection string must fail the host at boot; the
|
||||
/// retention window must be positive or terminal-row purge would delete
|
||||
/// everything.
|
||||
/// </summary>
|
||||
public class OperationTrackingOptionsValidatorTests
|
||||
{
|
||||
[Fact]
|
||||
public void DefaultOptions_AreValid()
|
||||
{
|
||||
var validator = new OperationTrackingOptionsValidator();
|
||||
Assert.True(validator.Validate(null, new OperationTrackingOptions()).Succeeded);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EmptyConnectionString_Fails()
|
||||
{
|
||||
var validator = new OperationTrackingOptionsValidator();
|
||||
var result = validator.Validate(null, new OperationTrackingOptions { ConnectionString = "" });
|
||||
Assert.False(result.Succeeded);
|
||||
Assert.Contains(result.Failures!,
|
||||
f => f.Contains(nameof(OperationTrackingOptions.ConnectionString), StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ZeroRetentionDays_Fails()
|
||||
{
|
||||
var validator = new OperationTrackingOptionsValidator();
|
||||
var result = validator.Validate(null, new OperationTrackingOptions { RetentionDays = 0 });
|
||||
Assert.False(result.Succeeded);
|
||||
Assert.Contains(result.Failures!,
|
||||
f => f.Contains(nameof(OperationTrackingOptions.RetentionDays), StringComparison.Ordinal));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user