From 4e76eeb57f30d89bbbb1e8dae8480aba4d7e5499 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Mon, 9 Nov 2026 15:19:23 -0500 Subject: [PATCH] test(historian): Gateway advertises TimeAverage/Total only behind EnableNativeTimeWeighted (lmxopcua#746) HistorianBackendRegistryTests (#682) still expected the Gateway data source to advertise the two AVEVA-native aggregates. Lane H2 (R08:2.1) refuses them by default until historiangw#27, and the lane branch never updated this Host test, so it failed after the rebase. The default case now expects the ten raw-evaluated aggregates, and a new case pins that ServerHistorian:Gateway:EnableNativeTimeWeighted=true, resolved through the Host's registry, brings TimeAverage and Total back. Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV --- .../HistorianBackendRegistryTests.cs | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.Host.Tests/Configuration/HistorianBackendRegistryTests.cs b/tests/Server/ZB.MOM.WW.OtOpcUa.Host.Tests/Configuration/HistorianBackendRegistryTests.cs index b276067b..21f9eb95 100644 --- a/tests/Server/ZB.MOM.WW.OtOpcUa.Host.Tests/Configuration/HistorianBackendRegistryTests.cs +++ b/tests/Server/ZB.MOM.WW.OtOpcUa.Host.Tests/Configuration/HistorianBackendRegistryTests.cs @@ -149,15 +149,24 @@ public sealed class HistorianBackendRegistryTests IHistorianDataSource Source(ServerHistorianOptions o, IConfiguration c) => HistorianBackendRegistry.Resolve(o, c).CreateDataSource(sp); - // #681: the ten per-sample aggregates (raw-evaluated) + the two AVEVA-native ones. - Source(Gateway(), Cfg).SupportedAggregates.ShouldBe( - [ - HistoryAggregateType.Average, HistoryAggregateType.Count, HistoryAggregateType.Minimum, - HistoryAggregateType.Maximum, HistoryAggregateType.Range, HistoryAggregateType.Start, HistoryAggregateType.End, - HistoryAggregateType.Delta, HistoryAggregateType.MinimumActualTime, HistoryAggregateType.MaximumActualTime, - HistoryAggregateType.TimeAverage, HistoryAggregateType.Total, - ], - ignoreOrder: true); + // #681: the ten per-sample aggregates (raw-evaluated). The two AVEVA-native ones (TimeAverage / Total) are + // refused and not advertised by default until historiangw#27 is fixed (#746, R08:2.1) ... + HistoryAggregateType[] gatewayRawEvaluated = + [ + HistoryAggregateType.Average, HistoryAggregateType.Count, HistoryAggregateType.Minimum, + HistoryAggregateType.Maximum, HistoryAggregateType.Range, HistoryAggregateType.Start, HistoryAggregateType.End, + HistoryAggregateType.Delta, HistoryAggregateType.MinimumActualTime, HistoryAggregateType.MaximumActualTime, + ]; + Source(Gateway(), Cfg).SupportedAggregates.ShouldBe(gatewayRawEvaluated, ignoreOrder: true); + + // ... and served again, through the Host's resolve path, once ServerHistorian:Gateway:EnableNativeTimeWeighted is on. + var nativeOn = new ServerHistorianOptions + { + Backend = "Gateway", Enabled = true, Endpoint = "http://localhost:5222", ApiKey = "histgw_id_secret", UseTls = false, + Gateway = new GatewayHistorianSettings { EnableNativeTimeWeighted = true }, + }; + Source(nativeOn, Cfg).SupportedAggregates.ShouldBe( + [.. gatewayRawEvaluated, HistoryAggregateType.TimeAverage, HistoryAggregateType.Total], ignoreOrder: true); Source(new ServerHistorianOptions { Backend = "SqlServer", Enabled = true }, SqlCfg()) .SupportedAggregates.ShouldBe(SqlServed, ignoreOrder: true); Source(new ServerHistorianOptions { Backend = "QuestDb", Enabled = true }, QuestDbCfg())