From 2ade23bc827f1345b32e39f1d8bd822fee4b0732 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 20 May 2026 22:56:42 +0000 Subject: [PATCH] Address health check review feedback Agent-Logs-Url: https://github.com/elsa-workflows/elsa-core/sessions/71c9cf76-ccac-4020-87f4-1e4122d34645 Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com> --- .../ElsaWorkflowPersistenceHealthCheck.cs | 4 ++++ ...ElsaWorkflowPersistenceHealthCheckTests.cs | 8 ++++++- .../HealthCheckExtensionsTests.cs | 23 +++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 test/unit/Elsa.Workflows.Runtime.UnitTests/HealthChecks/HealthCheckExtensionsTests.cs diff --git a/src/modules/Elsa.Workflows.Runtime/HealthChecks/ElsaWorkflowPersistenceHealthCheck.cs b/src/modules/Elsa.Workflows.Runtime/HealthChecks/ElsaWorkflowPersistenceHealthCheck.cs index 0d4679949..55d5478fb 100644 --- a/src/modules/Elsa.Workflows.Runtime/HealthChecks/ElsaWorkflowPersistenceHealthCheck.cs +++ b/src/modules/Elsa.Workflows.Runtime/HealthChecks/ElsaWorkflowPersistenceHealthCheck.cs @@ -27,6 +27,7 @@ public class ElsaWorkflowPersistenceHealthCheck(IServiceProvider serviceProvider var attemptedProbes = probeResults.Where(x => !x.Skipped).Select(x => x.StoreName).ToList(); var successfulProbes = probeResults.Where(x => !x.Skipped && x.Exception == null).Select(x => x.StoreName).ToList(); var skippedProbes = probeResults.Where(x => x.Skipped).Select(x => x.StoreName).ToList(); + var failedProbes = probeResults.Where(x => x.Exception != null).Select(x => x.StoreName).ToList(); var failedProbe = probeResults.FirstOrDefault(x => x.Exception != null); if (failedProbe != null) { @@ -78,6 +79,9 @@ public class ElsaWorkflowPersistenceHealthCheck(IServiceProvider serviceProvider if (attemptedProbes.Count > 0) data["attemptedProbes"] = string.Join(",", attemptedProbes); + if (failedProbes.Count > 0) + data["failedProbes"] = string.Join(",", failedProbes); + if (skippedProbes.Count > 0) data["skippedProbes"] = string.Join(",", skippedProbes); diff --git a/test/unit/Elsa.Workflows.Runtime.UnitTests/HealthChecks/ElsaWorkflowPersistenceHealthCheckTests.cs b/test/unit/Elsa.Workflows.Runtime.UnitTests/HealthChecks/ElsaWorkflowPersistenceHealthCheckTests.cs index 7d6192334..02fcd8f11 100644 --- a/test/unit/Elsa.Workflows.Runtime.UnitTests/HealthChecks/ElsaWorkflowPersistenceHealthCheckTests.cs +++ b/test/unit/Elsa.Workflows.Runtime.UnitTests/HealthChecks/ElsaWorkflowPersistenceHealthCheckTests.cs @@ -37,6 +37,11 @@ public class ElsaWorkflowPersistenceHealthCheckTests Assert.Equal(HealthStatus.Healthy, result.Status); Assert.Equal("persistence", result.Data["category"]); + Assert.Equal("workflow-definitions,workflow-instances,triggers,bookmark-queue", result.Data["probes"]); + Assert.Equal("workflow-definitions,workflow-instances,triggers,bookmark-queue", result.Data["attemptedProbes"]); + await _workflowDefinitionStore.Received(1).FindAsync( + Arg.Is(x => x.Id == "00000000-0000-0000-0000-000000000000"), + Arg.Any()); } [Fact] @@ -51,8 +56,9 @@ public class ElsaWorkflowPersistenceHealthCheckTests Assert.Equal("persistence", result.Data["category"]); Assert.Equal("triggers", result.Data["failedStore"]); Assert.Equal("triggers", result.Data["failedProbe"]); - Assert.Equal("workflow-definitions,workflow-instances,triggers,bookmark-queue", result.Data["attemptedProbes"]); Assert.Equal("workflow-definitions,workflow-instances,bookmark-queue", result.Data["probes"]); + Assert.Equal("workflow-definitions,workflow-instances,triggers,bookmark-queue", result.Data["attemptedProbes"]); + Assert.Equal("triggers", result.Data["failedProbes"]); } [Fact] diff --git a/test/unit/Elsa.Workflows.Runtime.UnitTests/HealthChecks/HealthCheckExtensionsTests.cs b/test/unit/Elsa.Workflows.Runtime.UnitTests/HealthChecks/HealthCheckExtensionsTests.cs new file mode 100644 index 000000000..5bb78efc4 --- /dev/null +++ b/test/unit/Elsa.Workflows.Runtime.UnitTests/HealthChecks/HealthCheckExtensionsTests.cs @@ -0,0 +1,23 @@ +using Elsa.Extensions; +using Elsa.Workflows.Runtime.Options; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; + +namespace Elsa.Workflows.Runtime.UnitTests.HealthChecks; + +public class HealthCheckExtensionsTests +{ + [Fact] + public void AddElsaReadinessChecksRegistersReadinessOptions() + { + var services = new ServiceCollection(); + + services + .AddHealthChecks() + .AddElsaReadinessChecks(includePersistence: false, includeDistributedLocks: true); + + using var serviceProvider = services.BuildServiceProvider(); + + Assert.NotNull(serviceProvider.GetRequiredService>()); + } +}