fix(deployment): bulk-deploy up-to-date pre-filter uses batch hash/status reads and the operation's shared flatten session; completion log reports pre-filter cost (review 2026-10-21 04/P1)
This commit is contained in:
@@ -323,4 +323,37 @@ public class ReconcileRepositoryTests : IDisposable
|
||||
Assert.Equal("SlimEnabled", e.UniqueName);
|
||||
Assert.Empty(_context.ChangeTracker.Entries<Instance>());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// review 2026-10-21 04/P1: the batch current-status read returns, per instance, the same
|
||||
/// record GetCurrentDeploymentStatusAsync would (latest DeployedAt, then highest Id), in
|
||||
/// one untracked query.
|
||||
/// </summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task GetCurrentDeploymentStatuses_MatchesPerInstanceCurrentRecord()
|
||||
{
|
||||
var siteId = await SeedSiteAsync("SiteStatus");
|
||||
var a = await SeedInstanceAsync("StatusA", siteId);
|
||||
var b = await SeedInstanceAsync("StatusB", siteId);
|
||||
var c = await SeedInstanceAsync("StatusC", siteId);
|
||||
var t0 = DateTimeOffset.UtcNow.AddHours(-1);
|
||||
|
||||
_context.DeploymentRecords.AddRange(
|
||||
new DeploymentRecord("a-old", "admin") { InstanceId = a, Status = DeploymentStatus.Success, DeployedAt = t0 },
|
||||
new DeploymentRecord("a-new", "admin") { InstanceId = a, Status = DeploymentStatus.InProgress, DeployedAt = t0.AddMinutes(5) },
|
||||
// Tie on DeployedAt: the higher Id (inserted later) wins.
|
||||
new DeploymentRecord("b-1", "admin") { InstanceId = b, Status = DeploymentStatus.Success, DeployedAt = t0 },
|
||||
new DeploymentRecord("b-2", "admin") { InstanceId = b, Status = DeploymentStatus.Failed, DeployedAt = t0 });
|
||||
await _context.SaveChangesAsync();
|
||||
_context.ChangeTracker.Clear();
|
||||
|
||||
var current = await _repository.GetCurrentDeploymentStatusesAsync(new[] { a, b, c });
|
||||
|
||||
Assert.Equal(2, current.Count);
|
||||
Assert.Equal("a-new", current[a].DeploymentId);
|
||||
Assert.Equal("b-2", current[b].DeploymentId);
|
||||
Assert.False(current.ContainsKey(c));
|
||||
Assert.Equal((await _repository.GetCurrentDeploymentStatusAsync(b))!.DeploymentId, current[b].DeploymentId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user