test(site-runtime): fix stale SetStaticAttribute tests
HandleSetStaticAttribute was made fire-and-forget (commit 2951507) — it no
longer replies with SetStaticAttributeResponse — but three InstanceActor
tests still ExpectMsg<SetStaticAttributeResponse> and timed out. Verify the
mutation via the GetAttributeRequest round-trip instead, which the FIFO
mailbox makes a sound sync point. Test intent (in-memory update, SQLite
persistence, serialized ordering) is unchanged.
This commit is contained in:
@@ -123,11 +123,9 @@ public class InstanceActorIntegrationTests : TestKit, IDisposable
|
|||||||
$"corr-{i}", "Pump1", "Temperature", $"{i}", DateTimeOffset.UtcNow));
|
$"corr-{i}", "Pump1", "Temperature", $"{i}", DateTimeOffset.UtcNow));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for all to process
|
// SetStaticAttributeCommand is fire-and-forget; the GetAttributeRequest
|
||||||
for (int i = 0; i < 50; i++)
|
// round-trip below is the sync point — the FIFO mailbox guarantees all
|
||||||
{
|
// 50 sets are processed before the get is.
|
||||||
ExpectMsg<SetStaticAttributeResponse>(TimeSpan.FromSeconds(10));
|
|
||||||
}
|
|
||||||
|
|
||||||
// The last value should be the final one
|
// The last value should be the final one
|
||||||
actor.Tell(new GetAttributeRequest(
|
actor.Tell(new GetAttributeRequest(
|
||||||
|
|||||||
@@ -113,13 +113,12 @@ public class InstanceActorTests : TestKit, IDisposable
|
|||||||
|
|
||||||
var actor = CreateInstanceActor("Pump1", config);
|
var actor = CreateInstanceActor("Pump1", config);
|
||||||
|
|
||||||
// Set a static attribute -- response comes async via PipeTo
|
// SetStaticAttributeCommand is fire-and-forget (no reply); the
|
||||||
|
// GetAttributeRequest round-trip below confirms it was applied — the
|
||||||
|
// actor mailbox is FIFO, so the set is processed before the get.
|
||||||
actor.Tell(new SetStaticAttributeCommand(
|
actor.Tell(new SetStaticAttributeCommand(
|
||||||
"corr-3", "Pump1", "Temperature", "100.0", DateTimeOffset.UtcNow));
|
"corr-3", "Pump1", "Temperature", "100.0", DateTimeOffset.UtcNow));
|
||||||
|
|
||||||
var setResponse = ExpectMsg<SetStaticAttributeResponse>(TimeSpan.FromSeconds(5));
|
|
||||||
Assert.True(setResponse.Success);
|
|
||||||
|
|
||||||
// Verify the value changed in memory
|
// Verify the value changed in memory
|
||||||
actor.Tell(new GetAttributeRequest(
|
actor.Tell(new GetAttributeRequest(
|
||||||
"corr-4", "Pump1", "Temperature", DateTimeOffset.UtcNow));
|
"corr-4", "Pump1", "Temperature", DateTimeOffset.UtcNow));
|
||||||
@@ -146,9 +145,12 @@ public class InstanceActorTests : TestKit, IDisposable
|
|||||||
actor.Tell(new SetStaticAttributeCommand(
|
actor.Tell(new SetStaticAttributeCommand(
|
||||||
"corr-persist", "PumpPersist1", "Temperature", "100.0", DateTimeOffset.UtcNow));
|
"corr-persist", "PumpPersist1", "Temperature", "100.0", DateTimeOffset.UtcNow));
|
||||||
|
|
||||||
ExpectMsg<SetStaticAttributeResponse>(TimeSpan.FromSeconds(5));
|
// SetStaticAttributeCommand is fire-and-forget; round-trip a
|
||||||
|
// GetAttributeRequest to confirm the command was processed (FIFO
|
||||||
// Give async persistence time to complete
|
// mailbox), then wait for the async SQLite persist to complete.
|
||||||
|
actor.Tell(new GetAttributeRequest(
|
||||||
|
"corr-persist-get", "PumpPersist1", "Temperature", DateTimeOffset.UtcNow));
|
||||||
|
ExpectMsg<GetAttributeResponse>(TimeSpan.FromSeconds(5));
|
||||||
await Task.Delay(500);
|
await Task.Delay(500);
|
||||||
|
|
||||||
// Verify it persisted to SQLite
|
// Verify it persisted to SQLite
|
||||||
|
|||||||
Reference in New Issue
Block a user