test: migrate AdminUI/ControlPlane/Runtime/Host tests to xunit.v3 (#756)
v2-ci / unit-tests (push) Failing after 13m22s
v2-ci / unit-tests (push) Failing after 13m22s
Akka.TestKit.Xunit2 -> Akka.TestKit.Xunit 1.5.62 (xunit.v3 TestKit; needs xunit.v3 3.2.2, set via VersionOverride on the four projects). Removes the xunit 2.9.3 pin. IAsyncLifetime returns ValueTask, SqlServerFactAttribute gains the source-info ctor, and xUnit1051 call sites pass TestContext.Current.CancellationToken. Test counts unchanged. Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
This commit is contained in:
+40
-40
@@ -33,17 +33,17 @@ public sealed class DriverInstanceActorNativeAlarmTests : RuntimeActorTestBase
|
||||
// #477: DriverInstanceActor now Tells the parent ConnectivityChanged on each connect/
|
||||
// disconnect; these tests assert on the data/alarm/discovery forwards, so ignore it.
|
||||
parent.IgnoreMessages(m => m is DriverInstanceActor.ConnectivityChanged);
|
||||
var actor = parent.ChildActorOf(DriverInstanceActor.Props(driver));
|
||||
var actor = parent.ChildActorOf(DriverInstanceActor.Props(driver), TestContext.Current.CancellationToken);
|
||||
|
||||
actor.Tell(new DriverInstanceActor.InitializeRequested("{}"));
|
||||
AwaitCondition(() => driver.InitializeCount > 0, TimeSpan.FromSeconds(2));
|
||||
AwaitCondition(() => driver.InitializeCount > 0, TimeSpan.FromSeconds(2), TestContext.Current.CancellationToken);
|
||||
// The alarm handler is attached after Become(Connected); wait for it to be wired before raising.
|
||||
AwaitCondition(() => driver.AlarmSubscriberCount == 1, TimeSpan.FromSeconds(2));
|
||||
AwaitCondition(() => driver.AlarmSubscriberCount == 1, TimeSpan.FromSeconds(2), TestContext.Current.CancellationToken);
|
||||
// Also establish a data-change subscription so the OnDataChange path is wired (the alarm attach is
|
||||
// independent of Subscribe — this proves both event paths coexist on one driver).
|
||||
await actor.Ask<DriverInstanceActor.SubscriptionEstablished>(
|
||||
new DriverInstanceActor.Subscribe(new[] { "tag-z" }, TimeSpan.FromMilliseconds(100)),
|
||||
TimeSpan.FromSeconds(3));
|
||||
TimeSpan.FromSeconds(3), TestContext.Current.CancellationToken);
|
||||
|
||||
driver.RaiseAlarm(new AlarmEventArgs(
|
||||
new StubAlarmHandle(),
|
||||
@@ -55,7 +55,7 @@ public sealed class DriverInstanceActorNativeAlarmTests : RuntimeActorTestBase
|
||||
SourceTimestampUtc: DateTime.UtcNow,
|
||||
Kind: AlarmTransitionKind.Raise));
|
||||
|
||||
var published = parent.ExpectMsg<DriverInstanceActor.AttributeAlarmPublished>(TimeSpan.FromSeconds(2));
|
||||
var published = parent.ExpectMsg<DriverInstanceActor.AttributeAlarmPublished>(TimeSpan.FromSeconds(2), cancellationToken: TestContext.Current.CancellationToken);
|
||||
published.DriverInstanceId.ShouldBe(driver.DriverInstanceId);
|
||||
published.Args.SourceNodeId.ShouldBe("src-node-7");
|
||||
published.Args.ConditionId.ShouldBe("cond-1");
|
||||
@@ -63,7 +63,7 @@ public sealed class DriverInstanceActorNativeAlarmTests : RuntimeActorTestBase
|
||||
|
||||
// The same driver's OnDataChange still flows independently — alarm + value events coexist.
|
||||
driver.FireDataChange("tag-z", value: 9.0, statusCode: 0u);
|
||||
parent.ExpectMsg<DriverInstanceActor.AttributeValueBatchPublished>(TimeSpan.FromSeconds(2))
|
||||
parent.ExpectMsg<DriverInstanceActor.AttributeValueBatchPublished>(TimeSpan.FromSeconds(2), cancellationToken: TestContext.Current.CancellationToken)
|
||||
.Items[0].FullReference.ShouldBe("tag-z");
|
||||
}
|
||||
|
||||
@@ -83,17 +83,17 @@ public sealed class DriverInstanceActorNativeAlarmTests : RuntimeActorTestBase
|
||||
// #477: DriverInstanceActor now Tells the parent ConnectivityChanged on each connect/
|
||||
// disconnect; these tests assert on the data/alarm/discovery forwards, so ignore it.
|
||||
parent.IgnoreMessages(m => m is DriverInstanceActor.ConnectivityChanged);
|
||||
var actor = parent.ChildActorOf(DriverInstanceActor.Props(driver));
|
||||
var actor = parent.ChildActorOf(DriverInstanceActor.Props(driver), TestContext.Current.CancellationToken);
|
||||
|
||||
actor.Tell(new DriverInstanceActor.InitializeRequested("{}"));
|
||||
AwaitCondition(() => driver.AlarmSubscriberCount == 1, TimeSpan.FromSeconds(2)); // reached Connected
|
||||
AwaitCondition(() => driver.AlarmSubscriberCount == 1, TimeSpan.FromSeconds(2), TestContext.Current.CancellationToken); // reached Connected
|
||||
driver.SubscribeAlarmsCallCount.ShouldBe(0, "no alarm subscription before any alarm refs are pushed");
|
||||
|
||||
// A deploy delivers the desired set with a native-alarm ref while the driver is already Connected.
|
||||
actor.Tell(new DriverInstanceActor.SetDesiredSubscriptions(
|
||||
Array.Empty<string>(), TimeSpan.FromMilliseconds(100), new[] { "Temp.HiHi" }));
|
||||
|
||||
AwaitCondition(() => driver.SubscribeAlarmsCallCount == 1, TimeSpan.FromSeconds(2));
|
||||
AwaitCondition(() => driver.SubscribeAlarmsCallCount == 1, TimeSpan.FromSeconds(2), TestContext.Current.CancellationToken);
|
||||
driver.LastAlarmRefs.ShouldBe(new[] { "Temp.HiHi" });
|
||||
|
||||
// Redeploying the same alarm set must NOT re-subscribe (idempotent — already un-gated). Round-trip a
|
||||
@@ -102,7 +102,7 @@ public sealed class DriverInstanceActorNativeAlarmTests : RuntimeActorTestBase
|
||||
Array.Empty<string>(), TimeSpan.FromMilliseconds(100), new[] { "Temp.HiHi" }));
|
||||
await actor.Ask<DriverInstanceActor.SubscriptionEstablished>(
|
||||
new DriverInstanceActor.Subscribe(new[] { "tag-z" }, TimeSpan.FromMilliseconds(100)),
|
||||
TimeSpan.FromSeconds(3));
|
||||
TimeSpan.FromSeconds(3), TestContext.Current.CancellationToken);
|
||||
driver.SubscribeAlarmsCallCount.ShouldBe(1, "an already-established alarm subscription is not re-issued");
|
||||
}
|
||||
|
||||
@@ -119,22 +119,22 @@ public sealed class DriverInstanceActorNativeAlarmTests : RuntimeActorTestBase
|
||||
// #477: DriverInstanceActor now Tells the parent ConnectivityChanged on each connect/
|
||||
// disconnect; these tests assert on the data/alarm/discovery forwards, so ignore it.
|
||||
parent.IgnoreMessages(m => m is DriverInstanceActor.ConnectivityChanged);
|
||||
var actor = parent.ChildActorOf(DriverInstanceActor.Props(driver));
|
||||
var actor = parent.ChildActorOf(DriverInstanceActor.Props(driver), TestContext.Current.CancellationToken);
|
||||
|
||||
actor.Tell(new DriverInstanceActor.InitializeRequested("{}"));
|
||||
AwaitCondition(() => driver.InitializeCount > 0, TimeSpan.FromSeconds(2));
|
||||
AwaitCondition(() => driver.InitializeCount > 0, TimeSpan.FromSeconds(2), TestContext.Current.CancellationToken);
|
||||
|
||||
await actor.Ask<DriverInstanceActor.SubscriptionEstablished>(
|
||||
new DriverInstanceActor.Subscribe(new[] { "tag-a" }, TimeSpan.FromMilliseconds(100)),
|
||||
TimeSpan.FromSeconds(3));
|
||||
TimeSpan.FromSeconds(3), TestContext.Current.CancellationToken);
|
||||
|
||||
driver.FireDataChange("tag-a", value: 1.5, statusCode: 0u);
|
||||
|
||||
// Data-change forwarding still works (no crash on AttachAlarmSource for a non-IAlarmSource driver).
|
||||
var dc = parent.ExpectMsg<DriverInstanceActor.AttributeValueBatchPublished>(TimeSpan.FromSeconds(2));
|
||||
var dc = parent.ExpectMsg<DriverInstanceActor.AttributeValueBatchPublished>(TimeSpan.FromSeconds(2), cancellationToken: TestContext.Current.CancellationToken);
|
||||
dc.Items[0].FullReference.ShouldBe("tag-a");
|
||||
// An AttributeAlarmPublished can never be produced for a non-IAlarmSource driver.
|
||||
parent.ExpectNoMsg(TimeSpan.FromMilliseconds(300));
|
||||
parent.ExpectNoMsg(TimeSpan.FromMilliseconds(300), TestContext.Current.CancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -182,11 +182,11 @@ public sealed class DriverInstanceActorNativeAlarmTests : RuntimeActorTestBase
|
||||
// #477: DriverInstanceActor now Tells the parent ConnectivityChanged on each connect/
|
||||
// disconnect; these tests assert on the data/alarm/discovery forwards, so ignore it.
|
||||
parent.IgnoreMessages(m => m is DriverInstanceActor.ConnectivityChanged);
|
||||
var actor = parent.ChildActorOf(DriverInstanceActor.Props(driver));
|
||||
var actor = parent.ChildActorOf(DriverInstanceActor.Props(driver), TestContext.Current.CancellationToken);
|
||||
|
||||
// Drive to Connected; confirm the alarm handler is attached.
|
||||
actor.Tell(new DriverInstanceActor.InitializeRequested("{}"));
|
||||
AwaitCondition(() => driver.AlarmSubscriberCount == 1, TimeSpan.FromSeconds(2));
|
||||
AwaitCondition(() => driver.AlarmSubscriberCount == 1, TimeSpan.FromSeconds(2), TestContext.Current.CancellationToken);
|
||||
|
||||
// Enqueue ForceReconnect FIRST — the actor hasn't processed it yet, so the handler is
|
||||
// still wired. The test thread then immediately fires the alarm on the driver; the handler's
|
||||
@@ -206,16 +206,16 @@ public sealed class DriverInstanceActorNativeAlarmTests : RuntimeActorTestBase
|
||||
// The actor processes: (1) ForceReconnect → Reconnecting (handler detached);
|
||||
// (2) NativeAlarmRaised → dropped (debug log, no forward).
|
||||
// Wait generously — the default reconnect interval of 10 s means no retry fires here.
|
||||
parent.ExpectNoMsg(TimeSpan.FromMilliseconds(500));
|
||||
parent.ExpectNoMsg(TimeSpan.FromMilliseconds(500), TestContext.Current.CancellationToken);
|
||||
|
||||
// (b) The alarm must also NOT have dead-lettered — the Reconnecting state's explicit
|
||||
// Receive<NativeAlarmRaised> handler must have consumed it. If that handler were removed the
|
||||
// message would become unhandled → AllDeadLetters, and this assertion would catch the regression.
|
||||
deadLetters.ExpectNoMsg(TimeSpan.FromMilliseconds(200));
|
||||
deadLetters.ExpectNoMsg(TimeSpan.FromMilliseconds(200), TestContext.Current.CancellationToken);
|
||||
|
||||
// The actor must still be alive — Watch + no Terminated.
|
||||
Watch(actor);
|
||||
parent.ExpectNoMsg(TimeSpan.FromMilliseconds(100));
|
||||
parent.ExpectNoMsg(TimeSpan.FromMilliseconds(100), TestContext.Current.CancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -231,18 +231,18 @@ public sealed class DriverInstanceActorNativeAlarmTests : RuntimeActorTestBase
|
||||
var driver = new AlarmSourceStubDriver();
|
||||
var parent = CreateTestProbe();
|
||||
parent.IgnoreMessages(m => m is DriverInstanceActor.ConnectivityChanged);
|
||||
var actor = parent.ChildActorOf(DriverInstanceActor.Props(driver));
|
||||
var actor = parent.ChildActorOf(DriverInstanceActor.Props(driver), TestContext.Current.CancellationToken);
|
||||
|
||||
actor.Tell(new DriverInstanceActor.InitializeRequested("{}"));
|
||||
AwaitCondition(() => driver.AlarmSubscriberCount == 1, TimeSpan.FromSeconds(2));
|
||||
AwaitCondition(() => driver.AlarmSubscriberCount == 1, TimeSpan.FromSeconds(2), TestContext.Current.CancellationToken);
|
||||
actor.Tell(new DriverInstanceActor.SetDesiredSubscriptions(
|
||||
new[] { "tag-a" }, TimeSpan.FromMilliseconds(100), new[] { "Temp.HiHi" }));
|
||||
AwaitCondition(() => driver.SubscribeAlarmsCallCount == 1, TimeSpan.FromSeconds(2));
|
||||
AwaitCondition(() => driver.SubscribeAlarmsCallCount == 1, TimeSpan.FromSeconds(2), TestContext.Current.CancellationToken);
|
||||
|
||||
// A second data subscribe while the first handle is live — the drop-then-resubscribe path.
|
||||
await actor.Ask<DriverInstanceActor.SubscriptionEstablished>(
|
||||
new DriverInstanceActor.Subscribe(new[] { "tag-a", "tag-b" }, TimeSpan.FromMilliseconds(100)),
|
||||
TimeSpan.FromSeconds(3));
|
||||
TimeSpan.FromSeconds(3), TestContext.Current.CancellationToken);
|
||||
|
||||
driver.AlarmSubscriberCount.ShouldBe(1, "the data re-subscribe must not unhook OnAlarmEvent");
|
||||
driver.SubscribeAlarmsCallCount.ShouldBe(1,
|
||||
@@ -251,7 +251,7 @@ public sealed class DriverInstanceActorNativeAlarmTests : RuntimeActorTestBase
|
||||
driver.RaiseAlarm(new AlarmEventArgs(
|
||||
new StubAlarmHandle(), "Temp.HiHi", "Temp.HiHi", "T", "after re-subscribe", AlarmSeverity.High,
|
||||
DateTime.UtcNow, Kind: AlarmTransitionKind.Raise));
|
||||
parent.FishForMessage<DriverInstanceActor.AttributeAlarmPublished>(_ => true, TimeSpan.FromSeconds(2))
|
||||
parent.FishForMessage<DriverInstanceActor.AttributeAlarmPublished>(_ => true, TimeSpan.FromSeconds(2), cancellationToken: TestContext.Current.CancellationToken)
|
||||
.Args.ConditionId.ShouldBe("Temp.HiHi");
|
||||
}
|
||||
|
||||
@@ -273,20 +273,20 @@ public sealed class DriverInstanceActorNativeAlarmTests : RuntimeActorTestBase
|
||||
var parent = CreateTestProbe();
|
||||
parent.IgnoreMessages(m => m is DriverInstanceActor.ConnectivityChanged);
|
||||
var actor = parent.ChildActorOf(DriverInstanceActor.Props(
|
||||
driver, healthPublisher: publisher, healthPollInterval: TimeSpan.FromMilliseconds(100)));
|
||||
driver, healthPublisher: publisher, healthPollInterval: TimeSpan.FromMilliseconds(100)), TestContext.Current.CancellationToken);
|
||||
|
||||
actor.Tell(new DriverInstanceActor.SetDesiredSubscriptions(
|
||||
Array.Empty<string>(), TimeSpan.FromMilliseconds(100), new[] { "Temp.HiHi" }));
|
||||
actor.Tell(new DriverInstanceActor.InitializeRequested("{}"));
|
||||
|
||||
AwaitCondition(() => driver.SubscribeAlarmsCallCount >= 1, PresenceBudget);
|
||||
AwaitCondition(() => driver.SubscribeAlarmsCallCount >= failures + 1, PresenceBudget);
|
||||
AwaitCondition(() => driver.SubscribeAlarmsCallCount >= 1, PresenceBudget, TestContext.Current.CancellationToken);
|
||||
AwaitCondition(() => driver.SubscribeAlarmsCallCount >= failures + 1, PresenceBudget, TestContext.Current.CancellationToken);
|
||||
driver.LastAlarmRefs.ShouldBe(new[] { "Temp.HiHi" });
|
||||
|
||||
driver.RaiseAlarm(new AlarmEventArgs(
|
||||
new StubAlarmHandle(), "Temp.HiHi", "Temp.HiHi", "T", "after retry", AlarmSeverity.High,
|
||||
DateTime.UtcNow, Kind: AlarmTransitionKind.Raise));
|
||||
parent.FishForMessage<DriverInstanceActor.AttributeAlarmPublished>(_ => true, TimeSpan.FromSeconds(2))
|
||||
parent.FishForMessage<DriverInstanceActor.AttributeAlarmPublished>(_ => true, TimeSpan.FromSeconds(2), cancellationToken: TestContext.Current.CancellationToken)
|
||||
.Args.ConditionId.ShouldBe("Temp.HiHi");
|
||||
|
||||
// Converged: a live, matching handle is left alone on later ticks. POSITIVE CONTROL: each tick
|
||||
@@ -296,7 +296,7 @@ public sealed class DriverInstanceActorNativeAlarmTests : RuntimeActorTestBase
|
||||
// stable health would publish once and this wait would time out (loudly, not vacuously).
|
||||
var settled = driver.SubscribeAlarmsCallCount;
|
||||
var before = publisher.Count;
|
||||
AwaitCondition(() => publisher.Count >= before + 4, PresenceBudget);
|
||||
AwaitCondition(() => publisher.Count >= before + 4, PresenceBudget, TestContext.Current.CancellationToken);
|
||||
driver.SubscribeAlarmsCallCount.ShouldBe(settled, "a live, matching alarm handle must not be re-subscribed every tick");
|
||||
}
|
||||
|
||||
@@ -314,17 +314,17 @@ public sealed class DriverInstanceActorNativeAlarmTests : RuntimeActorTestBase
|
||||
// #477: DriverInstanceActor now Tells the parent ConnectivityChanged on each connect/
|
||||
// disconnect; these tests assert on the data/alarm/discovery forwards, so ignore it.
|
||||
parent.IgnoreMessages(m => m is DriverInstanceActor.ConnectivityChanged);
|
||||
var actor = parent.ChildActorOf(DriverInstanceActor.Props(driver, reconnectInterval: TimeSpan.FromMilliseconds(50)));
|
||||
var actor = parent.ChildActorOf(DriverInstanceActor.Props(driver, reconnectInterval: TimeSpan.FromMilliseconds(50)), TestContext.Current.CancellationToken);
|
||||
|
||||
actor.Tell(new DriverInstanceActor.InitializeRequested("{}"));
|
||||
AwaitCondition(() => driver.AlarmSubscriberCount == 1, TimeSpan.FromSeconds(2));
|
||||
AwaitCondition(() => driver.AlarmSubscriberCount == 1, TimeSpan.FromSeconds(2), TestContext.Current.CancellationToken);
|
||||
|
||||
// Force Connected → Reconnecting (detaches) → Connected (re-attaches). InitializeCount climbs on
|
||||
// the retry; the alarm handler count must settle back to exactly one (no leaked extra handler).
|
||||
var initBefore = driver.InitializeCount;
|
||||
actor.Tell(new DriverInstanceActor.DisconnectObserved("backend blip"));
|
||||
AwaitCondition(() => driver.InitializeCount > initBefore, TimeSpan.FromSeconds(3));
|
||||
AwaitCondition(() => driver.AlarmSubscriberCount == 1, TimeSpan.FromSeconds(3));
|
||||
AwaitCondition(() => driver.InitializeCount > initBefore, TimeSpan.FromSeconds(3), TestContext.Current.CancellationToken);
|
||||
AwaitCondition(() => driver.AlarmSubscriberCount == 1, TimeSpan.FromSeconds(3), TestContext.Current.CancellationToken);
|
||||
|
||||
driver.RaiseAlarm(new AlarmEventArgs(
|
||||
new StubAlarmHandle(),
|
||||
@@ -337,9 +337,9 @@ public sealed class DriverInstanceActorNativeAlarmTests : RuntimeActorTestBase
|
||||
Kind: AlarmTransitionKind.Raise));
|
||||
|
||||
// Exactly one forward — a double-attach would surface as a second AttributeAlarmPublished.
|
||||
parent.ExpectMsg<DriverInstanceActor.AttributeAlarmPublished>(TimeSpan.FromSeconds(2))
|
||||
parent.ExpectMsg<DriverInstanceActor.AttributeAlarmPublished>(TimeSpan.FromSeconds(2), cancellationToken: TestContext.Current.CancellationToken)
|
||||
.Args.SourceNodeId.ShouldBe("src-node-1");
|
||||
parent.ExpectNoMsg(TimeSpan.FromMilliseconds(300));
|
||||
parent.ExpectNoMsg(TimeSpan.FromMilliseconds(300), TestContext.Current.CancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>#477 Layer 2 — the actor announces connectivity to its parent (the host): Connected on
|
||||
@@ -351,21 +351,21 @@ public sealed class DriverInstanceActorNativeAlarmTests : RuntimeActorTestBase
|
||||
{
|
||||
var driver = new AlarmSourceStubDriver();
|
||||
var parent = CreateTestProbe(); // deliberately does NOT ignore ConnectivityChanged — it's the subject.
|
||||
var actor = parent.ChildActorOf(DriverInstanceActor.Props(driver, reconnectInterval: TimeSpan.FromMilliseconds(50)));
|
||||
var actor = parent.ChildActorOf(DriverInstanceActor.Props(driver, reconnectInterval: TimeSpan.FromMilliseconds(50)), TestContext.Current.CancellationToken);
|
||||
|
||||
actor.Tell(new DriverInstanceActor.InitializeRequested("{}"));
|
||||
|
||||
// Initial connect → Connected=true.
|
||||
parent.FishForMessage<DriverInstanceActor.ConnectivityChanged>(m => true, TimeSpan.FromSeconds(3))
|
||||
parent.FishForMessage<DriverInstanceActor.ConnectivityChanged>(m => true, TimeSpan.FromSeconds(3), cancellationToken: TestContext.Current.CancellationToken)
|
||||
.Connected.ShouldBeTrue();
|
||||
|
||||
// Disconnect → Connected=false (this is what drives the conditions Bad).
|
||||
actor.Tell(new DriverInstanceActor.DisconnectObserved("backend blip"));
|
||||
parent.FishForMessage<DriverInstanceActor.ConnectivityChanged>(m => true, TimeSpan.FromSeconds(3))
|
||||
parent.FishForMessage<DriverInstanceActor.ConnectivityChanged>(m => true, TimeSpan.FromSeconds(3), cancellationToken: TestContext.Current.CancellationToken)
|
||||
.Connected.ShouldBeFalse();
|
||||
|
||||
// Reconnect → Connected=true again (drives them back Good).
|
||||
parent.FishForMessage<DriverInstanceActor.ConnectivityChanged>(m => true, TimeSpan.FromSeconds(3))
|
||||
parent.FishForMessage<DriverInstanceActor.ConnectivityChanged>(m => true, TimeSpan.FromSeconds(3), cancellationToken: TestContext.Current.CancellationToken)
|
||||
.Connected.ShouldBeTrue();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user