fix(deployment-manager): resolve DeploymentManager-015..017 — reconciliation applies post-success side effects, updates RevisionHash, corrected XML doc
This commit is contained in:
@@ -766,6 +766,99 @@ public class DeploymentServiceTests : TestKit
|
||||
Assert.Equal(1, ReconcileProbeActor.DeployCount);
|
||||
}
|
||||
|
||||
// ── DeploymentManager-015: reconciliation must perform the normal success side effects ──
|
||||
|
||||
[Fact]
|
||||
public async Task DeployInstanceAsync_Reconciled_SetsInstanceEnabledAndStoresSnapshot()
|
||||
{
|
||||
// A prior deploy timed out; the site actually applied the target
|
||||
// revision. Reconciliation marks the prior record Success WITHOUT
|
||||
// re-sending -- but it must still perform the same side effects as the
|
||||
// normal success path: set the instance State to Enabled and store the
|
||||
// deployed-config snapshot. Otherwise central and site diverge.
|
||||
var instance = new Instance("ReconcileSideEffects")
|
||||
{
|
||||
Id = 70, SiteId = 1, State = InstanceState.NotDeployed
|
||||
};
|
||||
_repo.GetInstanceByIdAsync(70, Arg.Any<CancellationToken>()).Returns(instance);
|
||||
SetupValidPipeline(70, "ReconcileSideEffects", "sha256:target");
|
||||
|
||||
var prior = new DeploymentRecord("dep-prior-70", "admin")
|
||||
{
|
||||
InstanceId = 70,
|
||||
Status = DeploymentStatus.InProgress,
|
||||
RevisionHash = "sha256:target"
|
||||
};
|
||||
_repo.GetCurrentDeploymentStatusAsync(70, Arg.Any<CancellationToken>()).Returns(prior);
|
||||
_repo.GetDeployedSnapshotByInstanceIdAsync(70, Arg.Any<CancellationToken>())
|
||||
.Returns((DeployedConfigSnapshot?)null);
|
||||
|
||||
DeployedConfigSnapshot? storedSnapshot = null;
|
||||
await _repo.AddDeployedSnapshotAsync(
|
||||
Arg.Do<DeployedConfigSnapshot>(s => storedSnapshot = s), Arg.Any<CancellationToken>());
|
||||
|
||||
var commActor = Sys.ActorOf(Props.Create(() =>
|
||||
new ReconcileProbeActor(siteHash: "sha256:target", failQuery: false)));
|
||||
var service = CreateServiceWithCommActor(commActor);
|
||||
|
||||
var result = await service.DeployInstanceAsync(70, "admin");
|
||||
|
||||
Assert.True(result.IsSuccess);
|
||||
// No re-deploy was sent -- this was reconciled.
|
||||
Assert.Equal(1, ReconcileProbeActor.QueryCount);
|
||||
Assert.Equal(0, ReconcileProbeActor.DeployCount);
|
||||
|
||||
// DeploymentManager-015: the instance State must reflect the deployed
|
||||
// config the site is actually running.
|
||||
Assert.Equal(InstanceState.Enabled, instance.State);
|
||||
await _repo.Received().UpdateInstanceAsync(instance, Arg.Any<CancellationToken>());
|
||||
|
||||
// DeploymentManager-015: a deployed-config snapshot must be stored so
|
||||
// GetDeploymentComparisonAsync has something to compare against.
|
||||
Assert.NotNull(storedSnapshot);
|
||||
Assert.Equal(70, storedSnapshot!.InstanceId);
|
||||
Assert.Equal("sha256:target", storedSnapshot.RevisionHash);
|
||||
}
|
||||
|
||||
// ── DeploymentManager-016: reconciled record must carry the target revision hash ──
|
||||
|
||||
[Fact]
|
||||
public async Task DeployInstanceAsync_Reconciled_PriorRecordRevisionHashUpdatedToTarget()
|
||||
{
|
||||
// The prior record carries a stale revision hash (R1), but the site
|
||||
// reports it has the freshly-flattened target revision (R2). After
|
||||
// reconciliation the prior record's RevisionHash must agree with the
|
||||
// site's applied revision -- not keep the stale R1.
|
||||
var instance = new Instance("ReconcileStaleHash")
|
||||
{
|
||||
Id = 71, SiteId = 1, State = InstanceState.Enabled
|
||||
};
|
||||
_repo.GetInstanceByIdAsync(71, Arg.Any<CancellationToken>()).Returns(instance);
|
||||
SetupValidPipeline(71, "ReconcileStaleHash", "sha256:target");
|
||||
|
||||
var prior = new DeploymentRecord("dep-prior-71", "admin")
|
||||
{
|
||||
InstanceId = 71,
|
||||
Status = DeploymentStatus.InProgress,
|
||||
RevisionHash = "sha256:stale-R1"
|
||||
};
|
||||
_repo.GetCurrentDeploymentStatusAsync(71, Arg.Any<CancellationToken>()).Returns(prior);
|
||||
_repo.GetDeployedSnapshotByInstanceIdAsync(71, Arg.Any<CancellationToken>())
|
||||
.Returns((DeployedConfigSnapshot?)null);
|
||||
|
||||
var commActor = Sys.ActorOf(Props.Create(() =>
|
||||
new ReconcileProbeActor(siteHash: "sha256:target", failQuery: false)));
|
||||
var service = CreateServiceWithCommActor(commActor);
|
||||
|
||||
var result = await service.DeployInstanceAsync(71, "admin");
|
||||
|
||||
Assert.True(result.IsSuccess);
|
||||
Assert.Equal(DeploymentStatus.Success, prior.Status);
|
||||
// DeploymentManager-016: the persisted record's RevisionHash must agree
|
||||
// with the site's applied revision, not keep the stale R1.
|
||||
Assert.Equal("sha256:target", prior.RevisionHash);
|
||||
}
|
||||
|
||||
// ── DeploymentManager-012: LifecycleCommandTimeout must actually bound lifecycle commands ──
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user