43 lines
2.5 KiB
C#
43 lines
2.5 KiB
C#
using Akka.Actor;
|
|
using Shouldly;
|
|
using Xunit;
|
|
using ZB.MOM.WW.OtOpcUa.Core.Abstractions.DataConnections;
|
|
using ZB.MOM.WW.OtOpcUa.Core.Authorization;
|
|
using ZB.MOM.WW.OtOpcUa.Runtime.DataConnections;
|
|
using ZB.MOM.WW.OtOpcUa.Runtime.Drivers;
|
|
using ZB.MOM.WW.OtOpcUa.Runtime.Redundancy;
|
|
using ZB.MOM.WW.OtOpcUa.Runtime.Tests.Harness;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Runtime.Tests.DataConnections;
|
|
|
|
[Trait("Category", "Unit"), Trait("Feature", "GrpcData"), Trait("Phase", "P07")]
|
|
public sealed class GrpcDataLocalCompositionTests : RuntimeActorTestBase
|
|
{
|
|
private sealed class PassiveActor : ReceiveActor { }
|
|
|
|
[Fact]
|
|
public void One_composition_shares_the_given_process_capacity_and_rejects_mismatched_clock()
|
|
{
|
|
var clock = TimeProvider.System;
|
|
var fence = new DataWriteDispatchFence(); var authority = new DataPlaneAuthorityState(fence);
|
|
var activation = new CatalogActivation(fence); var role = new RedundancyRoleView(fence);
|
|
var serving = new ServingIdentity("node", "boot", "Primary", 0, 0);
|
|
var catalog = new LocalCatalogCoordinator(activation, authority, () => serving);
|
|
var limits = new DataLimits(100, 100, 1_000_000, 100, 10, 1_000_000, TimeSpan.FromSeconds(15), TimeSpan.FromHours(1), TimeSpan.FromMinutes(1));
|
|
var caps = new DataCapabilitiesProvider("cluster", () => serving, () => false, limits);
|
|
var policy = new DataOperationPolicy(authority, new TriePermissionEvaluator(authority.Tries, clock), clock);
|
|
var bounds = new DriverWriteBounds(TimeSpan.FromMilliseconds(300));
|
|
var writes = new DataWriteRuntime(catalog, activation, authority, policy, caps, role, clock, bounds, "boot", 16, 16_384, 16_384, 4, TimeSpan.FromMinutes(1));
|
|
using var hub = HubTest.Create(clock: clock, bytes: 1_000_000);
|
|
var host = Sys.ActorOf(Props.Create(() => new PassiveActor()));
|
|
var shared = new SubscriptionAcquisitionCapacity(8);
|
|
var config = new LocalDataRuntimeLimits(8, 128, 8, 4, 1_000_000, 16, 16, 100_000, TimeSpan.FromMinutes(5), TimeSpan.FromSeconds(2));
|
|
using var runtime = new LocalDataRuntimeComposition(catalog, hub, policy, caps, clock, writes, host, shared, config);
|
|
runtime.AcquisitionCapacity.ShouldBeSameAs(shared);
|
|
runtime.Services.ShouldNotBeNull();
|
|
runtime.Services.Clock.ShouldBeSameAs(clock);
|
|
Should.Throw<ArgumentException>(() => new LocalDataRuntimeComposition(catalog, hub, policy, caps,
|
|
new ManualTimeProvider(), writes, host, shared, config));
|
|
}
|
|
}
|