fix(deployment-manager): resolve DeploymentManager-009,010,012,014 — shared deployment ID, lifecycle-timeout enforcement, doc/test cleanup; DeploymentManager-013 flagged
This commit is contained in:
@@ -763,6 +763,59 @@ public class DeploymentServiceTests : TestKit
|
||||
Assert.Equal(1, ReconcileProbeActor.DeployCount);
|
||||
}
|
||||
|
||||
// ── DeploymentManager-012: LifecycleCommandTimeout must actually bound lifecycle commands ──
|
||||
|
||||
[Fact]
|
||||
public async Task DisableInstanceAsync_SiteUnresponsive_LifecycleCommandTimeoutBoundsTheWait()
|
||||
{
|
||||
// The site never replies to the DisableInstanceCommand. A short
|
||||
// LifecycleCommandTimeout must abort the wait quickly -- if the option
|
||||
// is dead code the call would instead hang until CommunicationOptions
|
||||
// .LifecycleTimeout (much longer) elapses.
|
||||
var instance = new Instance("StuckInst") { Id = 60, SiteId = 1, State = InstanceState.Enabled };
|
||||
_repo.GetInstanceByIdAsync(60, Arg.Any<CancellationToken>()).Returns(instance);
|
||||
|
||||
// Probe drops every message -> no reply ever arrives.
|
||||
var commActor = Sys.ActorOf(Props.Create(() => new SilentProbeActor()));
|
||||
|
||||
var comms = new CommunicationService(
|
||||
Options.Create(new CommunicationOptions
|
||||
{
|
||||
// Long communication-layer timeout: if LifecycleCommandTimeout
|
||||
// were dead, the test would wait this long.
|
||||
LifecycleTimeout = TimeSpan.FromSeconds(30)
|
||||
}),
|
||||
NullLogger<CommunicationService>.Instance);
|
||||
comms.SetCommunicationActor(commActor);
|
||||
|
||||
var siteRepo = Substitute.For<ISiteRepository>();
|
||||
var service = new DeploymentService(
|
||||
_repo, siteRepo, _pipeline, comms, _lockManager, _audit,
|
||||
new DiffService(),
|
||||
Options.Create(new DeploymentManagerOptions
|
||||
{
|
||||
OperationLockTimeout = TimeSpan.FromSeconds(5),
|
||||
LifecycleCommandTimeout = TimeSpan.FromMilliseconds(300)
|
||||
}),
|
||||
NullLogger<DeploymentService>.Instance);
|
||||
|
||||
var sw = System.Diagnostics.Stopwatch.StartNew();
|
||||
var result = await service.DisableInstanceAsync(60, "admin");
|
||||
sw.Stop();
|
||||
|
||||
Assert.True(result.IsFailure);
|
||||
// The 300ms LifecycleCommandTimeout bounded the wait well under the
|
||||
// 30s communication-layer timeout.
|
||||
Assert.True(sw.Elapsed < TimeSpan.FromSeconds(10),
|
||||
$"Lifecycle command was not bounded by LifecycleCommandTimeout (took {sw.Elapsed}).");
|
||||
}
|
||||
|
||||
/// <summary>Stand-in actor that never replies to anything.</summary>
|
||||
private class SilentProbeActor : ReceiveActor
|
||||
{
|
||||
public SilentProbeActor() => ReceiveAny(_ => { });
|
||||
}
|
||||
|
||||
// ── DeploymentManager-003: post-success persistence must commit the Success status ──
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user