Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide the ability to Mock WorkflowActivityContext #1358

Open
wants to merge 70 commits into
base: master
Choose a base branch
from

Conversation

siri-varma
Copy link

@siri-varma siri-varma commented Oct 10, 2024

Description

Made the WorkflowActivityContext abstract.
Created DaprWorkflowActivityContext and made it inherit from WorkflowActivityContext

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #1200

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

@WhitWaldo
Copy link
Contributor

@siri-varma It looks like the DCO check failed.

Could you please make sure each of your commits are signed?

Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
@siri-varma siri-varma force-pushed the users/svegira/make-context-mockable branch from a0e576f to f51def0 Compare October 10, 2024 21:02
@WhitWaldo
Copy link
Contributor

@siri-varma Looks like we've got several build errors regarding nullability. If you can fix those, I'd appreciate it!

m3nax and others added 21 commits December 20, 2024 14:38
…xunit.runner.visualstudio, Microsoft.AspNetCore.Mvc.Testing, Moq to the same version in all projects.

Signed-off-by: Manuel Menegazzo <manuel.menegazzo@outlook.com>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
…quest

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
…d types

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
…ality has been moved out to the Dapr.Workflow project instead.

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
This PR takes the implementation of the static method and puts it into the DaprClient instance, pulling from the existing apiTokenHeader on the instance to populate the daprApiToken, pulling the endpoint from the instance's httpEndpoint value and accepting only an appId argument so as to specify the ID of the Dapr app to connect to and place in the resulting URI.

---------

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
…irect) (dapr#1366)

Migrating whole solution to Central Package Management - several package version upgrades to address security advisories and otherwise.

---------

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
Extracting classes out to common project

---------

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
Protos pulled out to separate shared project

Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
Add link about Dapr bot to contribution documentation

Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
…rops s headers (dapr#1153)

* forward cloudevent props
Signed-off-by: Ilias Politsopoulos <polil91@hotmail.com>

* refactor middleware
Signed-off-by: Ilias Politsopoulos <polil91@hotmail.com>

* add cloud event property filters
Signed-off-by: Ilias Politsopoulos <polil91@hotmail.com>

* update string check
Signed-off-by: Ilias Politsopoulos <polil91@hotmail.com>

* forward cloudevent props
Signed-off-by: Ilias Politsopoulos <polil91@hotmail.com>

* refactor middleware
Signed-off-by: Ilias Politsopoulos <polil91@hotmail.com>

* add cloud event property filters
Signed-off-by: Ilias Politsopoulos <polil91@hotmail.com>

* update checks
Signed-off-by: Ilias Politsopoulos <polil91@hotmail.com>

---------

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Co-authored-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
* Changed headers, updated introduction to reflect the difference in serialization between either type and added a brief section to detail the use of System.Text.Json for weakly-typed Dapr actor clients and to point to official documentation on it

---------

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
…tead of directly (dapr#1363)

* Implemented against Dapr.Client.AspNetCore and Dapr.Client

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* SImplified DaprWorkflow DI registration and updated to use IConfiguration preference. Needs testing.

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Added missing copyright header

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Updated actor registration to prefer the updated IConfiguration-based approach for pulling the HTTP endpoint and API token

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Adopted accepted proposal's guidelines for favoring different environment variables for determining the sidecar endpoint. Added notes to explain this in the code going forward.

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Made some lines a little more concise, added hostname default to DaprDefaults to use when building endpoints.

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Fixed and updated unit tests

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Updated to put endpoint resolution mechanism in DaprDefaults within Dapr.Common  - updating projects and unit tests

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Updated packages to fix security advisory GHSA-447r-wph3-92pm

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Updated Workflow builder to use DaprDefaults with IConfiguration

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Updating global.json

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Tweaked global.json comment

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Adding braces per nit

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Consolidated both registration extension methods to remove duplication

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

---------

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
* Removed Serilog nuget from Directory.Packages.props

Signed-off-by: Manuel Menegazzo <manuel.menegazzo@outlook.com>

* Update Directory.Packages.props

Signed-off-by: Manuel Menegazzo <65919883+m3nax@users.noreply.github.com>

---------

Signed-off-by: Manuel Menegazzo <manuel.menegazzo@outlook.com>
Signed-off-by: Manuel Menegazzo <65919883+m3nax@users.noreply.github.com>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
WhitWaldo and others added 5 commits December 20, 2024 14:44
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
* Corrected several unit tests

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Updated extension name for consistency

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Updated registration name for consistency

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

---------

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
… binary data (dapr#1116)

* Added methods in status API supports for direct storage and reading of byte arrays dapr#906

Signed-off-by: Divya Perumal <divzi.perumal@gmail.com>
Signed-off-by: Divya Perumal <diperuma@microsoft.com>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
* Added null check - the proto suggests this shouldn't ever be null, but there's an issue reporting as much, so this fixes that

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Removed the Task.WhenAll making the operation non-blocking

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Added unit test to validate that the subscription is no longer blocking

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Removed unused line from previous test, added another test

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Added another test

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* More unit tests

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Added more unit tests

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Updated to make DaprPublishSubscribeClientBuilder configurable via a registered IConfiguration

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Added missing copyright statements

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Added missing package reference

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Fixed bad reference (missed in merge)

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Fixed failing unit test

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Tweak to only pass along EventMessage payloads to developers as it's expected that the initial response will be null if EventMessage is populated

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Was missing assignment of the Data property in the TopicMessage. Shout out to both @tommorvolloriddle and @Aimless321 for catching this!

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Fix - return would be bad. Continue is the right move.

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Added a simple test

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Fixed unit tests

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

* Merged in tweaks from dapr#1422

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>

---------

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
@siri-varma siri-varma force-pushed the users/svegira/make-context-mockable branch from ab7956f to 3dd8019 Compare December 20, 2024 22:46
siri-varma and others added 10 commits December 20, 2024 14:54
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
…Properties/launchSettings.json

Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
@siri-varma siri-varma force-pushed the users/svegira/make-context-mockable branch from 3461bc9 to 8f27ba7 Compare December 20, 2024 23:08
siri-varma and others added 4 commits December 20, 2024 21:00
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
@siri-varma siri-varma force-pushed the users/svegira/make-context-mockable branch from 7c684dc to e3e6b0a Compare December 21, 2024 06:43
svegiraju-microsoft and others added 3 commits December 20, 2024 22:45
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
…Properties/launchSettings.json

Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <svegiraju@microsoft.com>
@siri-varma siri-varma force-pushed the users/svegira/make-context-mockable branch from f81134b to ea4ac28 Compare December 21, 2024 06:46
@siri-varma
Copy link
Author

@WhitWaldo let me know if anything else is needed on this PR. Thank you

@siri-varma siri-varma closed this Dec 27, 2024
@siri-varma siri-varma reopened this Dec 27, 2024
Copy link
Contributor

@WhitWaldo WhitWaldo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of nits and we're good here.


/// <summary>
/// Gets the unique ID of the current workflow instance.
/// Gets the unique ID of thcurrent workflow instance.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"thcurrent" -> "the current"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@siri-varma If you can fix that typo, we're good to go here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WorkflowActivityContext cannot be mocked