fix(deployment): read every external system's methods in one query for the artifact snapshot (review 2026-10-21 04/P7)
This commit is contained in:
@@ -255,6 +255,47 @@ public class ArtifactDeploymentServiceTests : TestKit
|
||||
Assert.Equal(TimeSpan.FromSeconds(120), artifact.RetryDelay);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// review 2026-10-21 04/P7: every external system's methods come from ONE query, grouped
|
||||
/// per system — not one method query per external system — and each system's artifact
|
||||
/// still carries exactly its own methods.
|
||||
/// </summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
public async Task ExternalSystemMethods_AreReadInOneQuery_AndGroupedPerSystem()
|
||||
{
|
||||
_externalSystemRepo.GetAllExternalSystemsAsync(Arg.Any<CancellationToken>()).Returns(
|
||||
[
|
||||
new ExternalSystemDefinition("Mes", "https://mes", "ApiKey") { Id = 1 },
|
||||
new ExternalSystemDefinition("Erp", "https://erp", "ApiKey") { Id = 2 },
|
||||
new ExternalSystemDefinition("Idle", "https://idle", "ApiKey") { Id = 3 },
|
||||
]);
|
||||
_deploymentRepo.GetAllExternalSystemMethodsAsync(Arg.Any<CancellationToken>()).Returns(
|
||||
[
|
||||
new ExternalSystemMethod("MoveOut", "POST", "/move") { Id = 10, ExternalSystemDefinitionId = 1 },
|
||||
new ExternalSystemMethod("GetOrder", "GET", "/order") { Id = 11, ExternalSystemDefinitionId = 2 },
|
||||
new ExternalSystemMethod("PostOrder", "POST", "/order") { Id = 12, ExternalSystemDefinitionId = 2 },
|
||||
]);
|
||||
|
||||
var recorder = new ArtifactProbeRecorder();
|
||||
var probe = Sys.ActorOf(Props.Create(() => new ArtifactProbeActor(recorder)));
|
||||
var service = CreateServiceWithCommActor(probe);
|
||||
|
||||
var result = await service.RetryForSiteAsync(1, "retry-site", "admin");
|
||||
|
||||
Assert.True(result.IsSuccess);
|
||||
await _deploymentRepo.Received(1).GetAllExternalSystemMethodsAsync(Arg.Any<CancellationToken>());
|
||||
await _externalSystemRepo.DidNotReceive().GetMethodsByExternalSystemIdAsync(
|
||||
Arg.Any<int>(), Arg.Any<CancellationToken>());
|
||||
|
||||
var artifacts = Assert.Single(recorder.Received).ExternalSystems!.ToDictionary(a => a.Name);
|
||||
Assert.Contains("MoveOut", artifacts["Mes"].MethodDefinitionsJson);
|
||||
Assert.DoesNotContain("Order", artifacts["Mes"].MethodDefinitionsJson);
|
||||
Assert.Contains("GetOrder", artifacts["Erp"].MethodDefinitionsJson);
|
||||
Assert.Contains("PostOrder", artifacts["Erp"].MethodDefinitionsJson);
|
||||
Assert.Null(artifacts["Idle"].MethodDefinitionsJson);
|
||||
}
|
||||
|
||||
/// <summary>Verifies that retrying a single site still runs the global artifact queries exactly once.</summary>
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user