perf(comms): alarms-only seed, capped buffers, at-least-once audit pull
This commit is contained in:
@@ -530,4 +530,54 @@ public class SiteStreamGrpcServerTests : TestKit
|
||||
|
||||
Assert.True(condition(), $"Condition not met within {timeoutMs}ms");
|
||||
}
|
||||
|
||||
// ── WP2.3: the site-wide alarm feed gets its OWN, larger send channel ──
|
||||
|
||||
[Fact]
|
||||
public void SiteAlarmStream_HasItsOwnLargerChannel_ThanTheDebugView()
|
||||
{
|
||||
// Sharing the Debug View's 1000-slot DropOldest channel meant an alarm burst during
|
||||
// a WAN stall silently evicted operator-visible transitions to make room for
|
||||
// diagnostics traffic. The two feeds are now sized independently.
|
||||
var options = Microsoft.Extensions.Options.Options.Create(new CommunicationOptions());
|
||||
var server = new SiteStreamGrpcServer(_subscriber, _logger, options);
|
||||
|
||||
Assert.Equal(1000, server.InstanceChannelCapacity);
|
||||
Assert.Equal(20_000, server.SiteAlarmChannelCapacity);
|
||||
Assert.True(server.SiteAlarmChannelCapacity > server.InstanceChannelCapacity);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ChannelCapacities_AreBoundFromOptions_AndFloorAtOne()
|
||||
{
|
||||
var options = Microsoft.Extensions.Options.Options.Create(new CommunicationOptions
|
||||
{
|
||||
GrpcInstanceStreamChannelCapacity = 42,
|
||||
GrpcSiteAlarmStreamChannelCapacity = 4242,
|
||||
});
|
||||
var server = new SiteStreamGrpcServer(_subscriber, _logger, options);
|
||||
|
||||
Assert.Equal(42, server.InstanceChannelCapacity);
|
||||
Assert.Equal(4242, server.SiteAlarmChannelCapacity);
|
||||
|
||||
// A misconfigured zero/negative capacity must not throw at channel-construction
|
||||
// time deep inside a live RPC — it floors at one instead.
|
||||
var degenerate = new SiteStreamGrpcServer(_subscriber, _logger,
|
||||
Microsoft.Extensions.Options.Options.Create(new CommunicationOptions
|
||||
{
|
||||
GrpcInstanceStreamChannelCapacity = 0,
|
||||
GrpcSiteAlarmStreamChannelCapacity = -5,
|
||||
}));
|
||||
Assert.Equal(1, degenerate.InstanceChannelCapacity);
|
||||
Assert.Equal(1, degenerate.SiteAlarmChannelCapacity);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DroppedStreamEventCount_StartsAtZero()
|
||||
{
|
||||
// The raw counter behind scadabridge.site.stream.events_dropped — a fresh node has
|
||||
// evicted nothing.
|
||||
var server = CreateServer();
|
||||
Assert.Equal(0, server.DroppedStreamEventCount);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user