20 commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
33181ae304
|
fix: persist Interrupted after drain force-cancel commits Cancelled (#8069)
Some checks failed
Packages / Test unit/integration with coverage (push) Has been cancelled
Packages / Test component with coverage (push) Has been cancelled
Packages / Generate coverage report (push) Has been cancelled
Packages / Build packages (push) Has been cancelled
Packages / Publish to feedz.io (push) Has been cancelled
Packages / Publish release to nuget.org (push) Has been cancelled
Packages / Deploy coverage to GitHub Pages (push) Has been cancelled
* fix: persist Interrupted after drain force-cancel commits Cancelled Deadline-breach force-cancel makes the runner persist Finished/Cancelled. #8059 then skipped every Finished row, so Interrupted never landed and Packages CI failed DeadlineBreachPersistsInterrupted. Treat Cancelled as interruptible and promote it to Running+Interrupted so recovery can requeue it, while still refusing naturally completed rows. Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * fix: do not promote user cancellations to Interrupted on drain Gate Cancelled→Interrupted on instances that were not already Cancelled when drain snapshotted live cycles. Deadline-breach force-cancel still promotes the runner's Finished/Cancelled commit; ordinary client cancellations stay Cancelled and are not requeued. Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * fix: confine Cancelled→Interrupted promote to Drain Restore TryMarkInterruptedAsync to refuse every Finished row by default (#8052). Drain PersistInterrupted alone may pass allowFinishedCancelled when the instance is Finished/Cancelled and in this drain's force-cancelled set. User cancellations stay cancelled. Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * docs: document TryMarkInterruptedAsync parameters Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * fix: bound pre-cancel snapshot so stalled Find cannot block Cancel WaitAsync the instance-store snapshot under a short shutdown budget so a hang or ignored cancellation token cannot delay handle.Cancel(). Unknown pre-state is not treated as already Cancelled; observed user cancellations are still preserved. Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * test: restore Fact on terminal-race drain persist skip Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * fix: exclude unknown snapshot rows from drain-induced promote A timed-out or failed pre-cancel Find no longer joins drainInduced. Only a successful read that is clearly not already Cancelled may be promoted. Cancel still proceeds without waiting on store latency. Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * fix: give each pre-cancel snapshot its own timeout A shared 250ms overallSnapshotCts let a stalled first Find cancel later Finds before they started, so those instances were excluded from drainInduced and never persisted as Interrupted after Phase A Cancel. Each Find now uses an independent CTS linked only to the host token. Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * fix: snapshot live instances concurrently before Phase A Cancel Independent per-find 250ms budgets kept recovery, but a serial foreach still delayed every handle.Cancel by up to N×250ms. Run those bounded Finds with Task.WhenAll so Cancel waits one timeout window, not N. Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * fix: give each parallel snapshot Find its own DI scope Task.WhenAll was sharing one scoped IWorkflowInstanceStore. EF DbContext is not thread-safe; Phase C already persists sequentially for that reason. Each snapshot task now CreateScope()s its own store and disposes it. Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> |
||
|
|
5ab383ce86
|
fix: stop requeuing Finished+Interrupted workflow instances (#8052)
* fix: stop requeuing Finished+Interrupted workflow instances InterruptedRecoveryScanner now requires Status=Running, matching the sibling crash-recovery task. DrainOrchestrator skips already-terminal instances so a runner-clobber race cannot stamp Interrupted onto a Finished row. Fixes #8052. Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * fix: conditionally mark Interrupted so drain cannot clobber Finished PersistInterruptedAsync no longer SaveAsync-es the Find snapshot. The store now applies Interrupted only when Status is still non-terminal (EF: ExecuteUpdate WHERE Status != Finished; memory: mutate the live row). A runner that commits Finished between read and write keeps its terminal state, so startup recovery cannot requeue completed work. Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * test: disambiguate NSubstitute Returns for TryMarkInterruptedAsync Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * fix: make in-memory Interrupted mark atomic against completion Lock the memory-store check and mutations together, then abort if Status became Finished in-place so drain cannot record Interrupted on a completed instance. Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * fix: share memory-store lock between Interrupted mark and Save TryMarkInterruptedAsync now serializes with Save/Update/SaveMany so a runner's terminal persist cannot land between the non-terminal check and the Interrupted mutations. A finishing Save therefore cannot leave Finished+Interrupted. Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> |
||
|
|
61fc376dac
|
Add output converter support at binding boundaries
Backport to release/3.8.0 so Elsa.Api.Client 3.8.0-rc2 exposes the
Resources/OutputConverters surface that Elsa Studio's release/3.8.0 branch
already consumes. Without it, Studio cannot build against a released client:
it was green against 3.8.0-preview.5397 (built from main) and broke when its
pin moved to 3.8.0-rc1 (built from this branch).
(cherry picked from commit
|
||
|
|
542058971b
|
Avoid repeated tenant-agnostic registry population | ||
|
|
c2fb027c41
|
Refactor: Overhauls workflow JSON type serialization (#7549)
* Avoid null endpoint DTO metadata in tests * Enforce console logs hub read permission * Remove unused console logs hub import * Support mapped endpoint metadata in auth tests * Reduce console log capture throughput impact * Address Copilot console logs review * Refactor task scheduling to support tenant-level background work and enhance logging functionality. * Introduce ConsoleStreamHook for stdout/stderr tee and enhance logging validation. Adjust test cases and startup warnings for distributed lock provider usage. * Refactor console logging pipeline with capture optimization and new ConsoleLogsHost; update tests accordingly. * Add Ansi SGR parser for console logs and associated unit tests * Remove ANSI color renderings and parsers; integrate ConsoleLogScopeAccessor for improved logging context with workflow instance ID support. * Address console logs code quality feedback * Address PR review feedback * Preserve console logs extension points * Stabilize console logs host lifecycle * Address final automated review comments * Tighten console log capture shutdown * Address console log review feedback * Address follow-up review feedback * Cover final review feedback * Avoid recursive console provider initialization * Guard console host lease shutdown * Preserve console log scope and provider lifetime * Correlate console log scope fallback * Tighten console scope correlation * Expose host services during provider construction * Redact ANSI-normalized console lines * Remove `ConsoleCaptureTee` and related services and tests * Use pipeline contributors for console log context * Update CShells package versions to 0.0.24-preview.132 * Filter live console logs by workflow instance * Enhance console logging with activity execution metadata and extend test coverage. * Address console logs stream consumption comment * Add diagnostics OpenTelemetry backend * Introduce dedicated workflow JSON type registry and hardening This change addresses GitHub issue #7541 by establishing a separate type registry (`IWorkflowJsonTypeRegistry`) for workflow JSON serialization. This decouples workflow type resolution from expression type aliases, enforcing a strict trust boundary. Key aspects: - New workflow JSON emits preferred aliases for registered types. - Existing persisted workflows can be loaded via registered legacy names. - Unknown, abstract, interface, open generic, or inappropriate collection types are rejected during deserialization, enhancing security. - Public APIs (e.g., incident strategies) now expose consistent workflow JSON type identifiers. This ensures secure, predictable, and backward-compatible handling of types within workflow definitions and payloads. * Remove unused project references and streamline console log endpoint * Move serialization type aliases to Elsa.Common * Update serialization integration fixtures for aliases * Stabilize missing rate limiter policy test |
||
|
|
842cf7c162
|
[codex] Fix console log metadata and type resolution (#7542)
* Avoid null endpoint DTO metadata in tests * Enforce console logs hub read permission * Remove unused console logs hub import * Support mapped endpoint metadata in auth tests * Reduce console log capture throughput impact * Address Copilot console logs review * Refactor task scheduling to support tenant-level background work and enhance logging functionality. * Introduce ConsoleStreamHook for stdout/stderr tee and enhance logging validation. Adjust test cases and startup warnings for distributed lock provider usage. * Refactor console logging pipeline with capture optimization and new ConsoleLogsHost; update tests accordingly. * Add Ansi SGR parser for console logs and associated unit tests * Remove ANSI color renderings and parsers; integrate ConsoleLogScopeAccessor for improved logging context with workflow instance ID support. * Address console logs code quality feedback * Address PR review feedback * Preserve console logs extension points * Stabilize console logs host lifecycle * Address final automated review comments * Tighten console log capture shutdown * Address console log review feedback * Address follow-up review feedback * Cover final review feedback * Avoid recursive console provider initialization * Guard console host lease shutdown * Preserve console log scope and provider lifetime * Correlate console log scope fallback * Tighten console scope correlation * Expose host services during provider construction * Redact ANSI-normalized console lines * Add OpenTelemetry diagnostics backend foundation * Add OTLP HTTP ingestion parsing * Document OpenTelemetry diagnostics setup * Enforce OpenTelemetry hub permissions * Remove `ConsoleCaptureTee` and related services and tests * Add OpenTelemetry HTTP ingestion integration test * Use pipeline contributors for console log context * Update CShells package versions to 0.0.24-preview.132 * Add OpenTelemetry ingestion security tests * Add OpenTelemetry API authorization tests * Filter live console logs by workflow instance * Add OpenTelemetry hub tests * Add OpenTelemetry gRPC metadata hook * Assert OpenTelemetry workflow tags survive ingestion * Mark OpenTelemetry core build verified * Enhance console logging with activity execution metadata and extend test coverage. * Address console logs stream consumption comment * Wire OpenTelemetry diagnostics into core sample * Address Core diagnostics review feedback * Address Core Copilot follow-up feedback * Add OpenTelemetry metric instrument names * Address Core Copilot provider feedback * Address Core Copilot diagnostics follow-up * Address Core Copilot live feed feedback * Address Core Copilot store feedback * Integrate OpenTelemetry for logging, tracing, and metrics in ModularServer and update launch settings and docker-compose configuration. * Refactor to replace `ConsoleLogStream.Core` with `ConsoleLogStreaming.Core` across codebase and update `ConsoleStreamHook` installation. * Add diagnostics OpenTelemetry backend * Fix OpenTelemetry live hub subscription * Fix modular OpenTelemetry exporter endpoints * Add CShells logging configuration in appsettings.json * Remove obsolete unit tests and helper classes * Restore default activity exception handling * Simplify type serialization and alias management This commit refactors the internal type serialization and alias management system to reduce boilerplate, improve robustness, and simplify the developer experience: - Removed numerous explicit `ExpressionOptions` type alias registrations across various modules. - Updated `TypeJsonConverter` and polymorphic serialization to reliably handle types using assembly-qualified names when a short alias is not explicitly registered. - Streamlined `ExcludeFromHashConverter` to strictly adhere to `ExcludeFromHashAttribute` for hash calculations, removing complex `JsonIgnoreCondition` logic. - Eliminated several helper classes (`WorkflowJsonTypeResolver`, `WorkflowTypeValidator`, `IWorkflowTypeRegistry`, `WorkflowFactoryDictionary`, `JavaScriptExceptionTypeAliasRegistrar`, `WorkflowRuntimeTypeAliasRegistrar`) and their associated unit tests, simplifying the codebase. Additionally, this commit introduces a comprehensive markdown document (`product-website-feature-source.md`) outlining Elsa's core features, Studio capabilities, extension ecosystem, and architectural selling points, intended as source material for the product website. * Refine type serialization for improved robustness and alias handling This commit further enhances the type serialization and deserialization mechanisms: * Centralizes type resolution and alias management through `IWellKnownTypeRegistry` and `WorkflowJsonTypeResolver`. * Prioritizes registered type aliases when serializing type metadata in `PolymorphicObjectConverter`, resulting in more concise JSON output. * Enhances deserialization in `PolymorphicObjectConverter` and `VariableMapper` to gracefully handle unknown or non-instantiable types, providing fallbacks and logging warnings. * Simplifies `TypeJsonConverter` by delegating complex type resolution logic to the `WorkflowJsonTypeResolver`. * Adds `JsonArray` to the well-known type aliases for direct recognition. * Fix console logs packaging and workflow type resolution * Fix console log metadata and type resolution * Address Copilot review feedback * Enhance type resolution, improve console log handling, and update tests - Streamlined `WorkflowDictionaryExtensions` for better workflow registration validation. - Refined `ConsoleLogsAuthorizationTests` with the new `SetJsonRequest` helper to improve test requests handling. - Updated `OrderDefinition` to ignore JSON serialization for `KeySelector`. - Enhanced `WorkflowRuntimeFeature` for improved workflow registration and type alias configuration. - Added tests to ensure `ConsoleLogProvider` metadata filtration in various scenarios. - Improved type serialization logic in `WorkflowJsonTypeResolver`. - Updated README to fix references related to diagnostics. - Optimized `ExcludeFromHashConverter` for property serialization conditions. - Modified `TriggerIndexer` for streamlined trigger management. - Tested payload checks in `PublishEventTests`. - Adjusted `Endpoint` in `ConsoleLogs` for automatic JSON request handling. - Ensured registration of workflow type aliases in `WorkflowsFeature`. * Restore CLR workflow registration compatibility * Align JSON island serialization fixtures * Add Console Logs Services and Enhance Endpoint Handling - Introduced `ActivityExecutionsEndpointTests` to validate route exposure. - Added `ConsoleLogCaptureHostedService` for console log streaming. - Implemented `ConsoleStreamJsonConverter` for JSON conversion of console streams. - Developed `ElsaConsoleLogRecentBuffer` to handle recent log buffering. - Updated `ConsoleLogsAuthorizationTests` with new test cases for stream filter mapping. - Consolidated console log provider dependencies and registration, including recent buffering. - Enhanced `ElsaConsoleLogProvider` to use recent buffer for filtering. - Adjusted `Program.cs` for streamlined logging service setup. * Enhance type resolution and test coverage; streamline console log integration - Added `ConsoleStreamHook` for streamlined log streaming. - Updated `WorkflowJsonTypeResolverTests` to improve type resolution and test new scenarios. - Simplified type resolution by removing trusted assembly checks. * Fix CI smoke and package restore failures * Fix Docker smoke image project paths * Fix Docker Python runtime packages * Fix Docker CA smoke teardown * Refresh Elsa roadmap * Implement background processors and mediation coordination - Added `BackgroundCommandProcessor`, `BackgroundJobProcessor`, and `BackgroundNotificationProcessor` classes for handling commands, jobs, and notifications, respectively. - Introduced `MediatorBackgroundProcessingCoordinator` to coordinate the execution of all background processors. - Implemented `MediatorBackgroundTask` for wrapping `MediatorBackgroundProcessingCoordinator` in `BackgroundTask`. - Added unit tests for `MediatorBackgroundTask` to ensure proper start and stop behavior. - Refactored `BackgroundCommandSenderHostedService` to utilize `BackgroundCommandProcessor`. - Introduced 'elsa-roadmap-refresh' skill configuration for roadmap updates. * Address workflow type resolution review feedback * Address follow-up review feedback * Restore recent console logs execute path * Address Copilot follow-up review * Decouple workflow JSON aliases from expressions * Fix workflow management unit test setup * Fix console logs recent endpoint handler shape * Respect workflow JSON strict type aliases * Remove unused console log contracts reference * Address Copilot review feedback * Address Copilot follow-up comments * Synchronize ring buffer dropped count * Address background processor strategy replay |
||
|
|
25b1ee11ef
|
Refine timestamp filter validation feedback | ||
|
|
4b824d65b8
|
Isolate timestamp filter integration tests | ||
|
|
3a45938dea
|
Address timestamp filter review comments | ||
|
|
f72ed4edab
|
Harden timestamp filter validation null handling | ||
|
|
37de3404cd
|
Whitelist workflow timestamp filter columns | ||
|
|
27ae1fae64
|
[codex] Resolve build warnings (#7458)
* Resolve build warnings * Address Greptile review feedback * Remove dead metadata null guard * Preserve tenant-agnostic workflow activities |
||
|
|
3d8d3b7de2
|
Merge remote-tracking branch 'origin/release/3.6.1' | ||
|
|
a0f0a3c2f5
|
Add workflow export functionality and update changelog (#7357)
* Add `IWorkflowDefinitionExporter` for workflow export functionality Introduced `IWorkflowDefinitionExporter` interface and its implementation to export workflow definitions as JSON or ZIP archives. Simplified `Export` endpoint logic by utilizing the new exporter service. Updated package version to 3.6.1. * Remove duplicate `ExportAsync` method from `IWorkflowDefinitionExporter` and its implementation in `WorkflowDefinitionExporter`. * Remove deprecated test from `WorkflowDefinitionExporterTests`, regression tests are covered in `WorkflowReferenceGraphBuilderTests`. * Update GitHub Actions workflow to support version 3.6.1 deployment * Update src/modules/Elsa.Workflows.Management/Services/WorkflowDefinitionExporter.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Move `WorkflowDefinitionExporterRegressionTests` to separate test file for clarity * Add `DefaultFileNameSanitizer` for sanitizing file names and update `WorkflowDefinitionExporter` to use it. Implement unit tests for the sanitizer. * Update test assertion for exported workflow file name in `WorkflowDefinitionExporterRegressionTests`. * Simplify file naming in `WorkflowDefinitionExporter` by removing duplicate ID from JSON file names. * Update test/unit/Elsa.Workflows.Management.UnitTests/Services/DefaultFileNameSanitizerTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> |
||
|
|
11fec1c85d
|
Add shell middleware, call‑stack tracking, and workflow reference graph APIs (#7333)
* refactor(deps): use local CShells project refs Replace CShells NuGet package references with direct project references to the local CShells source to enable developing and testing against local changes and simplify build integration across modules. * Handle assembly load errors in feature discovery Added error handling for assembly load failures in feature discovery to improve resilience. Also updated configuration for identity token options and removed unused service bus consumer dependencies. Simplified project structure by moving and cleaning up `Directory.Build.targets` files. * Refactor configuration and service extension methods. Moved `ShellSettingsExtensions` and `ShellConfiguration` to `CShells.Abstractions` for better modularity. Added new `ServiceCollectionFeatureExtensions` to improve options registration. Updated appsettings and references to support these changes. * Introduce ManagementServiceCollectionExtensions to streamline activity and variable registration Added `ManagementServiceCollectionExtensions` for registering Elsa activity types and variable descriptors, providing a modular and shell-feature-compatible approach to configuration. Updated relevant features to utilize these new extension methods, enhancing code modularity and reducing redundancy. * Add resilience strategy registration to HTTP feature Introduced `ResilienceServiceCollectionExtensions` to register resilience strategies within the `Elsa.Resilience.Core` module. Updated `HttpFeature` to incorporate resilience strategies, enhancing HTTP-related resilience configuration leveraging the new extension methods. * Add new configuration options to JavaScriptFeature Implemented multiple properties in `JavaScriptFeature` to enhance JavaScript execution: `AllowClrAccess`, `AllowConfigurationAccess`, `ScriptCacheTimeout`, `DisableWrappers`, and `DisableVariableCopying`. These additions enable more flexible and secure configuration of the Jint JavaScript engine. * refactor(workflows): unify graph caching Resolve workflow definitions first and store graphs under stable per-version-ID cache keys so different lookup paths share entries. Centralize cache creation and change-token registration to remove duplicated caching logic. Skip materializer-unavailable definitions to avoid caching null graphs and simplify flow. * refactor(tests): centralize default IDs and materializer setup Introduce constants for default definition and version IDs, and materializer name. Refactor tests to use these constants, streamline graph and definition resolution, and improve cache key creation by sharing logic across tests. Extend tests to check scenarios with unavailable materializers, ensuring caching only occurs for valid cases. * extend(tests): enhance cache key verification in AutoUpdateTests Added checks for both workflow definition and version cache keys in AutoUpdateTests to ensure comprehensive cache validation, improving test reliability and coverage. * refactor(projects): update CShells project paths and solution configuration Revised project reference paths in `Elsa.ModularServer.Web.csproj` for CShells projects and updated `Elsa.sln` to include new CShells projects, streamlining project organization and build configuration. * Add `IWorkflowReferenceGraphBuilder` to `WorkflowManagementFeature`; rename `ResilienceShellFeature` to `ResilienceFeature`. * Refactor `HttpFeature` to use `IMiddlewareShellFeature`, include `HttpWorkflowsMiddleware`, and update `HttpActivityOptions` defaults. * Add `AddTypeAlias` and `AddVariableTypeAndAlias` extension methods to service collections - Introduced `AddTypeAlias<T>` method in `ServiceCollectionExtensions.cs` for adding type aliases. - Added `AddVariableTypeAndAlias<T>` method in `ManagementServiceCollectionExtensions.cs` to add variable types with aliases. * Update CShells package versions to 0.0.11 and replace ProjectReferences with PackageReferences in project files |
||
|
|
56ad8990e4
|
Merge branch 'fix/trigger-indexing-idempotency' | ||
|
|
0a2e99ad42
|
Expose consumers API and recursive export option (#7309)
* Initial plan
* Add consumers API endpoint and enhance export with IncludeConsumingWorkflows option
- New endpoint: GET /workflow-definitions/{definitionId}/consumers
- Export request model: added IncludeConsumingWorkflows boolean property
- Export endpoint: recursive consumer discovery and inclusion in exports
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
* Address greptile-apps feedback: fix double-fetch, remove redundant HashSet, add version comment, remove unused params
- Extract WriteZipResponseAsync helper to avoid double-fetching definitions from DB
- Remove redundant existingDefinitionIds HashSet in IncludeConsumersAsync
- Add XML doc comment documenting that consumers are resolved at VersionOptions.Latest
- Remove unused constructor parameters (workflowDefinitionService, variableDefinitionMapper)
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
* Address greptile-apps round 2: 404 for unknown definitions, deterministic ZIP response, parallel BFS
- Consumers endpoint now returns 404 when the definition ID doesn't exist
- Single-workflow export always returns ZIP when includeConsumingWorkflows=true
- BFS traversal processes each frontier level concurrently via Task.WhenAll
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
* Implement workflow reference graph feature
- Added `IWorkflowReferenceGraphBuilder` interface for building complete graphs of workflow references.
- Created `WorkflowReferenceGraph` and `WorkflowReferenceEdge` models.
- Implemented `WorkflowReferenceGraphBuilder` service for recursive graph building.
- Replaced previous workflow reference query logic with the new graph-based approach in consumers.
* Refactor workflow consumers to utilize recursive graph-based approach for retrieving consumer definitions.
* Enhance workflow export by adding support for including consuming workflows and update nullable default values across endpoints and models.
* Add WorkflowReferenceGraphOptions for depth and definition limit configuration
- Introduced `WorkflowReferenceGraphOptions` to configure max depth and definition limits for reference graph building.
- Updated `WorkflowManagementFeature` to support configuring these options.
- Enhanced `WorkflowReferenceGraphBuilder` to respect configuration limits during graph construction process.
* Refactor `WorkflowReferenceGraphBuilder` to utilize target-typed new expressions for cleaner code.
* Add Workflow Reference Graph tests and scenarios
Introduced JSON files for parent-child-grandchild workflow hierarchy tests and implemented unit tests for `WorkflowReferenceGraphBuilder`. Also added component tests for workflow export and consumers endpoint validation. Updated project configuration for workflow JSON to always copy to output directory.
* Include DefinitionId in exported workflow definition filenames for uniqueness.
* Remove unused models and constants from `WorkflowReferenceGraphTests`.
* Refactor `WorkflowReferenceGraphBuilderTests`: streamline test setup with `SetupGraph`, replace repeated assertions with helper methods.
* Deterministic ZIP export and 404 test coverage for consumers endpoint (#7312)
* Initial plan
* Fix deterministic ZIP export and add 404 test for consumers endpoint
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
|
||
|
|
ca88051573
|
Improves workflow materializer handling (#7195)
* Add tenant headers support to BackgroundWorkflowCancellationDispatcher (#7040) * Add tenant headers support to BackgroundWorkflowCancellationDispatcher * Fix 'CreateHeaders' call * Fix memory leak: Dispose IronCompressResult in Zstd codec (#7193) * Initial plan * Fix memory leak: Dispose IronCompressResult in Zstd codec and add tests Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com> * Refactor tests to be more DRY using Theory and InlineData Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com> * Introduce `IMaterializerRegistry` to manage workflow materializers and ensure availability checks. * Extend `IWorkflowDefinitionService` and `CachingWorkflowDefinitionService` with workflow graph lookup methods (`TryFindWorkflowGraphAsync`). Refactor caching and materialization logic for consistency. * Refactor caching interface and implementation: add `FindOrCreateAsync`, update `GetOrCreateAsync` to ensure non-null results, and improve exception handling. * Refactor `GetWorkflowGraphAsync` to use `TryFindWorkflowGraphAsync` and improve exception handling for missing workflow definitions and materializers. * Refactor caching logic to replace `GetOrCreateAsync` with `FindOrCreateAsync` for improved clarity and consistency. * Update workflow model, add event, and mark exception obsolete Updated `TimestampFilter.Column` to use a `null!` default value for clarity. Added `Event1` in the `hello-world.elsa` workflow and removed an unused folder entry from the project. Marked `WorkflowGraphNotFoundException` as obsolete with guidance to use `WorkflowDefinitionNotFoundException` instead. * Add new workflow files and exception classes for Elsa Introduced a workflow definition file "eventing.json" and new exception classes (`WorkflowDefinitionNotFoundException` and `WorkflowMaterializerNotFoundException`) to enhance handling of workflow-related errors. Also added a `WorkflowGraphFindResult` model for better workflow graph management. These changes improve the structure and functionality of the workflow system. * Add unit tests for `CachingWorkflowDefinitionService` and related helpers Introduce comprehensive unit tests to validate caching logic, workflow graph/materialization behavior, and cache key generation in `CachingWorkflowDefinitionService`. Add `WorkflowDefinitionServiceTests` and helper methods for streamlined test setup. * Enable `UseElsaScriptBlobStorage` in workflow server configuration * Refactor `BackgroundWorkflowCancellationDispatcher` to simplify object initialization and clean up XML documentation comments * Address PR #7195 review feedback: optimize caching, improve exceptions, add test coverage (#7196) * Initial plan * Apply PR review feedback: Fix exceptions, optimize caching, improve error handling Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com> * Add unit tests for MaterializerRegistry and LocalWorkflowClient exception handling Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com> * Add unit tests for BackgroundWorkflowCancellationDispatcher tenant headers Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com> * Refactor `WorkflowMaterializerNotFoundException` to improve structure and usability, update related references, and simplify object initialization in test cases. * Update `WorkflowDefinitionServiceTests` to use `WorkflowMaterializerNotFoundException` in place of `InvalidOperationException` for materializer not found scenario --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Potential fix for pull request finding 'Inefficient use of ContainsKey' Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> * Refactor tests and services: simplify object initialization, use target-typed `new()` syntax, and replace `CancellationToken` with `CancellationToken.None` where applicable. * Refactor tests in `BackgroundWorkflowCancellationDispatcherTests`: improve tenant initialization and optimize header checks by replacing `TryGetValue` with `ContainsKey`. --------- Co-authored-by: Sverre Winkelmans <69142682+Sverre-W@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> |
||
|
|
8747151330
|
Add code coverage configuration and adjust test projects (#7049)
* Add code coverage configuration and adjust test projects - Introduced `Include` and `Threshold` properties across test project files for improved code coverage tracking. - Added `coverlet.collector` as a dependency for coverage data collection. - Removed unused `global using` directives and redundant imports for cleaner test codebases. * Update GitHub Actions workflows for pull request triggers - Adjusted `pr.yml` to include `patch/*` and `develop/*` branches. - Removed redundant pull request triggers in `packages.yml` for cleaner configuration. * Expand pull request triggers in GitHub Actions - Renamed `PR` workflow to `pr` for consistency. - Included `patch/*` and `develop/*` branches in `pr.yml` and `Build.CI.GitHubActions.cs`. * Remove pack target from pull request workflows - Updated `pr.yml` to exclude the pack step. - Adjusted `Build.CI.GitHubActions.cs` to reflect the removal of the pack target. * Remove `Elsa.Workflows.Api` from integration test project references - Updated `Elsa.Workflows.IntegrationTests.csproj` to exclude `Elsa.Workflows.Api` from the `Include` list and project references for cleanup and simplification. |
||
|
|
fcd0b5ae9a
|
Feat/unit test coverage sendhttprequest (#6961)
* Unit test coverage for SendHttpRequest + useful extensions * Update src/modules/Elsa.Workflows.Core/Extensions/ActivityExecutionContextExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update test/unit/Elsa.Activities.UnitTests/HTTP/SendHttpRequestTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update test/unit/Elsa.Activities.UnitTests/HTTP/SendHttpRequestTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Improvements on unit test and documentation for http * Update doc/qa/test-guidelines.md Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> * Improvements on maintainability of sendhttprequest unit tests * Improving tests and scheduled activity evaluation for activity context * Refactor and splitting unnecessary grouped tests * Improvements on SendHttp Unit tests * Improvements on tests * Update test/unit/Elsa.Activities.UnitTests/HTTP/SendHttpRequestTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Small suggestions from copilot * Update test/unit/Elsa.Activities.UnitTests/HTTP/SendHttpRequestTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * small copilot suggestion * Introduce Scheduler Strategy Interfaces and Implementations for Workflow and Activity Execution Contexts (#6984) * Introduce Scheduler Strategy Interfaces and Implementations for Workflow and Activity Execution Contexts - Added `IWorkflowExecutionContextSchedulerStrategy` and `IActivityExecutionContextSchedulerStrategy` interfaces. - Implemented `WorkflowExecutionContextSchedulerStrategy` and `ActivityExecutionContextSchedulerStrategy` for scheduling activities in workflows. - Refactored scheduling logic to utilize the new scheduler strategies. - Updated unit tests and test helpers to reflect refactoring, introducing fake implementations for testing purposes. - Adjusted background execution scheduling and improved extensibility for custom scheduler strategies. * Refactor `SendHttpRequestTests`: simplify scheduling assertions, use shared extensions, and standardize method naming. Streamline helper methods and remove unused test logic. * Refactor: Replace `ActivityTestHelper` with `ActivityTestFixture` in unit tests for streamlined activity testing - Introduced `ActivityTestFixture` with a fluent API for better test setup and execution of activities. - Added extension methods `ActivityTestFixtureExtensions` and `ActivityTestFixtureHttpExtensions` for configuring attributes and HTTP services. - Updated test guidelines and unit tests to use the new fixture and extensions. - Removed `ActivityTestHelper`. * Refactor: Move `ActivityTestFixture` and related extensions to shared project for reuse across test suites - Consolidated `ActivityTestFixture`, `ActivityTestFixtureExtensions`, and `ActivityTestFixtureHttpExtensions` into `Elsa.Testing.Shared`. - Updated namespaces and imports across unit tests to reflect new structure. - Enhanced `AssertActivityAttributes` and added fluent configuration APIs. - Adjusted `Directory.Packages.props` with new dependencies, including `NSubstitute` and `xunit.assert`. * Refactor `SetVariableTests`: inline `ActivityTestFixture` initialization to simplify test setup. * Refactor `ActivityTestFixture`: eliminate redundant field `_services`, add `UsedImplicitly` attributes, and improve service collection management * Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Add XML documentation for `ActivityExecutionContextExtensions`, detailing methods and parameters. * Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Add XML documentation for scheduler strategies and their methods - Updated `IActivityExecutionContextSchedulerStrategy` and `IWorkflowExecutionContextSchedulerStrategy` interfaces with XML summaries for methods. - Added XML documentation to implementations (`ActivityExecutionContextSchedulerStrategy`, `WorkflowExecutionContextSchedulerStrategy`) and test fakes for clarity. * Refactor `WriteLineTests`: consolidate duplicate test logic, simplify setup with shared helper method, and enhance readability in assertions. * Refactor `WriteLineTests` and `SetVariableTests`: replace `WriteLineAsync` assertions with synchronous `WriteLine`, streamline exception recording in `SetVariableTests`, and remove unused imports. * Add `ParallelTests` for unit and integration testing with various scenarios (#6988) - Added unit tests for `Parallel` activity to ensure proper scheduling of child activities, including empty and mixed activity cases. - Added integration tests to validate execution flow and edge cases for `Parallel` activities (e.g., nested parallelism, fault handling). - Enhanced `ScheduleChildrenAsync` in `Parallel` to handle no activity scenario by completing immediately. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Add new unit and integration tests for activity input and expression evaluation (#6990) * Introduce Scheduler Strategy Interfaces and Implementations for Workflow and Activity Execution Contexts - Added `IWorkflowExecutionContextSchedulerStrategy` and `IActivityExecutionContextSchedulerStrategy` interfaces. - Implemented `WorkflowExecutionContextSchedulerStrategy` and `ActivityExecutionContextSchedulerStrategy` for scheduling activities in workflows. - Refactored scheduling logic to utilize the new scheduler strategies. - Updated unit tests and test helpers to reflect refactoring, introducing fake implementations for testing purposes. - Adjusted background execution scheduling and improved extensibility for custom scheduler strategies. * Refactor `SendHttpRequestTests`: simplify scheduling assertions, use shared extensions, and standardize method naming. Streamline helper methods and remove unused test logic. * Refactor: Replace `ActivityTestHelper` with `ActivityTestFixture` in unit tests for streamlined activity testing - Introduced `ActivityTestFixture` with a fluent API for better test setup and execution of activities. - Added extension methods `ActivityTestFixtureExtensions` and `ActivityTestFixtureHttpExtensions` for configuring attributes and HTTP services. - Updated test guidelines and unit tests to use the new fixture and extensions. - Removed `ActivityTestHelper`. * Refactor: Move `ActivityTestFixture` and related extensions to shared project for reuse across test suites - Consolidated `ActivityTestFixture`, `ActivityTestFixtureExtensions`, and `ActivityTestFixtureHttpExtensions` into `Elsa.Testing.Shared`. - Updated namespaces and imports across unit tests to reflect new structure. - Enhanced `AssertActivityAttributes` and added fluent configuration APIs. - Adjusted `Directory.Packages.props` with new dependencies, including `NSubstitute` and `xunit.assert`. * Refactor `SetVariableTests`: inline `ActivityTestFixture` initialization to simplify test setup. * Refactor `ActivityTestFixture`: eliminate redundant field `_services`, add `UsedImplicitly` attributes, and improve service collection management * Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Add XML documentation for `ActivityExecutionContextExtensions`, detailing methods and parameters. * Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Add XML documentation for scheduler strategies and their methods - Updated `IActivityExecutionContextSchedulerStrategy` and `IWorkflowExecutionContextSchedulerStrategy` interfaces with XML summaries for methods. - Added XML documentation to implementations (`ActivityExecutionContextSchedulerStrategy`, `WorkflowExecutionContextSchedulerStrategy`) and test fakes for clarity. * Refactor `WriteLineTests`: consolidate duplicate test logic, simplify setup with shared helper method, and enhance readability in assertions. * Refactor `WriteLineTests` and `SetVariableTests`: replace `WriteLineAsync` assertions with synchronous `WriteLine`, streamline exception recording in `SetVariableTests`, and remove unused imports. * Add new unit and integration tests for activity input and expression evaluation - Introduced comprehensive test suites covering activity input evaluation, expression handling, and fault scenarios. - Added unit tests for `ExpressionDescriptorRegistry`, `ExpressionEvaluator`, and activity execution context extensions. - Added integration tests: `CustomInputEvaluatorTests`, `InputEvaluationErrorTests`, and `InputPropertyEvaluationTests`. - Enhanced code coverage for edge cases and async evaluation logic. * Remove unused `RunWorkflowAsync` extension method from `RunActivityExtensions`. * Rename `CustomInputEvaluatorTests` to `InputEvaluationTests` for consistency with naming conventions. * Remove unused `Elsa.Workflows.Activities` import from `RunActivityExtensions`. * Remove redundant comments from `InputEvaluationErrorTests` for clarity. * Refactor unit tests to streamline activity and expression evaluations - Refactored `ExecuteActivityAsync` and `ExecuteWriteLineAsync` into shared helpers for consistency and reuse across tests. - Replaced redundant mock setups with helper methods in `ExpressionDescriptorRegistryTests`. - Simplified test setup for expression and activity evaluation by removing unused imports and consolidating configuration logic. - Enhanced readability by reducing duplicate code and leveraging shared utility methods. * Refactor activity input evaluation tests - Extracted `CreateContextAsync` helper into `EvaluationTestHelpers` for reuse across evaluation test suites. - Replaced inline activity context setup with shared helper in `InputPropertyEvaluationTests`, `WrappedInputEvaluationTests`, and related test suites. - Simplified test method names for clarity and consistency. - Updated test annotations to enhance readability and align with naming conventions. * Remove redundant test cases and unused imports - Deleted duplicated and non-essential test cases across evaluation test suites. - Removed unused imports to improve code cleanliness and readability. - Streamlined variable initializations and method calls within test setups. * Remove redundant test case from `InputEvaluationErrorTests` - Deleted the `ContinuesEvaluationForMultipleInputs` test, as it overlaps with existing tests and does not provide additional coverage. * Remove redundant assertion from `InputPropertyEvaluationTests` - Deleted `Assert.True(context.GetHasEvaluatedProperties())`, as it is unnecessary for verifying test outcomes. * Remove redundant test cases from `WrappedInputEvaluationTests` - Deleted `UsesDefaultValueWhenInputIsNull` and `EvaluatesExpression` tests as they are either duplicated or unnecessary for current test coverage. * Add unit test projects for `Elsa.Workflows.Management` and `Elsa.Expressions` - Introduced new test projects to separate and organize unit tests for `Elsa.Workflows.Management` and `Elsa.Expressions`. - Updated `Elsa.sln` to include references to the newly added test projects. - Adjusted namespaces in affected test classes for consistency with the updated project structure. * Refactor `ExpressionEvaluatorTests` for clarity and consistency - Simplified test method names and annotations for improved readability. - Replaced duplicate mock setups with helper functions (`CreateContextAsync`, `CreateContextWithMockHandlerAsync`, and related methods). - Streamlined test setups by removing redundant code and consolidating context creation logic. - Updated test annotations to include descriptive `DisplayName` attributes. * Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Remove redundant comment from `ExpressionEvaluatorTests` for clarity * Remove redundant blank lines from unit test classes - Eliminated unnecessary blank lines across `ActivityExecutionContextExtensions` test suites to improve code readability and consistency. * Update src/modules/Elsa.Expressions/Services/ExpressionEvaluator.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Expand `test-guidelines.md` with testing best practices, helper references, and example snippets - Added detailed guidance on test project organization, updated helper documentation, and streamlined example code for activity unit testing. - Introduced scheduler strategy information and integration test patterns for deterministic tests. - Clarified usage of shared infrastructure like `ActivityTestFixture` and `AsyncWorkflowRunner`. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: lucas.hipolito <lukhipolito@yahoo.com.br> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com> |