feat: expose mapped raw and uns data through grpc adapters
This commit is contained in:
+24
-7
@@ -20,6 +20,8 @@ public sealed class GrpcDataLocalConnectionTests
|
||||
await using var connection = fixture.Services.Create(context, new(DataTargetMode.Node, "cluster", "node-a"));
|
||||
var budget = LocalDataFixture.Budget with { MaxItems = 1 };
|
||||
var branch = await connection.BrowseAsync(new(fixture.Root, null, null, budget), TestContext.Current.CancellationToken);
|
||||
branch.Serving.ShouldNotBeNull();
|
||||
branch.Items.ShouldAllBe(x => x.Serving == branch.Serving);
|
||||
branch.Status.ShouldBe(DataItemStatus.Good);
|
||||
branch.Lease!.Duration.ShouldBeLessThanOrEqualTo(TimeSpan.FromSeconds(1));
|
||||
branch.Continuation.ShouldNotBeNull();
|
||||
@@ -127,15 +129,16 @@ internal sealed class LocalDataFixture : IDisposable
|
||||
internal LocalDataFixture(int additionalRawNodes = 0,
|
||||
Func<DataAuthenticatedContext, IDataSubscriptionService>? subscriptions = null,
|
||||
Func<DataAuthenticatedContext, DataTarget, IDataSubscriptionService>? targetSubscriptions = null,
|
||||
bool advanceAuthority = false, string role = "Primary")
|
||||
bool advanceAuthority = false, string role = "Primary", long servingGeneration = 0, bool nestedCatalog = false, bool nestedUnsCatalog = false)
|
||||
{
|
||||
Serving = Serving with { Role = role };
|
||||
Serving = Serving with { Role = role, ServingGeneration = servingGeneration };
|
||||
Hub = HubTest.Create(clock: Clock, bytes: 1_000_000);
|
||||
Hub.TryBind(Ticket).ShouldBeTrue();
|
||||
var key = new ApiKey { ApiKeyId = "peer-key", Name = "peer-key", Principal = "peer", SecretHash = "hash", Enabled = true };
|
||||
Authority.Apply("cluster", "first", [key],
|
||||
[new NodeAcl { NodeAclId = "grant", ClusterId = "cluster", Principal = "peer", ScopeKind = NodeAclScopeKind.RawFolder,
|
||||
ScopeId = "folder", PermissionFlags = NodePermissions.ReadOnly }],
|
||||
[new NodeAcl { NodeAclId = "grant", ClusterId = "cluster", Principal = "peer",
|
||||
ScopeKind = nestedUnsCatalog ? NodeAclScopeKind.Cluster : NodeAclScopeKind.RawFolder,
|
||||
ScopeId = nestedUnsCatalog ? null : "folder", PermissionFlags = NodePermissions.ReadOnly }],
|
||||
new Dictionary<AclScopeRef, IReadOnlyList<NodeAclPath>> { [new(NodeAclScopeKind.RawFolder, "folder")] = [new(["raw", "Plant"])] });
|
||||
if (advanceAuthority)
|
||||
{
|
||||
@@ -153,10 +156,24 @@ internal sealed class LocalDataFixture : IDisposable
|
||||
var rootMetadata = new DataMetadata(Root, "Plant", "Folder", DataValueKind.Null, -1, [], false, operations, 1, null, null, false);
|
||||
var rawMetadata = new DataMetadata(Raw, "Speed", "Variable", DataValueKind.Int32, -1, [], true, operations, 1, Ticket.Key.StableSourceId, "rpm", false);
|
||||
var unsMetadata = rawMetadata with { View = Uns };
|
||||
var folder = Root with { Address = Root.Address with { Identifier = "Plant/Driver" }, Subject = "Plant/Driver" };
|
||||
var unsRoot = Uns with { Address = Uns.Address with { Identifier = "Area" }, Subject = "Area" };
|
||||
var nodes = new List<LocalDataNode>
|
||||
{new("RawFolder", "folder", rootMetadata, new() { ClusterId = "cluster", Kind = NodeHierarchyKind.Raw, Segments = ["Plant"] }, null, null),
|
||||
new("RawTag", "tag", rawMetadata, new() { ClusterId = "cluster", Kind = NodeHierarchyKind.Raw, Segments = ["Plant", "Driver", "Device", "Speed"] }, Root, Ticket.Key),
|
||||
new("UnsTagReference", "reference", unsMetadata, new() { ClusterId = "cluster", Kind = NodeHierarchyKind.Uns, Segments = ["Area", "Line", "Equipment", "Speed"] }, null, Ticket.Key)};
|
||||
new("RawTag", "tag", rawMetadata, new() { ClusterId = "cluster", Kind = NodeHierarchyKind.Raw, Segments = ["Plant", "Driver", "Device", "Speed"] }, nestedCatalog ? folder : Root, Ticket.Key),
|
||||
new("UnsTagReference", "reference", unsMetadata, new() { ClusterId = "cluster", Kind = NodeHierarchyKind.Uns, Segments = ["Area", "Line", "Equipment", "Speed"] }, nestedUnsCatalog ? unsRoot : null, Ticket.Key)};
|
||||
if (nestedUnsCatalog)
|
||||
nodes.Add(new("UnsArea", "area", rootMetadata with { View = unsRoot, BrowseName = "Area" },
|
||||
new() { ClusterId = "cluster", Kind = NodeHierarchyKind.Uns, Segments = ["Area"] }, null, null));
|
||||
if (nestedCatalog)
|
||||
{
|
||||
nodes.Add(new("RawFolder", "nested-folder", rootMetadata with { View = folder, BrowseName = "Driver" },
|
||||
new() { ClusterId = "cluster", Kind = NodeHierarchyKind.Raw, Segments = ["Plant", "Driver"] }, Root, null));
|
||||
var array = Raw with { Address = Raw.Address with { Identifier = "Plant/Driver/Array" }, Subject = "Plant/Driver/Array" };
|
||||
nodes.Add(new("RawTag", "array", rawMetadata with { View = array, BrowseName = "Array", ValueKind = DataValueKind.Array,
|
||||
ValueRank = 1, Dimensions = [3], ArrayElementKind = DataValueKind.UInt8 },
|
||||
new() { ClusterId = "cluster", Kind = NodeHierarchyKind.Raw, Segments = ["Plant", "Driver", "Array"] }, folder, Ticket.Key));
|
||||
}
|
||||
for (var i = 0; i < additionalRawNodes; i++)
|
||||
{
|
||||
var view = Raw with { Address = Raw.Address with { Identifier = Raw.Address.Identifier + i }, Subject = Raw.Subject + i };
|
||||
@@ -165,7 +182,7 @@ internal sealed class LocalDataFixture : IDisposable
|
||||
}
|
||||
Catalog = new LocalExportCatalog("cluster", Serving, Activation.CaptureAuthority(), nodes,
|
||||
[new() { DataExportId = "raw-export", ClusterId = "cluster", Enabled = true, Realm = DataRealm.Raw, RootKind = "RawFolder", RootEntityId = "folder", PrincipalId = "peer", AllowedOperations = operations },
|
||||
new() { DataExportId = "uns-export", ClusterId = "cluster", Enabled = true, Realm = DataRealm.Uns, RootKind = "UnsTagReference", RootEntityId = "reference", PrincipalId = "peer", AllowedOperations = operations }]);
|
||||
new() { DataExportId = "uns-export", ClusterId = "cluster", Enabled = true, Realm = DataRealm.Uns, RootKind = nestedUnsCatalog ? "UnsArea" : "UnsTagReference", RootEntityId = nestedUnsCatalog ? "area" : "reference", PrincipalId = "peer", AllowedOperations = operations }]);
|
||||
var limits = new DataLimits(100, 100, 1_000_000, 100, 10, 1_000_000, TimeSpan.FromSeconds(15), TimeSpan.FromHours(1), TimeSpan.FromMinutes(1));
|
||||
var capabilities = new DataCapabilitiesProvider("cluster", () => Serving, () => Catalog.IsActive, limits);
|
||||
Services = new LocalDataServices(() => Catalog, Hub, new DataOperationPolicy(Authority,
|
||||
|
||||
Reference in New Issue
Block a user