fix(mtconnect): the Agent refuses count ABOVE bufferSize, not at it (#825)

Live gate against the cppagent 2.7 fixture: count=16384 with bufferSize
16384 streams; 16385 is OUT_OF_RANGE ('count' must be less than 16385).
Warn only when SampleCount > bufferSize, pin both sides of the edge
against the live Agent, and correct the #804 wording that said 'at or
above'.
This commit is contained in:
Joseph Doherty
2026-11-11 01:38:48 -05:00
parent f8f6781a24
commit 8a6f0e3c84
11 changed files with 41 additions and 29 deletions
@@ -868,7 +868,7 @@ public sealed class MTConnectAgentIntegrationTests(MTConnectAgentFixture agent)
}
/// <summary>
/// #804 — a <c>SampleCount</c> at or above the Agent's <c>bufferSize</c> is refused <c>OUT_OF_RANGE</c> on
/// #804 — a <c>SampleCount</c> above the Agent's <c>bufferSize</c> is refused <c>OUT_OF_RANGE</c> on
/// EVERY <c>/sample</c> open (live: <c>'count' must be less than N</c>). The driver keeps serving values off
/// <c>/current</c> re-baselines, and — after three in a row with no <c>/sample</c> chunk — reports the stream
/// Degraded with <c>LastSuccessfulRead</c> still advancing, rather than Healthy for ever (before #804 the
@@ -949,7 +949,8 @@ public sealed class MTConnectAgentIntegrationTests(MTConnectAgentFixture agent)
/// <summary>
/// #825 — Test Connect reads the live Agent's <c>/probe</c> <c>bufferSize</c> and warns (still Ok) when the
/// configured <c>SampleCount</c> would be refused; one below the buffer is the falsifiability control.
/// configured <c>SampleCount</c> would be refused. The live Agent accepts <c>count == bufferSize</c> and refuses
/// <c>bufferSize + 1</c>, so both sides of that edge are checked against the Agent itself as well as the probe.
/// </summary>
[Fact(Timeout = TestTimeoutMs)]
public async Task Test_Connect_warns_when_SampleCount_reaches_the_live_agents_buffer_size()
@@ -963,14 +964,22 @@ public sealed class MTConnectAgentIntegrationTests(MTConnectAgentFixture agent)
Assert.Skip($"The Agent at {agent.AgentUri} declares no usable bufferSize in its /probe header.");
}
// The Agent's own edge, so the warning threshold is pinned to what the Agent actually does.
using (var http = new HttpClient { Timeout = TimeSpan.FromSeconds(15) })
{
(await http.GetStringAsync($"{agent.AgentUri}/sample?count={bufferSize.Value}", Ct)).ShouldNotContain("OUT_OF_RANGE");
var over = await http.GetAsync($"{agent.AgentUri}/sample?count={bufferSize.Value + 1}", Ct);
(await over.Content.ReadAsStringAsync(Ct)).ShouldContain("OUT_OF_RANGE");
}
var refused = await new MTConnectDriverProbe().ProbeAsync(
JsonSerializer.Serialize(new { agentUri = agent.AgentUri, sampleCount = bufferSize.Value }),
JsonSerializer.Serialize(new { agentUri = agent.AgentUri, sampleCount = bufferSize.Value + 1 }),
TimeSpan.FromSeconds(15), Ct);
refused.Ok.ShouldBeTrue(refused.Message);
refused.Message!.ShouldContain($"WARNING: SampleCount {bufferSize.Value} is at or above the Agent's bufferSize {bufferSize.Value}");
refused.Message!.ShouldContain($"WARNING: SampleCount {bufferSize.Value + 1} is above the Agent's bufferSize {bufferSize.Value}");
var fits = await new MTConnectDriverProbe().ProbeAsync(
JsonSerializer.Serialize(new { agentUri = agent.AgentUri, sampleCount = bufferSize.Value - 1 }),
JsonSerializer.Serialize(new { agentUri = agent.AgentUri, sampleCount = bufferSize.Value }),
TimeSpan.FromSeconds(15), Ct);
fits.Ok.ShouldBeTrue(fits.Message);
fits.Message!.ShouldNotContain("WARNING");