Commit graph

47 commits

Author SHA1 Message Date
MariusVuscanNx d817d7ccaf
Global read-only and read-only workflows (#5406)
* Implemented global readonly and workflow readonly

* Fixed bug of unfilled versions

* Fixed failing test

* Updated pipeline

* Revert

* Pushed fixes based on the PR comments and fixed history bug

* Implemented changes based on PR comments

* Fixed issue in caused by AuthorizationHandler not being able to receive null resources

* Remove unused Google.Protobuf dependency in Program.cs

An unused Protobuf library import was found in Program.cs file. In order to clean up the code and improve readability, this import statement has been removed. No other changes have been made.

* Refactor code to reduce redundancy and improve readability

Optimize code by removing unnecessary constructor assignments and simplify function calls. The simplification is mainly achieved by directly passing the required services as constructor parameters instead of assigning them to private fields first. This results in a more readable and less redundant code.

---------

Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2024-05-27 10:06:39 +02:00
Sipke Schoorstra f03c62a7a4
Revert sending input as global state instead of parameter (#5425)
* Add distributed locking to MassTransitWorkflowDispatcher

This commit introduces a distributed lock to the MassTransitWorkflowDispatcher to prevent concurrent updates to the workflow instance. The lock is acquired before any interaction with the workflow instance and is released after the update operation is complete.

* Refactor MassTransitWorkflowDispatcher for simplified code

Removed unnecessary code in the MassTransitWorkflowDispatcher.cs class, previously used to handle input and properties. Refactored to directly include input and properties in the DispatchWorkflowInstanceRequest object, increasing efficiency and readability.

* Remove unused IDistributedLockProvider dependency

The IDistributedLockProvider dependency in the constructor of MassTransitWorkflowDispatcher class was removed because it was identified as unnecessary in this context. This results in less complicated code and improved maintainability.

* Add bulk dispatch workflows unit tests

Added a new file `BulkDispatchWorkflowsTests.cs` that contains tests for Bulk Dispatch Workflows. Also, two new workflow files `EmployeeGreetingWorkflow.cs` and `GreetEmployeesWorkflow.cs` were added to define workflows used in the unit tests. This will help ensure the Bulk Dispatch Workflows feature is working as expected.
2024-05-22 17:22:19 +02:00
Sipke Schoorstra 6a0f74e06c
Fix FlowJoin Activity NRE Bug (#5349)
* Update property retrieval in FlowJoin activity

This commit modifies the way flowScope is retrieved within the FlowJoin activity in Elsa.Workflows.Core. Instead of directly calling GetProperty, a fallback value is now being provided in case the desired property is not found. This reduces the risk of null reference exceptions.

* Add FlowJoins component tests

Two new files have been created to facilitate component testing for the FlowJoins scenarios in the Elsa Workflows. The `Tests.cs` file includes a Fact to validate the successful execution of a Flowchart with a single FlowJoin. The `Workflows.cs` file defines a single join workflow for these tests.

* Add RabbitMq support to ComponentTests

Added RabbitMq to Infrastructure.cs for component testing, allowing both RabbitMqContainer and DbContainer to start and stop asynchronously. Also, adjusted WorkflowServer.cs to configure RabbitMq mass transit alongside existing PostgreSql support, aiming to improve testing robustness and coverage.

* Refactor placement of RemoveOrphanedSubscriptions service

Move the implementation of AddNotificationHandler<RemoveOrphanedSubscriptions>() from the notifier block to the singleton section in AzureServiceBusFeature.cs. This will help keep all service registration related to notifications in one place.

* Increase prefetch count
2024-05-08 09:29:15 +02:00
Sipke Schoorstra b6689c7e2b
Fix Race Condition in WorkflowDefinitionActivity (#5315)
* Refactor hash method in Hasher.cs

The Hash method in the Hasher.cs file has been refactored to use more efficient code. Instead of creating a SHA256 instance, it directly hashes the data using SHA256.HashData. As a result, the private Hash method and its usage, which only has relevance to the previous approach, have been removed.

* Replace GetHashCode with SHA256 for script caching

Two unused namespaces, Esprima and Esprima.Ast, have been removed, and two new ones, System.Security.Cryptography and System.Text, have been added. These changes in Elsa.JavaScript's JintJavaScriptEvaluator file were made to replace the basic GetHashCode method, which was used earlier to generate a cache key for JavaScript scripts, with SHA256 hash function to ensure uniqueness and avoid possible hash collisions. This greatly increases the reliability of the caching mechanism.

* Set HTTP client timeout in WorkflowServer

The client timeout in WorkflowServer has been set to 1 minute for `ResrService` and `client` methods. This was done to manage long running requests and prevent timeouts.

* Refactor code and add validation in ScheduleActivityAsync methods

An unnecessary line of code in the ScheduleActivityAsync method under the ActivityExecutionContext file has been removed to simplify the function. Meanwhile, validation has been added to ensure that specified activities are part of the workflow. This improves code clarity and prevents potential errors caused by incorrect activity scheduling.

* Refactor ActivityVisitor to use ActivityVisitorContext

The ActivityVisitor class in Elsa.Workflows.Core was refactored to use an ActivityVisitorContext class. The introduction of this context class replaced the multiple hashsets that were used within function signatures, consolidating them into a single object and reducing function complexity. This change improves readability and code organization.

* Refactor WorkflowDefinitionActivity to use WorkflowGraph

Adjusted the WorkflowDefinitionActivity class in the Elsa.Workflows.Management module. The changes include migration from using Workflow to WorkflowGraph objects and condensing code blocks for clearer readability. Additionally, a new 'IsInitialized' field is added to eliminate potential race conditions during the graph construction process.

* Add activity validation to WorkflowExecutionContext

A check has been implemented in the WorkflowExecutionContextExtensions to validate that a specified activity is part of the workflow. This prevents incorrect activity references when scheduling tasks in the workflow.

* Refactor to use WorkflowGraph instead of Workflow

The codebase has been refactored to utilize the WorkflowGraph instead of the Workflow while running and manipulating workflows. Additional changes include restructuring WorkflowRunner and WorkflowDefinitionService classes, introducing WorkflowGraphBuilder usage, and mapping updates in WorkflowDefinitionMapper. The WorkflowHost, WorkflowDispatcher, and WorkflowExecutionContext have also been updated accordingly.

* Add WorkflowGraph and related services

This commit introduces the IWorkflowGraphBuilder interface, the WorkflowGraph model, and an implementation of the interface in the WorkflowGraphBuilder class. The purpose of these additions is to establish the building and structure of a workflow graph. The WorkflowGraph model also includes activity node handling and hashing capabilities.

* Add tests to ensure exception when scheduling an activity not part of workflow

Several unit tests were written to ensure that the right behavior is exhibited when scheduling an activity that is not part of the workflow. An exception is expected to be thrown in this case. Additionally, new service definitions, workflow definitions and workflow queries were added for more comprehensive testing.

* Update WorkflowGraph class and add comment descriptions

This commit updates the WorkflowGraph class by extending its descriptions and implementing an explicit mention to the Workflow reference. Additionally, more attribute descriptions have been added to increase code readability and comprehension.

* Removed unnecessary brackets

* Remove unused services from workflow management

This commit deletes "ExpressionDescriptorRegistryPopulator.cs" and "ScopedWorkflowDefinitionLookup.cs" files from Elsa.Workflows.Management.Services. These files, containing obsolete services, are no longer used in the workflow management process. The services' registration has been removed as well from "WorkflowManagementFeature.cs".

* Remove TestWorkflowDefinitionService.cs from component tests

A file, TestWorkflowDefinitionService.cs, was removed under Elsa.Workflows.ComponentTests. This is part of the improvement process where inefficient or unnecessary test files are cleaned up.

* Add comments to WorkflowDefinitionActivityTests

This commit adds explanatory comments to the WorkflowDefinitionActivityTests file. The comments provide information about the purpose of these tests and a reference to a related issue in the project's Github repository.

* Updated duplicate and missing package references

---------

Co-authored-by: Raymond den Haan <raymond.den.haan@nexxbiz.io>
2024-05-01 14:53:37 +02:00
Sipke Schoorstra 406469825c
Add Component Testing Framework (#5261)
* Add application component tests

Multiple new test files were added to deliver application component tests. This move improves testing by adding integration tests that cover overall system behavior and checking end-to-end actions. Ensuring the system functions correctly as a whole. In the process, updating some package versions to maintain compatibility.

* Add RefitSettings helper and revise API client service configuration

The commit introduces a 'RefitSettingsHelper' for Elsa API client and revises the way the API client services are configured. It also makes improvements to the WorkflowServerTestWebAppFactory for component testing. Some endpoint contracts related to workflow execution are also updated to have optional parameters.

* Remove old tests and add new workflow tests

This commit removes old, unnecessary tests and incorporates new workflow tests. It also improves the Elsa API client JSON serializer and adds a helper for HttpResponseMessage. Lastly, the commit introduces changes to properly configure the test logging and to manage application settings.

* Add HttpHelloWorld workflow tests

A new component test scenario, HttpHelloWorldTests, has been created for testing an HttpHelloWorld workflow. This involves asserting if a workflow responds correctly with "Hello World". Furthermore, an HTTP workflow client has been introduced in the WorkflowServerTestWebAppFactory class to provide a base address for workflow API calls.

* Add new test file and update workflow execution tests

This change adds a new test file "fork-1.json" to the Elsa.Workflows.Api.ComponentTests project. Also, updates were made throughout the tests to replace the WorkflowServerTestWebAppFactory with a fixture, allowing the tests to run in parallel. Lastly, unnecessary warning suppression was removed from the Elsa.Workflows.Core extension method.

* Add filter for .json and .elsa files in BlobStorageWorkflowProvider

This change adds a BrowseFilter in the BlobStorageWorkflowProvider options. This filter checks for files that end with .json or .elsa and includes only these files when browsing through the blob storage. This filter helps prioritize specific workflow file types.

* Rename WorkflowServerTestWebAppFactoryFixture and update usage

The old class name "WorkflowServerTestWebAppFactoryFixture" has been replaced with the more accurate "WorkflowServerWebAppFactoryFixture". All references to the previous name in other classes were also updated accordingly. In addition, the directory key in the method "CreateConvoyOptionsBuilder" has been updated from "Workflows" to "Scenarios".

* Update test fixture in workflow tests

The commit updates the test fixture in two test classes: HttpHelloWorldTests and HelloWorldTests. The former test fixture, WorkflowServerTestWebAppFactoryFixture, was replaced by WorkflowServerWebAppFactoryFixture to accurately match the testing needs.

* Update .csproj file paths and reorganize tests

The commit modifies the file paths for several test scenario files in the Elsa.Workflows.Api.ComponentTests.csproj, reflecting a reorganization of the tests. Previously static paths have been updated to new paths under 'Scenarios'. Additionally, two new test files related to 'LogPersistenceModes' have been included in the project.

* Add tests for log persistence modes

This commit introduces two new test scenarios for logging persistence modes and includes a related test called 'HelloWorldWorkflow'. These tests cover scenarios where certain workflow inputs should be stored and others shouldn't, thereby testing the log persistence feature. This ensures that the logging behavior respects the specified persistence mode.

* Add log persistence tests and update LogPersistenceMode enum

The commit contains the addition of new log persistence tests for verifying correctness of log persistence behavior. Furthermore, the LogPersistenceMode enum has been updated, replacing 'Default' with 'Inherit'. This change makes the mode's purpose clearer. Lastly, new test scenarios and test data files were added for more comprehensive testing.

* Remove obsolete component tests and support files

The files removed are no longer necessary for the current state of the application. They include various component tests and their related support files within the Elsa.Workflows.Api.ComponentTests project. By removing these, the project structure is cleaner and only contains relevant tests.

* Add dispatch workflow scenario tests and necessary helper classes

This commit includes two new tests for dispatching workflows, along with the creation of new 'ChildWorkflow' and 'DispatchAndWaitWorkflow' classes. Auxiliary helpers and services have been added to aid in managing workflow events and signals for these tests. The 'ComponentTest' has also been upgraded to support disposal handling.

* Remove ITestOutputHelper dependency from test classes

Removed the dependency on ITestOutputHelper in multiple test classes across various workflow scenarios. This change simplifies the test class constructors by reducing the number of required dependencies, contributing to cleaner and leaner code.

* Add 'Hello World' scenario to WorkflowCompletion tests

The 'Hello World' scenario was moved into WorkflowCompletion tests, along with changes in workflow definition identifiers. As part of these changes, the 'hello-world.json' file was updated; a new file under the same name was created in the WorkflowCompletion area and the workflow identifiers in basic and workflow completion tests were updated accordingly. Additionally, 'fork-1.json' has been renamed to 'fork.json'.

* Add support for cluster hosting tests

This commit introduces a suite of integration tests designed to validate the behaviour of hosting multiple instances of Elsa in a clustered environment. These tests simulate a typical clustered hosting scenario by using 'App', 'Cluster', and 'Infrastructure' objects to emulate different instances of the Elsa workflow engine running on separate servers. Name changes were made to certain classes and methods to reflect their new scopes and roles within the testing environment.

* Add performance tests and improve component tests

Added a new performance tests project scaffold, complete with its own project file, build properties file, and a dummy test. Updated component tests to improve multi-pod testing, primarily through the addition of additional service scopes and asserting activity registry synchronization. These changes also required updates to existing project and props files as well as the solution file.

* Update ActivityRegistrySyncTests and Infrastructure

Added a reference to Services in ActivityRegistrySyncTests and removed unnecessary whitespace in both files. The test component Elsa.Workflows has been modified to import newly added services, ensuring all tests are running with the expected resources and services.

* Fix comment

* Add NOOP implementations for stores

* Update PostgreSQL image and adjust test timings

The PostgreSQL image used for testing has been updated to the latest version from 13.3-alpine. Timeouts in ISignalManager and DispatchWorkflowsTests have been reduced for efficiency. A delay in the ChildWorkflow has also been decreased. Additionally, an 'ImportWorkflowActivity' test in ActivityRegistrySyncTests has been marked as not yet implemented.
2024-04-26 15:49:14 +02:00
cristinamudura 9fa1b4685e
Feature/sonar cloud (#5224)
* Update packages.yml

* Added sonar cloud properties

* Update packages.yml

* Update packages.yml

* Update packages.yml

* Update packages.yml

* Updated nuke Build to produce test coverage output

* Updated project key

* Fix organization key

* Versioning fix

* Removed sonar properties

* Added jdk17

* Changed build configuration for nuke

* Added opencover paths

* Added the coverlet collector NuGet package

* Added exclusions

* Updated workflow

* Modified exclusions

* Updated packages.yml to contain sonar cloud integration

* Removed test github action

* Updated for test coverage

* Updated MergeWith property for the tests

* Add verbose to check for code coverage issue

* Updated reportPaths

* Added --collect parameter

* Updates

* Updated packages workflow

* Updated exclusions

* Added sonar exclusions

* Updated exclusions

---------

Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2024-04-26 15:46:34 +02:00
Marko Lahma bc3d6d9bbc Convert to use Central Package Management
* Add GitHubActionsTestLogger
2024-02-04 13:49:54 +02:00
Marko Lahma 68beb5c61f replace configureawait.props and frameworks.props with Directory.Build.props 2024-01-26 19:04:39 +02:00
Sipke Schoorstra bec8cbc322
Target .NET 8 (#4660) 2023-11-27 11:26:16 +01:00
Sipke Schoorstra 45d194125d
Remove WorkflowStateStore (#4374)
* Remove WorkflowStateStore and use WorkflowInstanceStore instead

* Delete RunningWorkflows actor

* Cleanup
2023-08-30 15:42:16 +02:00
Sipke Schoorstra b3e0c0064c Fix sample and test 2023-08-28 22:44:43 +02:00
Sipke Schoorstra 911d13d31c Fix component test project reference 2023-08-05 10:40:09 +02:00
Sipke Schoorstra 815b544f53 Update Flowchart completion logic
In addition to taking into account scheduled work, also check if there are actual activity instances still running
2023-08-04 11:45:07 +02:00
Sipke Schoorstra 42ce946d64 Reset 2022-01-04 09:38:11 +01:00
Yopi Cahya 4933a2e81e
Upgrade all projects to .NET6.0 (#2616)
* Upgrade all projects to .NET6.0

* Add compatibility NET5.0

* Add compatibility NET Core 3.1

* Update appveyor.yml

* Update packages

* Update src/activities/Elsa.Activities.Http/Elsa.Activities.Http.csproj

Remove common Authorization package

* Update src/activities/Elsa.Activities.Http/Elsa.Activities.Http.csproj

reimplement fix for #1568

* reimplement fix for #1611

* add missing .netcoreapp3.1 references to persistence packages

* fix Jint reference

* change samples and tests to target .NET 6

* cleanup multi-targeting conditions in samples/tests

* revert Elsa and Elsa.Temporal.Common to .netstandard2.1 only

* Update docker files to use net6.0 SDK

* Fix docker poor performance on arm64

* Update Elsa.sln

* Update Elsa.Activities.RabbitMq.csproj

Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
Co-authored-by: Mohamed Ali <antivirus.cs@gmail.com>
2021-12-26 22:31:35 +01:00
Sipke Schoorstra 142b574481 Update packages 2021-09-16 20:25:38 +02:00
Sipke Schoorstra 6352372179 Update package references 2021-09-14 16:09:59 +02:00
Sipke Schoorstra cbfb21c4c9 Remove redundant Trigger parameter from workflow selection 2021-07-12 19:37:01 +02:00
Sipke Schoorstra bb4ff3b714 Update packages 2021-05-25 09:57:17 +02:00
Sipke Schoorstra e945e58ecf Fix component tests 2021-05-24 17:57:27 +02:00
Sipke Schoorstra cb94f4dde5 Update packages 2021-05-10 22:19:29 +02:00
Sipke Schoorstra ae46e0e143 Update packages and accommodate for breaking changes 2021-04-07 14:48:30 +02:00
Sipke Schoorstra 0434b4825a Update packages 2021-03-18 11:24:04 +01:00
Craig Fowler df83b9a1de WIP #665 - Beginnings of SonarCloud integration
Adds an XUnit test logger to each test csproj
file (will be used by test script).

Also add a skeleton SonarCloud analysis config file with a couple
of settings for starters: Don't analyse exception classes or samples
for coverage.
2021-02-27 14:33:45 +00:00
Craig Fowler 8d4339f4b0 Revert "Merge branch 'feature/665-SonarCloud-integration' into feature/elsa-2.0"
This reverts commit 3dc1b79b3b, reversing
changes made to 1dbafd8ba2.

The previous merge of work on #665 broke the build so this commit
reverts it back out.
2021-02-27 13:58:06 +00:00
Craig Fowler 8deb1a1f56 WIP #665 - Beginnings of SonarCloud integration
Adds an XUnit test logger to each test csproj
file (will be used by test script).

Also add a skeleton SonarCloud analysis config file with a couple
of settings for starters: Don't analyse exception classes or samples
for coverage.
2021-02-27 12:41:55 +00:00
Craig Fowler f34409696d
Should resolve #653 - Reinstate tests in CI process for v2 branch (#658)
* WIP #653 - Delete two tests

These two couldn't easily be fixed, in both cases they were
integration tests which involved passing through many classes.
It wasn't immediately clear what needed to be done to fix them.

As noted in the issue description, removing them was an
acceptable fix.

* WIP #653 - Fix a failing test

I split this test into two.  Per the discussion at:
  https://github.com/xunit/xunit/issues/350
XUnit seems quite opinonated about not having assertion messages.
Thus, without changing assertion library (which deserves discussion
before I just do it), the logical next best thing is to split into two
single-assert tests, so it's clear which assertion failed on a test
failure.

Also, I moved the AutoMoqData attribute to the shared test lib, so
that it can be used anywhere.  That allowed me to eliminate the
constructor for this test class, except for initialising the base class.

* Provisionally resolve #653 - reinstate tests in CI

This should complete the issue although we need to see a
passing CI build with this code change before we can say
it's done.

* Provisionally resolves #653 - Add test script
2021-02-25 09:24:00 +01:00
Sipke Schoorstra f048e6d3ef
Refactor Switch builder API (#649)
* Refactor Switch builder API

* Remove unused namespaces
2021-02-20 20:47:56 +01:00
Sipke Schoorstra 86980a752e
Designer web component (#636)
* Activity picker dialog

* Activity picker

* Activity editor

* Activity property fields

* Blazor bindings for Elsa designer

* Only index triggers from published & enabled workflow definitions

* Handle case of null workflow blueprint not found

* Add check for zero duration and general scheduler exceptions

* Don't rethrow expression evaluation failure

* Workflow definition settings editor modal

* Integration between stencil and blazor 🎉

* Fix expression type conversion

* Add publish button and restructure components

* Fix up workflow definition ID vs workflow definition version ID

* Update EF Core migrations

* Fix Workflow Publisher

* Fix version display

* Add Import menu item
2021-02-16 09:55:13 +01:00
Sipke Schoorstra e6f42aca8f Update packages 2021-01-21 12:45:10 +01:00
Sipke Schoorstra 5f08df0556 Add Dashboard samples: monolith + client/server 2020-12-27 11:53:52 +01:00
Sipke Schoorstra c047d66942 Update packages 2020-12-19 15:35:11 +01:00
Sipke Schoorstra 2d54b7e337 Add Rebus activities 2020-11-19 22:21:17 +01:00
Sipke Schoorstra fee41d1932 Implement auto-save 2020-11-19 15:14:39 +01:00
Sipke Schoorstra 757fde7e6e Update packages and incremental work on API 2020-11-18 22:31:16 +01:00
Sipke Schoorstra be92fe7d74 Incremental work on activity picker fetching activities from Elsa server using gRPC 2020-11-14 15:44:03 +01:00
Sipke Schoorstra 8be781d1e8 Add Activities API client 2020-11-13 21:30:07 +01:00
Sipke Schoorstra c75196f696 Add component tests 2020-11-13 20:47:08 +01:00
Sipke Schoorstra 0c5bdf27a7 Incremental work on API client 2020-11-13 15:30:23 +01:00
Sipke Schoorstra d31ef98bb1 Update to .NET 5 and update icon 2020-11-11 21:32:12 +01:00
Sipke Schoorstra 7f44bfe4c1 Replace precompiled queries with extensions, process warnings and fix test 2020-11-03 10:50:32 +01:00
Sipke Schoorstra 38470c0176 WIP: Declarative composite activities 2020-11-02 21:04:41 +01:00
Sipke Schoorstra 594853d45c Add Composite Activity support 2020-11-01 20:03:21 +01:00
Sipke Schoorstra 6755002f51 Add file/blob storage-based provider + test 2020-10-23 14:20:52 +02:00
Sipke Schoorstra c12c294b07 Incremental work on blob/file storage-based workflows 2020-10-21 22:27:02 +02:00
Sipke Schoorstra 400b4f827a Incremental work on tests, API endpoint, versioning and cleanup 2020-10-20 23:17:08 +02:00
Sipke Schoorstra bd3b41440a Incremental work on tests and QA 2020-10-19 22:12:11 +02:00