test(gateway): cover failback reason, FromFeed/SinceUtc badge paths; style + bounded drain (Tests-032..035)

This commit is contained in:
Joseph Doherty
2026-06-15 02:46:06 -04:00
parent b57d02cc4d
commit 56dd56954b
5 changed files with 328 additions and 15 deletions
@@ -312,21 +312,35 @@ public sealed class AlarmFailoverEndToEndTests
WaitTimeout);
// New subscriber: its initial cache snapshot must carry the degraded flags.
// Bound the drain so a regression that never emits SnapshotComplete fails
// with a clean TimeoutException (via cancellation) instead of hanging.
using CancellationTokenSource newStreamCts = new();
using CancellationTokenSource drainTimeoutCts = new();
drainTimeoutCts.CancelAfter(WaitTimeout);
using CancellationTokenSource linkedDrainCts =
CancellationTokenSource.CreateLinkedTokenSource(newStreamCts.Token, drainTimeoutCts.Token);
ActiveAlarmSnapshot? initialActiveAlarm = null;
await foreach (AlarmFeedMessage message in monitor.StreamAsync(null, newStreamCts.Token))
try
{
if (message.PayloadCase == AlarmFeedMessage.PayloadOneofCase.ActiveAlarm
&& message.ActiveAlarm.AlarmFullReference == "Galaxy!Area.Tank02.Lo")
await foreach (AlarmFeedMessage message in monitor.StreamAsync(null, linkedDrainCts.Token))
{
initialActiveAlarm = message.ActiveAlarm;
}
if (message.PayloadCase == AlarmFeedMessage.PayloadOneofCase.ActiveAlarm
&& message.ActiveAlarm.AlarmFullReference == "Galaxy!Area.Tank02.Lo")
{
initialActiveAlarm = message.ActiveAlarm;
}
if (message.PayloadCase == AlarmFeedMessage.PayloadOneofCase.SnapshotComplete)
{
break;
if (message.PayloadCase == AlarmFeedMessage.PayloadOneofCase.SnapshotComplete)
{
break;
}
}
}
catch (OperationCanceledException) when (drainTimeoutCts.IsCancellationRequested)
{
throw new TimeoutException(
"The new subscriber did not receive a SnapshotComplete message within the timeout.");
}
Assert.NotNull(initialActiveAlarm);
Assert.True(initialActiveAlarm!.Degraded);