feat(historian): QuestDb provider, registry + consumer-gated validator, compose env
Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
This commit is contained in:
+43
@@ -6,6 +6,7 @@ using Xunit;
|
||||
using ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway;
|
||||
using ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway.Recorder;
|
||||
using ZB.MOM.WW.OtOpcUa.Core.Abstractions;
|
||||
using ZB.MOM.WW.OtOpcUa.Driver.Historian.QuestDb;
|
||||
using ZB.MOM.WW.OtOpcUa.Driver.Historian.SqlServer;
|
||||
using ZB.MOM.WW.OtOpcUa.Host.Configuration;
|
||||
using ZB.MOM.WW.OtOpcUa.Runtime.Historian;
|
||||
@@ -86,4 +87,46 @@ public sealed class HistorianBackendRegistryTests
|
||||
holder.Updater.ShouldNotBeNull();
|
||||
holder.Updater!.GetType().Name.ShouldBe("SqlServerHistorianDataUpdater");
|
||||
}
|
||||
|
||||
private static IConfiguration QuestDbCfg() => new ConfigurationBuilder().AddInMemoryCollection(new Dictionary<string, string?>
|
||||
{
|
||||
["ServerHistorian:QuestDb:ConnectionString"] = "Host=localhost;Port=18812;Username=admin;Password=quest;Database=qdb",
|
||||
["ServerHistorian:QuestDb:TablePrefix"] = "rig_",
|
||||
}).Build();
|
||||
|
||||
[Theory]
|
||||
[InlineData("questdb")]
|
||||
[InlineData("QUESTDB")]
|
||||
[InlineData("QuestDb")]
|
||||
public void QuestDb_backend_resolves_case_insensitively(string name) =>
|
||||
HistorianBackendRegistry.Resolve(new ServerHistorianOptions { Backend = name, Enabled = true }, QuestDbCfg())
|
||||
.ShouldBeOfType<QuestDbHistorianProvider>().Name.ShouldBe("QuestDb");
|
||||
|
||||
[Fact]
|
||||
public void QuestDb_backend_resolves_and_builds_the_questdb_seams()
|
||||
{
|
||||
var sp = new ServiceCollection().BuildServiceProvider();
|
||||
var p = HistorianBackendRegistry.Resolve(new ServerHistorianOptions { Backend = "questdb", Enabled = true }, QuestDbCfg());
|
||||
|
||||
p.ShouldBeOfType<QuestDbHistorianProvider>();
|
||||
HistorianBackendRegistry.KnownBackends.ShouldContain("QuestDb");
|
||||
p.SupportedKinds.Count.ShouldBe(6);
|
||||
p.SupportedKinds.ShouldContain(HistorianValueKind.String);
|
||||
p.SupportedKinds.ShouldContain(HistorianValueKind.Empty);
|
||||
p.CreateDataSource(sp).ShouldBeOfType<QuestDbHistorianDataSource>();
|
||||
p.CreateValueWriter(sp).GetType().Name.ShouldBe("QuestDbHistorianValueWriter");
|
||||
p.CreateAlarmWriter(sp).GetType().Name.ShouldBe("QuestDbAlarmHistorianWriter");
|
||||
p.CreateProvisioning(sp).GetType().Name.ShouldBe("QuestDbTagProvisioner");
|
||||
var holder = new HistorianUpdaterHolder(p.CreateUpdater(sp));
|
||||
holder.Updater.ShouldNotBeNull();
|
||||
holder.Updater!.GetType().Name.ShouldBe("QuestDbHistorianDataUpdater");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BindQuestDb_reads_the_QuestDb_section()
|
||||
{
|
||||
var o = HistorianBackendRegistry.BindQuestDb(QuestDbCfg());
|
||||
o.ConnectionString.ShouldContain("Port=18812");
|
||||
o.TablePrefix.ShouldBe("rig_");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user