test(gateway): cover failback reason, FromFeed/SinceUtc badge paths; style + bounded drain (Tests-032..035)
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user