[Fix] (IntegrationTest): assert actual staging backpressure in the small ring lane

This commit is contained in:
2026-09-16 12:34:33 -04:00
parent 6fa6a925bd
commit d50183cb1a
10 changed files with 88 additions and 26 deletions
@@ -19,10 +19,21 @@
#include <MG_Remote/Client/ClientSession.h>
#include <MG_Remote/Client/EmitTables.h>
#include <MG_Remote/Server/ServerLoop.h>
#include <chrono>
#include <thread>
#define MGITEST_SPLIT_RUNTIME_PEEK_LIVE 1
#endif
namespace MGITest {
void DelaySplitRetirementForTesting(bool enabled) {
#if defined(MGITEST_SPLIT_RUNTIME_PEEK_LIVE)
MobileGL::MG_Remote::Server::ServerLoopInstance().SetBeforeRetireHookForTesting(
enabled ? +[] { std::this_thread::sleep_for(std::chrono::milliseconds(30)); } : nullptr);
#else
(void)enabled;
#endif
}
SplitRuntimeState PeekSplitRuntime() {
SplitRuntimeState state;
@@ -91,9 +91,8 @@ namespace MGITest {
// than asserted: a uniform record stride over a power-of-two ring lands on the
// boundary exactly and never straddles it.
//
// stageReclaimWaits: SEG_STAGE allocations that only fitted after the encoder reclaimed
// what the server had retired - P5's one real producer wait (see PipeWireCodec.h for
// why the command ring has none while the verb barrier is armed).
// stageReclaimWaits: allocations blocked after immediate reclamation failed;
// already-retired bytes reclaimed lazily do not count as a wait.
unsigned long long maxRecordBytes = 0;
unsigned long long maxRecordBytesCap = 0;
unsigned long long cmdWraps = 0;
@@ -103,6 +102,8 @@ namespace MGITest {
};
SplitRuntimeState PeekSplitRuntime();
// Scheduling-only perturbation; never changes a watermark or counter.
void DelaySplitRetirementForTesting(bool enabled);
// Empty when this process is a real split run that can be asserted about; otherwise the
// reason to GTEST_SKIP() with, naming the first fact that is not true and the package that
@@ -134,6 +134,9 @@ namespace MGITest::WireLedger {
"kSmallRingLaneCmdByteTarget, which is sized for the 1 MiB ring this lane "
"declares (MGL_ITEST_GLES_SPLIT_SMALL_RING_ENVIRONMENT); a larger ring needs a "
"larger workload and is not what this lane is for";
EXPECT_GE(state.stageReclaimWaits, 1u)
<< where << ": exit gate E3(e) - producer NEVER WAITED for staging retirement; "
"lazy reclamation of already-retired bytes is not back-pressure";
::testing::Test::RecordProperty("ring_wraps", static_cast<int>(state.cmdWraps));
::testing::Test::RecordProperty("ring_wrap_pads", static_cast<int>(state.cmdWrapPads));
::testing::Test::RecordProperty("ring_waits", static_cast<int>(state.stageReclaimWaits));