test(comm): de-race StreamRelay null-map + SiteConnectionUp gauge under load (#288)

This commit is contained in:
Joseph Doherty
2026-06-19 05:00:13 -04:00
parent ab40534986
commit 84cb8c2abb
2 changed files with 21 additions and 5 deletions
@@ -279,8 +279,16 @@ public class StreamRelayActorTests : TestKit
var ts = DateTimeOffset.UtcNow;
actor.Tell(new AttributeValueChanged("Inst", "Path", "Name", null, "Good", ts));
Thread.Sleep(500);
Assert.True(channel.Reader.TryRead(out var evt));
// Poll for the relayed event with a generous timeout instead of a single
// fixed Thread.Sleep + one-shot TryRead. Under full-suite CPU
// oversubscription the actor may not have processed the Tell within a
// fixed 500ms window, racing the read; AwaitAssert retries until the
// channel has the item (or the generous deadline elapses).
SiteStreamEvent? evt = null;
AwaitAssert(
() => Assert.True(channel.Reader.TryRead(out evt), "Expected a relayed proto event on the channel"),
TimeSpan.FromSeconds(5));
Assert.NotNull(evt);
Assert.Equal("", evt.AttributeChanged.Value);
}