fix(test): give the three absence assertions a positive control (#501)
`AwaitAssert` returns on its FIRST success, so an assertion that is already true at t=0 passes instantly and spends none of its duration. All three sites asserted an absence against a collection that starts empty, so none of them ever gave the handler the time their comments claimed. Replaced with mailbox-ordering positive controls rather than sleeps: - `RouteNativeAlarmAck_unknown_node_is_dropped` — follow the unmapped ack with a MAPPED one. The host forwards via `Tell` and the child handles `RouteAlarmAck` with `ReceiveAsync` (which suspends its own mailbox), so once the control reaches the driver the unmapped one has provably been handled. - `RouteNativeAlarmAck_on_non_primary_is_dropped` — the role itself is the control: return the node to Primary and re-send. Comments (`gated` / `control`) are the discriminator, so a leaked ack is visible rather than merged into a count. - `PeerProbeSupervisorTests.Single_node_snapshot_spawns_no_children` — a FOURTH site the issue did not list. It says the other `ChildCount.ShouldBe(0)` waits are each preceded by a `ShouldBe(1)`; that is true of three of the four, but not this one, which asserts the initial state. Now followed by a two-node snapshot: the count reaching 1 proves the single-node snapshot was processed, and a local-node child would have made it 2. The issue warned these may turn red, which would be a real defect surfacing. They did not — the routing is correct. Proven by breaking it deliberately instead: disabling the Primary gate reddens the Secondary test, and routing unmapped ids to an arbitrary mapping reddens the unknown-node test. Under the old form both breaks passed.
This commit is contained in:
@@ -78,7 +78,9 @@ public sealed class PeerProbeSupervisorTests : RuntimeActorTestBase
|
||||
duration: PresenceBudget);
|
||||
}
|
||||
|
||||
/// <summary>Verifies a single-node snapshot (just the local node) spawns no children.</summary>
|
||||
/// <summary>Verifies a single-node snapshot (just the local node) spawns no children — the local node
|
||||
/// is never its own probe peer. Established against a following two-node snapshot as a positive
|
||||
/// control, so the count of 1 (rather than 2) is what carries the "no local child" claim.</summary>
|
||||
[Fact]
|
||||
public void Single_node_snapshot_spawns_no_children()
|
||||
{
|
||||
@@ -87,7 +89,20 @@ public sealed class PeerProbeSupervisorTests : RuntimeActorTestBase
|
||||
|
||||
sup.Tell(Snapshot(State(Local, RedundancyRole.Primary)));
|
||||
|
||||
AwaitAssert(() => sup.UnderlyingActor.ChildCount.ShouldBe(0),
|
||||
// POSITIVE CONTROL (#501). This is an ABSENCE assertion, and ChildCount is 0 before the snapshot
|
||||
// above has been processed at all — so asserting it directly passes at t=0 and proves nothing
|
||||
// (AwaitAssert returns on its first success, spending none of its duration). Unlike the other
|
||||
// ChildCount.ShouldBe(0) waits in this class, there is no preceding ShouldBe(1) to make it a
|
||||
// transition.
|
||||
//
|
||||
// Follow with a snapshot that DOES spawn exactly one child. The supervisor processes its mailbox
|
||||
// in order, so once the count reaches 1 the single-node snapshot has provably been handled — and
|
||||
// had it spawned a child for the local node, the count would be 2.
|
||||
sup.Tell(Snapshot(
|
||||
State(Local, RedundancyRole.Primary),
|
||||
State(Peer, RedundancyRole.Secondary)));
|
||||
|
||||
AwaitAssert(() => sup.UnderlyingActor.ChildCount.ShouldBe(1),
|
||||
duration: PresenceBudget);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user